summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2017-08-14 18:22:25 +0200
committerYorhel <git@yorhel.nl>2017-08-14 18:22:45 +0200
commitd872f28ca4841a842fdf2573d40d49105add8672 (patch)
tree3ff67672ddba532485f9403aa0de91c293d43888
parent05077a1c55f01272e613fbc450c3381b5c814d82 (diff)
API: Some additions to the "get *list" commands
-rw-r--r--data/docs/1165
-rw-r--r--lib/Multi/API.pm22
2 files changed, 71 insertions, 16 deletions
diff --git a/data/docs/11 b/data/docs/11
index e9678e88..f5cf904a 100644
--- a/data/docs/11
+++ b/data/docs/11
@@ -1435,20 +1435,27 @@ Returned members:</p>
<td>Description</td>
</tr></thead>
<tr class="odd">
+ <td>uid</td>
+ <td>basic</td>
+ <td>integer</td>
+ <td>no</td>
+ <td>User ID</td>
+ </tr>
+ <tr>
<td>vn</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>Visual Novel ID</td>
</tr>
- <tr>
+ <tr class="odd">
<td>vote</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>In the range of 10 (lowest) to 100 (highest). These are displayed on the site as a fractional number between 1 and 10.</td>
</tr>
- <tr class="odd">
+ <tr>
<td>added</td>
<td>basic</td>
<td>integer</td>
@@ -1470,7 +1477,13 @@ Returned members:</p>
<td>uid</td>
<td>integer</td>
<td>=</td>
- <td>This filter must be present. The special value '0' is recognized as the currently logged in user.</td>
+ <td>The special value '0' is recognized as the currently logged in user.</td>
+ </tr>
+ <tr>
+ <td>vid</td>
+ <td>integer<br />array of integers</td>
+ <td>= != &gt; &lt; &gt;= &lt;=<br />= !=</td>
+ <td>Visual novel ID.</td>
</tr>
</table>
<p>
@@ -1493,27 +1506,34 @@ Returned members:</p>
<td>Description</td>
</tr></thead>
<tr class="odd">
+ <td>uid</td>
+ <td>basic</td>
+ <td>integer</td>
+ <td>no</td>
+ <td>User ID</td>
+ </tr>
+ <tr>
<td>vn</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>Visual Novel ID</td>
</tr>
- <tr>
+ <tr class="odd">
<td>status</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>0=Unknown, 1=playing, 2=finished, 3=stalled, 4=dropped.</td>
</tr>
- <tr class="odd">
+ <tr>
<td>added</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>Unix timestamp of when this item has been added.</td>
</tr>
- <tr>
+ <tr class="odd">
<td>notes</td>
<td>basic</td>
<td>string</td>
@@ -1535,7 +1555,13 @@ Returned members:</p>
<td>uid</td>
<td>integer</td>
<td>=</td>
- <td>This filter must be present. The special value '0' is recognized as the currently logged in user.</td>
+ <td>The special value '0' is recognized as the currently logged in user.</td>
+ </tr>
+ <tr>
+ <td>vid</td>
+ <td>integer<br />array of integers</td>
+ <td>= != &gt; &lt; &gt;= &lt;=<br />= !=</td>
+ <td>Visual novel ID.</td>
</tr>
</table>
<p>The notes mentioned under 'get votelist' also apply here.</p>
@@ -1551,20 +1577,27 @@ Returned members:</p>
<td>Description</td>
</tr></thead>
<tr class="odd">
+ <td>uid</td>
+ <td>basic</td>
+ <td>integer</td>
+ <td>no</td>
+ <td>User ID</td>
+ </tr>
+ <tr>
<td>vn</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>Visual Novel ID</td>
</tr>
- <tr>
+ <tr class="odd">
<td>priority</td>
<td>basic</td>
<td>integer</td>
<td>no</td>
<td>0=high, 1=medium, 2=low, 3=blacklist.</td>
</tr>
- <tr class="odd">
+ <tr>
<td>added</td>
<td>basic</td>
<td>integer</td>
@@ -1586,7 +1619,13 @@ Returned members:</p>
<td>uid</td>
<td>integer</td>
<td>=</td>
- <td>This filter must be present. The special value '0' is recognized as the currently logged in user.</td>
+ <td>The special value '0' is recognized as the currently logged in user.</td>
+ </tr>
+ <tr>
+ <td>vid</td>
+ <td>integer<br />array of integers</td>
+ <td>= != &gt; &lt; &gt;= &lt;=<br />= !=</td>
+ <td>Visual novel ID.</td>
</tr>
</table>
<p>The notes mentioned under 'get votelist' also apply here.</p>
@@ -1755,6 +1794,12 @@ Returned members:</p>
Check out the <a href="/t/an">announcements board</a> for more information about updates.
<br /><br />
</p>
+<b>2017-08-14</b>
+<ul>
+ <li>Add 'uid' field to "get votelist/vnlist/wishlist" commands</li>
+ <li>Add 'vn' filter to the same commands</li>
+ <li>The 'uid' filter for these commands is now optional, making it possible to find all list entries for a particular VN</li>
+</ul>
<b>2017-06-21</b>
<ul>
<li>Add "resolution", "voiced", "animation" members to "get release" command</li>
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 9ad2a33a..c9b2540d 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -1008,12 +1008,20 @@ my %GET_USER = (
# the uid filter for votelist/vnlist/wishlist
my $UID_FILTER = [ 'int' => 'uid :op: :value:', {qw|= =|}, range => [0,1e6], process => \&subst_user_id ];
+# Similarly, a filter for 'vid'
+my $VN_FILTER = [
+ [ 'int' => 'vid :op: :value:', {qw|= = != <> > > < < <= <= >= >=|}, range => [1,1e6] ],
+ [ inta => 'vid :op:(:value:)', {'=' => 'IN', '!=' => 'NOT IN'}, range => [1,1e6], join => ',' ],
+];
+
+
my %GET_VOTELIST = (
islist => 1,
sql => "SELECT %s FROM votes v WHERE (%s) AND NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = v.uid AND key = 'hide_list') %s",
sqluser => q{SELECT %1$s FROM votes v WHERE (%2$s) AND (uid = %4$d OR NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = v.uid AND key = 'hide_list')) %3$s},
- select => "vid as vn, vote, extract('epoch' from date) AS added",
+ select => "uid, vid as vn, vote, extract('epoch' from date) AS added",
proc => sub {
+ $_[0]{uid}*=1;
$_[0]{vn}*=1;
$_[0]{vote}*=1;
$_[0]{added} = int $_[0]{added};
@@ -1021,15 +1029,16 @@ my %GET_VOTELIST = (
sortdef => 'vn',
sorts => { vn => 'vid %s' },
flags => { basic => {} },
- filters => { uid => [ $UID_FILTER ] }
+ filters => { uid => [ $UID_FILTER ], vn => $VN_FILTER }
);
my %GET_VNLIST = (
islist => 1,
sql => "SELECT %s FROM vnlists v WHERE (%s) AND NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = v.uid AND key = 'hide_list') %s",
sqluser => q{SELECT %1$s FROM vnlists v WHERE (%2$s) AND (uid = %4$d OR NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = v.uid AND key = 'hide_list')) %3$s},
- select => "vid as vn, status, extract('epoch' from added) AS added, notes",
+ select => "uid, vid as vn, status, extract('epoch' from added) AS added, notes",
proc => sub {
+ $_[0]{uid}*=1;
$_[0]{vn}*=1;
$_[0]{status}*=1;
$_[0]{added} = int $_[0]{added};
@@ -1038,15 +1047,16 @@ my %GET_VNLIST = (
sortdef => 'vn',
sorts => { vn => 'vid %s' },
flags => { basic => {} },
- filters => { uid => [ $UID_FILTER ] }
+ filters => { uid => [ $UID_FILTER ], vn => $VN_FILTER }
);
my %GET_WISHLIST = (
islist => 1,
sql => "SELECT %s FROM wlists w WHERE (%s) AND NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = w.uid AND key = 'hide_list') %s",
sqluser => q{SELECT %1$s FROM wlists w WHERE (%2$s) AND (uid = %4$d OR NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = w.uid AND key = 'hide_list')) %3$s},
- select => "vid AS vn, wstat AS priority, extract('epoch' from added) AS added",
+ select => "uid, vid AS vn, wstat AS priority, extract('epoch' from added) AS added",
proc => sub {
+ $_[0]{uid}*=1;
$_[0]{vn}*=1;
$_[0]{priority}*=1;
$_[0]{added} = int $_[0]{added};
@@ -1054,7 +1064,7 @@ my %GET_WISHLIST = (
sortdef => 'vn',
sorts => { vn => 'vid %s' },
flags => { basic => {} },
- filters => { uid => [ $UID_FILTER ] }
+ filters => { uid => [ $UID_FILTER ], vn => $VN_FILTER }
);