summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-09-26 14:25:29 +0200
committerYorhel <git@yorhel.nl>2021-09-26 14:25:29 +0200
commite26586a24450b13763df85d31c6e1cd801b3b1bf (patch)
tree9ee8aa77cfd6b5971d6bccafe8f946292a3ef110 /lib
parent381a3932bbeb4e8f4fa2f2f0715a83ae69713ae5 (diff)
AdvSearch: Prefer vote median in VN length filter if known
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Types.pm12
-rw-r--r--lib/VNWeb/AdvSearch.pm3
-rw-r--r--lib/VNWeb/VN/Page.pm6
3 files changed, 9 insertions, 12 deletions
diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm
index 8b4ae92a..e13f8e33 100644
--- a/lib/VNDB/Types.pm
+++ b/lib/VNDB/Types.pm
@@ -167,12 +167,12 @@ hash CREDIT_TYPE =>
hash VN_LENGTH =>
- 0 => { txt => 'Unknown', time => '' },
- 1 => { txt => 'Very short', time => '< 2 hours' },
- 2 => { txt => 'Short', time => '2 - 10 hours' },
- 3 => { txt => 'Medium', time => '10 - 30 hours' },
- 4 => { txt => 'Long', time => '30 - 50 hours' },
- 5 => { txt => 'Very long', time => '> 50 hours' };
+ 0 => { txt => 'Unknown', time => '', low => 0, high => 0 },
+ 1 => { txt => 'Very short', time => '< 2 hours', low => 1, high => 2*60 },
+ 2 => { txt => 'Short', time => '2 - 10 hours', low => 2*60, high => 10*60 },
+ 3 => { txt => 'Medium', time => '10 - 30 hours', low => 10*60, high => 30*60 },
+ 4 => { txt => 'Long', time => '30 - 50 hours', low => 30*60, high => 50*60 },
+ 5 => { txt => 'Very long', time => '> 50 hours', low => 50*60, high => 32767 };
diff --git a/lib/VNWeb/AdvSearch.pm b/lib/VNWeb/AdvSearch.pm
index 82030ffd..5cc769dd 100644
--- a/lib/VNWeb/AdvSearch.pm
+++ b/lib/VNWeb/AdvSearch.pm
@@ -312,7 +312,8 @@ f v => 2 => 'lang', { enum => \%LANGUAGE }, '=' => sub { sql 'v.c_language
f v => 3 => 'olang', { enum => \%LANGUAGE }, '=' => sub { sql 'v.olang =', \$_ };
f v => 4 => 'platform', { enum => \%PLATFORM }, '=' => sub { sql 'v.c_platforms && ARRAY', \$_, '::platform[]' };
f v => 6 => 'developer-id',{ vndbid => 'p' }, '=' => sub { sql 'v.c_developers && ARRAY', \$_, '::vndbid[]' };
-f v => 5 => 'length', { uint => 1, enum => \%VN_LENGTH }, '=' => sub { sql 'v.length =', \$_ };
+f v => 5 => 'length', { uint => 1, enum => \%VN_LENGTH },
+ '=' => sub { sql 'COALESCE(v.c_length BETWEEN', \$VN_LENGTH{$_}{low}, 'AND', \$VN_LENGTH{$_}{high}, ', v.length =', \$_, ')' };
f v => 7 => 'released', { fuzzyrdate => 1 }, sql => sub { sql 'v.c_released', $_[0], \($_ == 1 ? strftime('%Y%m%d', gmtime) : $_) };
f v => 9 => 'popularity',{ uint => 1, range => [ 0, 100] }, sql => sub { sql 'v.c_popularity', $_[0], \($_*100) };
f v => 10 => 'rating', { uint => 1, range => [10, 100] }, sql => sub { sql 'v.c_rating', $_[0], \($_*10) };
diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm
index 31a49c6c..4cf3c659 100644
--- a/lib/VNWeb/VN/Page.pm
+++ b/lib/VNWeb/VN/Page.pm
@@ -169,11 +169,7 @@ sub infobox_length_ {
td_ sub {
if($v->{c_lengthnum}) {
my $m = $v->{c_length};
- my $len = $m < 2*60 ? 1
- : $m < 10*60 ? 2
- : $m < 30*60 ? 3
- : $m < 50*60 ? 4 : 5;
- txt_ $VN_LENGTH{$len}{txt}.' (';
+ txt_ +(grep $m >= $_->{low} && $m < $_->{high}, values %VN_LENGTH)[0]{txt}.' (';
vnlength_ $m;
txt_ ' from ';
a_ href => "/$v->{id}/lengthvotes", sprintf '%d vote%s', $v->{c_lengthnum}, $v->{c_length}==1?'':'s';