X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FIndex.pm;h=8bd8aba7f57871ab8e5c4ba7089c2357ff860d03;hp=2c93c7c55c93bd930d71828759558ca33fc608e3;hb=94f48b7b936c7958fa58a0d8dc5f3812ac1ce30d;hpb=a58f1ab4dd5b224b12ed78096b6867f47c316231 diff --git a/perl/Sesse/pr0n/Index.pm b/perl/Sesse/pr0n/Index.pm index 2c93c7c..8bd8aba 100644 --- a/perl/Sesse/pr0n/Index.pm +++ b/perl/Sesse/pr0n/Index.pm @@ -127,17 +127,16 @@ sub handler { if ($model eq '') { # no defined model - $where .= " AND id NOT IN ( SELECT image FROM exif_info WHERE key='Model' AND TRIM(value)<>'' )"; + $where .= " AND model IS NULL"; } else { - $where .= " AND id IN ( SELECT image FROM exif_info WHERE key='Model' AND TRIM(value)=$mq )"; + $where .= " AND model=$mq"; } - # This doesn't match 1:1 if there's both lens and lensspec, but it should be OK in practice if ($lens eq '') { # no defined lens - $where .= " AND id NOT IN ( SELECT image FROM exif_info WHERE (key='Lens' OR key='LensSpec') AND TRIM(value)<>'' )"; + $where .= " AND lens IS NULL"; } else { - $where .= " AND id IN ( SELECT image FROM exif_info WHERE (key='Lens' OR key='LensSpec') AND TRIM(value)=$lq )"; + $where .= " AND lens=$lq"; } } if (defined($author)) { @@ -199,7 +198,9 @@ sub handler { my @files = (); while (my $ref = $q->fetchrow_hashref()) { - push @files, [ $ref->{'event'}, $ref->{'filename'}, $ref->{'width'}, $ref->{'height'} ]; + my $width = defined($ref->{'width'}) ? $ref->{'width'} : -1; + my $height = defined($ref->{'height'}) ? $ref->{'height'} : -1; + push @files, [ $ref->{'event'}, $ref->{'filename'}, $width, $height ]; } for my $i (0..$#files) { @@ -250,15 +251,12 @@ sub handler { if (1 || $event ne '+all') { # Find the equipment used my $eq = $dbh->prepare(" - SELECT - TRIM(model.value) AS model, - coalesce(TRIM(lens_spec.value), TRIM(lens.value)) AS lens, + SELECT + model, + lens, COUNT(*) AS num - FROM ( SELECT * FROM images WHERE vhost=? $where ) i - LEFT JOIN exif_info model ON i.id=model.image - LEFT JOIN ( SELECT * FROM exif_info WHERE key='Lens' ) lens ON i.id=lens.image - LEFT JOIN ( SELECT * FROM exif_info WHERE key='LensSpec') lens_spec ON i.id=lens_spec.image - WHERE model.key='Model' + FROM images + WHERE vhost=? $where GROUP BY 1,2 ORDER BY 1,2") or die "Couldn't prepare to find equipment: $!"; @@ -366,7 +364,7 @@ sub handler { } } - if ($ref->{'width'} != -1 && $ref->{'height'} != -1) { + if (defined($ref->{'width'}) && defined($ref->{'height'})) { my $width = $ref->{'width'}; my $height = $ref->{'height'};