summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-01-16 09:45:54 +0100
committerYorhel <git@yorhel.nl>2021-01-16 09:46:10 +0100
commit4406605928109f1800582acf886a2b77c46dcea0 (patch)
treeee27436ffab50812ea61adeee8b9e48faa29a8e5
parentb82e89d248861bdd5dd4dfd2a793ee94d4a29185 (diff)
AdvSearch: Add VN subquery to character search
Damn, that was easy.
-rw-r--r--elm/AdvSearch/Fields.elm5
-rw-r--r--lib/VNWeb/AdvSearch.pm3
2 files changed, 6 insertions, 2 deletions
diff --git a/elm/AdvSearch/Fields.elm b/elm/AdvSearch/Fields.elm
index 35062e46..b9d02a8f 100644
--- a/elm/AdvSearch/Fields.elm
+++ b/elm/AdvSearch/Fields.elm
@@ -110,6 +110,7 @@ nestToQuery dat model =
(V, C) -> wrap (QQuery 51 op)
(V, S) -> wrap (QQuery 52 op)
(C, S) -> wrap (QQuery 52 op)
+ (C, V) -> wrap (QQuery 53 op)
(R, V) -> wrap (QQuery 53 op)
_ -> wrap identity
@@ -134,6 +135,7 @@ nestFromQuery ptype qtype dat q =
(V, C, QQuery 51 op r) -> initSub op r
(V, S, QQuery 52 op r) -> initSub op r
(C, S, QQuery 52 op r) -> initSub op r
+ (C, V, QQuery 53 op r) -> initSub op r
(R, V, QQuery 53 op r) -> initSub op r
(_, _, QAnd l) -> if ptype == qtype then Just (init True l) else Nothing
(_, _, QOr l) -> if ptype == qtype then Just (init False l) else Nothing
@@ -207,7 +209,7 @@ nestView dat dd model =
case (model.ptype, model.qtype) of
(_, C) -> ("Has a character that matches these filters", "Does not have a character that matches these filters")
(_, R) -> ("Has a release that matches these filters", "Does not have a release that matches these filters")
- (_, V) -> ("Has a visual novel that matches these filters", "Does not have a visual novel that matches these filters")
+ (_, V) -> ("Linked to a visual novel that matches these filters", "Not linked to a visual novel that matches these filters")
(V, S) -> ("Has staff that matches these filters", "Does not have staff that matches these filters")
(C, S) -> ("Has a voice actor that matches these filters", "Does not have a voice actor that matches these filters")
_ -> ("","")
@@ -444,6 +446,7 @@ fields =
, n C C "And/Or"
, n C S "Voice Actor »"
+ , n C V "Visual Novel »"
, f C "Role" 1 FMRole AS.init AS.roleFromQuery
, f C "Age" 0 FMAge AR.ageInit AR.ageFromQuery
, f C "Sex" 2 FMSex (AS.sexInit False) (AS.sexFromQuery False)
diff --git a/lib/VNWeb/AdvSearch.pm b/lib/VNWeb/AdvSearch.pm
index 0a0590a8..a47655cd 100644
--- a/lib/VNWeb/AdvSearch.pm
+++ b/lib/VNWeb/AdvSearch.pm
@@ -417,7 +417,8 @@ f c => 13 => 'trait', { type => 'any', func => \&_validate_trait },
# XXX: When this field is nested inside a VN query, it may match seiyuu linked to other VNs.
# This can be trivially fixed by adding an (AND vs.id = v.id) clause, but that results in extremely slow queries that I've no clue how to optimize.
-f c => 52 => 'seiyuu', 's', '=' => sub { sql 'c.id IN(SELECT vs.cid FROM vn_seiyuu vs JOIN staff_alias sa ON sa.aid = vs.aid JOIN staff s ON s.id = sa.id WHERE NOT s.hidden AND', $_, ')' };
+f c => 52 => 'seiyuu', 's', '=' => sub { sql 'c.id IN(SELECT vs.cid FROM vn_seiyuu vs JOIN staff_alias sa ON sa.aid = vs.aid JOIN staff s ON s.id = sa.id WHERE NOT s.hidden AND', $_, ')' };
+f c => 53 => 'vn', 'v', '=' => sub { sql 'c.id IN(SELECT cv.id FROM chars_vns cv JOIN vn v ON v.id = cv.vid WHERE NOT v.hidden AND', $_, ')' };