summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/DB')
-rw-r--r--lib/VNDB/DB/Chars.pm22
-rw-r--r--lib/VNDB/DB/VN.pm6
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm
index be620378..86b3a859 100644
--- a/lib/VNDB/DB/Chars.pm
+++ b/lib/VNDB/DB/Chars.pm
@@ -8,7 +8,8 @@ use Exporter 'import';
our @EXPORT = qw|dbCharGet dbCharRevisionInsert dbCharImageId|;
-# options: id rev instance traitspoil trait_inc trait_exc char what results page
+# options: id rev instance tagspoil trait_inc trait_exc char what results page gender bloodt
+# bust_min bust_max waist_min waist_max hip_min hip_max height_min height_max weight_min weight_max role
# what: extended traits vns changes
sub dbCharGet {
my $self = shift;
@@ -16,7 +17,7 @@ sub dbCharGet {
page => 1,
results => 10,
what => '',
- traitspoil => 0,
+ tagspoil => 0,
@_
);
@@ -29,15 +30,30 @@ sub dbCharGet {
$o{notid} ? ( 'c.id <> ?' => $o{notid} ) : (),
$o{instance} ? ( 'cr.main = ?' => $o{instance} ) : (),
$o{vid} ? ( 'cr.id IN(SELECT cid FROM chars_vns WHERE vid = ?)' => $o{vid} ) : (),
+ defined $o{gender} ? ( 'cr.gender IN(!l)' => [ ref $o{gender} ? $o{gender} : [$o{gender}] ]) : (),
+ defined $o{bloodt} ? ( 'cr.bloodt IN(!l)' => [ ref $o{bloodt} ? $o{bloodt} : [$o{bloodt}] ]) : (),
+ defined $o{bust_min} ? ( 'cr.s_bust >= ?' => $o{bust_min} ) : (),
+ defined $o{bust_max} ? ( 'cr.s_bust <= ? AND cr.s_bust > 0' => $o{bust_max} ) : (),
+ defined $o{waist_min} ? ( 'cr.s_waist >= ?' => $o{waist_min} ) : (),
+ defined $o{waist_max} ? ( 'cr.s_waist <= ? AND cr.s_waist > 0' => $o{waist_max} ) : (),
+ defined $o{hip_min} ? ( 'cr.s_hip >= ?' => $o{hip_min} ) : (),
+ defined $o{hip_max} ? ( 'cr.s_hip <= ? AND cr.s_hip > 0' => $o{hip_max} ) : (),
+ defined $o{height_min} ? ( 'cr.height >= ?' => $o{height_min} ) : (),
+ defined $o{height_max} ? ( 'cr.height <= ? AND cr.height > 0' => $o{height_max} ) : (),
+ defined $o{weight_min} ? ( 'cr.weight >= ?' => $o{weight_min} ) : (),
+ defined $o{weight_max} ? ( 'cr.weight <= ? AND cr.weight > 0' => $o{weight_max} ) : (),
$o{search} ? (
'(cr.name ILIKE ? OR cr.original ILIKE ? OR cr.alias ILIKE ?)', [ map '%%'.$o{search}.'%%', 1..3 ] ) : (),
$o{char} ? (
'LOWER(SUBSTR(cr.name, 1, 1)) = ?' => $o{char} ) : (),
defined $o{char} && !$o{char} ? (
'(ASCII(cr.name) < 97 OR ASCII(cr.name) > 122) AND (ASCII(cr.name) < 65 OR ASCII(cr.name) > 90)' => 1 ) : (),
+ $o{role} ? (
+ 'EXISTS(SELECT 1 FROM chars_vns cvi WHERE cvi.cid = cr.id AND cvi.role IN(!l))',
+ [ ref $o{role} ? $o{role} : [$o{role}] ] ) : (),
$o{trait_inc} ? (
'c.id IN(SELECT cid FROM traits_chars WHERE tid IN(!l) AND spoil <= ? GROUP BY cid HAVING COUNT(tid) = ?)',
- [ ref $o{trait_inc} ? $o{trait_inc} : [$o{trait_inc}], $o{traitspoil}, ref $o{trait_inc} ? $#{$o{trait_inc}}+1 : 1 ]) : (),
+ [ ref $o{trait_inc} ? $o{trait_inc} : [$o{trait_inc}], $o{tagspoil}, ref $o{trait_inc} ? $#{$o{trait_inc}}+1 : 1 ]) : (),
$o{trait_exc} ? (
'c.id NOT IN(SELECT cid FROM traits_chars WHERE tid IN(!l))' => [ ref $o{trait_exc} ? $o{trait_exc} : [$o{trait_exc}] ] ) : (),
);
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index 474066ce..473fa92c 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -11,7 +11,7 @@ our @EXPORT = qw|dbVNGet dbVNRevisionInsert dbVNImageId dbScreenshotAdd dbScreen
# Options: id, rev, char, search, length, lang, olang, plat, tag_inc, tag_exc, tagspoil,
-# hasani, hasshot, ul_notblack, ul_onwish, results, page, what, sort, reverse
+# hasani, hasshot, ul_notblack, ul_onwish, results, page, what, sort, reverse, inc_hidden
# What: extended anime relations screenshots relgraph rating ranking changes
# Sort: id rel pop rating title tagscore rand
sub dbVNGet {
@@ -66,7 +66,7 @@ sub dbVNGet {
$uid && defined $o{ul_onlist} ? (
'v.id !s IN(SELECT vid FROM vnlists WHERE uid = ?)' => [ $o{ul_onlist} ? '' : 'NOT', $uid ] ) : (),
# don't fetch hidden items unless we ask for an ID
- !$o{id} && !$o{rev} ? (
+ !$o{id} && !$o{rev} && !$o{inc_hidden} ? (
'v.hidden = FALSE' => 0 ) : (),
# optimize fetching random entries (only when there are no other filters present, otherwise this won't work well)
$o{sort} eq 'rand' && $o{results} <= 10 && !grep(!/^(?:results|page|what|sort|tagspoil)$/, keys %o) ? (
@@ -107,7 +107,7 @@ sub dbVNGet {
my $order = sprintf {
id => 'id %s',
- rel => 'c_released %s',
+ rel => 'c_released %s, title ASC',
pop => 'c_popularity %s NULLS LAST',
rating => 'c_rating %s NULLS LAST',
title => 'title %s',