summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-11-11 14:45:22 +0100
committerYorhel <git@yorhel.nl>2010-11-11 14:45:22 +0100
commit2a7236184180f24169d454396b482d923beb21b5 (patch)
treecb00efb8c2b31d00c6355e7c3cb81af42a83f86a /lib
parent076408b17bc231dfab30125f2e445cd54f5227b8 (diff)
Display releases grouped by VNs on producer pages
A nice expanded view. It also happens to be faster than the old view in terms of SQL queries. (In most cases at least) Can be improved a little more by: - Adding an 'expand/collapse' feature to list only the VNs - Adding a column indicating the role of the producer (dev/pub)
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Producers.pm26
-rw-r--r--lib/VNDB/DB/Releases.pm6
-rw-r--r--lib/VNDB/Handler/Producers.pm80
3 files changed, 67 insertions, 45 deletions
diff --git a/lib/VNDB/DB/Producers.pm b/lib/VNDB/DB/Producers.pm
index 5ec387cf..ad6f22b2 100644
--- a/lib/VNDB/DB/Producers.pm
+++ b/lib/VNDB/DB/Producers.pm
@@ -9,7 +9,7 @@ our @EXPORT = qw|dbProducerGet dbProducerRevisionInsert|;
# options: results, page, id, search, char, rev
-# what: extended changes vn relations relgraph
+# what: extended changes relations relgraph
sub dbProducerGet {
my $self = shift;
my %o = (
@@ -56,30 +56,6 @@ sub dbProducerGet {
$select, join(' ', @join), \%where,
);
- if(@$r && $o{what} =~ /vn/) {
- my %r = map {
- $r->[$_]{vn} = [];
- ($r->[$_]{id}, $_)
- } 0..$#$r;
-
- push @{$r->[$r{$_->{pid}}]{vn}}, $_ for (@{$self->dbAll(q|
- SELECT MAX(vp.pid) AS pid, v.id, MAX(vr.title) AS title, MAX(vr.original) AS original, MIN(rr.released) AS date,
- MAX(CASE WHEN vp.developer = true THEN 1 ELSE 0 END) AS developer, MAX(CASE WHEN vp.publisher = true THEN 1 ELSE 0 END) AS publisher
- FROM releases_producers vp
- JOIN releases_rev rr ON rr.id = vp.rid
- JOIN releases r ON r.latest = rr.id
- JOIN releases_vn rv ON rv.rid = rr.id
- JOIN vn v ON v.id = rv.vid
- JOIN vn_rev vr ON vr.id = v.latest
- WHERE vp.pid IN(!l)
- AND v.hidden = FALSE
- AND r.hidden = FALSE
- GROUP BY v.id
- ORDER BY date|,
- [ keys %r ]
- )});
- }
-
if(@$r && $o{what} =~ /relations/) {
my %r = map {
$r->[$_]{relations} = [];
diff --git a/lib/VNDB/DB/Releases.pm b/lib/VNDB/DB/Releases.pm
index cb8ad006..466a7ab4 100644
--- a/lib/VNDB/DB/Releases.pm
+++ b/lib/VNDB/DB/Releases.pm
@@ -10,7 +10,7 @@ use VNDB::Func 'gtintype';
our @EXPORT = qw|dbReleaseGet dbReleaseRevisionInsert|;
-# Options: id vid rev unreleased page results what date media sort reverse
+# Options: id vid pid rev unreleased page results what date media sort reverse
# platforms languages type minage search resolutions freeware doujin
# What: extended changes vn producers platforms media
# Sort: title released minage
@@ -25,6 +25,7 @@ sub dbReleaseGet {
$o{id} ? ( 'r.id = ?' => $o{id} ) : (),
$o{rev} ? ( 'c.rev = ?' => $o{rev} ) : (),
$o{vid} ? ( 'rv.vid = ?' => $o{vid} ) : (),
+ $o{pid} ? ( 'rp.pid = ?' => $o{pid} ) : (),
$o{patch} ? ( 'rr.patch = ?' => $o{patch} == 1 ? 1 : 0) : (),
$o{freeware} ? ( 'rr.freeware = ?' => $o{freeware} == 1 ? 1 : 0) : (),
$o{doujin} ? ( 'rr.doujin = ?' => $o{doujin} == 1 ? 1 : 0) : (),
@@ -61,8 +62,9 @@ sub dbReleaseGet {
}
my @join = (
- $o{rev} ? 'JOIN releases r ON r.id = rr.rid' : 'JOIN releases r ON rr.id = r.latest',
+ $o{rev} ? 'JOIN releases r ON r.id = rr.rid' : 'JOIN releases r ON rr.id = r.latest AND rr.rid = r.id',
$o{vid} ? 'JOIN releases_vn rv ON rv.rid = rr.id' : (),
+ $o{pid} ? 'JOIN releases_producers rp ON rp.rid = rr.id' : (),
$o{what} =~ /changes/ || $o{rev} ? (
'JOIN changes c ON c.id = rr.id',
'JOIN users u ON u.id = c.requester'
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index e6ccdffb..12485629 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -45,7 +45,7 @@ sub page {
my $p = $self->dbProducerGet(
id => $pid,
- what => 'vn extended relations'.($rev ? ' changes' : ''),
+ what => 'extended relations'.($rev ? ' changes' : ''),
$rev ? ( rev => $rev ) : ()
)->[0];
return 404 if !$p->{id};
@@ -76,7 +76,7 @@ sub page {
);
}
- div class => 'mainbox producerpage';
+ div class => 'mainbox';
$self->htmlItemMessage('p', $p);
h1 $p->{name};
h2 class => 'alttitle', $p->{original} if $p->{original};
@@ -117,28 +117,72 @@ sub page {
lit bb2html $p->{desc};
end;
}
-
end;
- div class => 'mainbox producerpage';
- h1 mt '_prodpage_vnrel';
- if(!@{$p->{vn}}) {
+
+ _releases($self, $p);
+
+ $self->htmlFooter;
+}
+
+sub _releases {
+ my($self, $p) = @_;
+
+ # prodpage_(dev|pub)
+ my $r = $self->dbReleaseGet(pid => $p->{id}, results => 999, what => 'vn platforms');
+ div class => 'mainbox prodrel';
+ h1 mt '_prodpage_rel';
+ if(!@$r) {
p mt '_prodpage_norel';
- } else {
- ul;
- for (@{$p->{vn}}) {
- li;
- i;
- lit $self->{l10n}->datestr($_->{date});
+ end;
+ return;
+ }
+
+ my %vn; # key = vid, value = [ $r1, $r2, $r3, .. ]
+ my @vn; # $vn objects in order of first release
+ for my $rel (@$r) {
+ for my $v (@{$rel->{vn}}) {
+ push @vn, $v if !$vn{$v->{vid}};
+ push @{$vn{$v->{vid}}}, $rel;
+ }
+ }
+
+ table;
+ for my $v (@vn) {
+ Tr class => 'vn';
+ td colspan => 5;
+ a href => "/v$v->{vid}", title => $v->{original}, $v->{title};
+ end;
+ end;
+ for my $rel (@{$vn{$v->{vid}}}) {
+ Tr;
+ td class => 'tc1'; lit $self->{l10n}->datestr($rel->{released}); end;
+ td class => 'tc2', !defined($rel->{minage}) ? '' : minage $rel->{minage};
+ td class => 'tc3';
+ for (sort @{$rel->{platforms}}) {
+ next if $_ eq 'oth';
+ cssicon $_, mt "_plat_$_";
+ }
+ cssicon "lang $_", mt "_lang_$_" for (@{$rel->{languages}});
+ cssicon "rt$rel->{type}", mt "_rtype_$rel->{type}";
+ end;
+ td class => 'tc4';
+ a href => "/r$rel->{id}", title => $rel->{original}||$rel->{title}, $rel->{title};
+ b class => 'grayedout', ' '.mt '_vnpage_rel_patch' if $rel->{patch};
+ end;
+ td class => 'tc5';
+ if($rel->{website}) {
+ a href => $rel->{website}, rel => 'nofollow';
+ cssicon 'ext', mt '_vnpage_rel_extlink';
+ end;
+ } else {
+ txt ' ';
+ }
end;
- a href => "/v$_->{id}", title => $_->{original}, $_->{title};
- b class => 'grayedout', ' ('.join(', ',
- $_->{developer} ? mt '_prodpage_dev' : (), $_->{publisher} ? mt '_prodpage_pub' : ()).')';
end;
}
- end;
- }
+ }
+ end;
end;
- $self->htmlFooter;
}