summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-06-13 18:00:59 +0200
committerYorhel <git@yorhel.nl>2018-06-13 18:00:59 +0200
commite3a336aae012ee1ed89fd6fb09ceba0b4e6c7c42 (patch)
tree848d3a0bb3529e6be3c7438b31ce33fdb1dd88b4
parent0c0007630fd310bc6857a94fe65703d1fb446177 (diff)
Multi::API: Add "get characters instances"
-rw-r--r--lib/Multi/API.pm18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 985081bd..c959539a 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -855,7 +855,23 @@ my %GET_CHARACTER = (
}
},
]]
- }
+ },
+ instances => {
+ fetch => [[ 'id', 'SELECT c2.id AS cid, c.id, c.name, c.original, c2.main_spoil AS spoiler FROM chars c2 JOIN chars c ON c.id = c2.main OR c.main = c2.main WHERE c2.id IN(%s)
+ UNION SELECT c.main AS cid, c.id, c.name, c.original, c.main_spoil AS spoiler FROM chars c WHERE c.main IN(%1$s)',
+ sub { my($n, $r) = @_;
+ for my $i (@$n) {
+ $i->{instances} = [ grep $i->{id} == $_->{cid} && $_->{id} != $i->{id}, @$r ];
+ }
+ for (@$r) {
+ $_->{id}*=1;
+ $_->{original} ||= undef;
+ $_->{spoiler}*=1;
+ delete $_->{cid};
+ }
+ }
+ ]]
+ },
},
filters => {
id => [