From d4f0d9ec6819c2b84289193021c74c9220d084ed Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 26 Mar 2007 22:11:59 +0200 Subject: [PATCH] Add a counter for how much each equipment combination is used. --- perl/Sesse/pr0n/Index.pm | 20 ++++++++++++------- templates/bilder.knatten.com/equipment-item | 1 + .../equipment-item-singular | 1 + templates/default/equipment-item | 1 + templates/default/equipment-item-singular | 1 + .../images.tg05.gathering.org/equipment-item | 1 + .../equipment-item-singular | 1 + .../skoyen.bilder.knatten.com/equipment-item | 1 + .../equipment-item-singular | 1 + .../equipment-item | 1 + .../equipment-item-singular | 1 + 11 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 templates/bilder.knatten.com/equipment-item create mode 100644 templates/bilder.knatten.com/equipment-item-singular create mode 100644 templates/default/equipment-item create mode 100644 templates/default/equipment-item-singular create mode 100644 templates/images.tg05.gathering.org/equipment-item create mode 100644 templates/images.tg05.gathering.org/equipment-item-singular create mode 100644 templates/skoyen.bilder.knatten.com/equipment-item create mode 100644 templates/skoyen.bilder.knatten.com/equipment-item-singular create mode 100644 templates/skoyen.bildereks.knatten.com/equipment-item create mode 100644 templates/skoyen.bildereks.knatten.com/equipment-item-singular diff --git a/perl/Sesse/pr0n/Index.pm b/perl/Sesse/pr0n/Index.pm index f8f4404..737eba6 100644 --- a/perl/Sesse/pr0n/Index.pm +++ b/perl/Sesse/pr0n/Index.pm @@ -155,14 +155,16 @@ sub handler { # Find the equipment used my $eq = $dbh->prepare(' - SELECT DISTINCT + SELECT model.value AS model, - coalesce(lens_spec.value, lens.value) AS lens + coalesce(lens_spec.value, lens.value) AS lens, + COUNT(*) AS num FROM images i LEFT JOIN exif_info model ON i.id=model.image LEFT JOIN ( SELECT * FROM exif_info WHERE tag=\'Lens\' ) lens ON i.id=lens.image LEFT JOIN ( SELECT * FROM exif_info WHERE tag=\'LensSpec\') lens_spec ON i.id=lens_spec.image WHERE event=? AND model.tag=\'Model\' + GROUP BY 1,2 ORDER BY 1,2') or die "Couldn't prepare to find equipment: $!"; $eq->execute($event) @@ -175,8 +177,9 @@ sub handler { # # Some compact cameras seem to add lens info sometimes and not at other # times; if we have seen a camera with at least one specific lens earlier, - # just ignore entries without a lens. + # just combine entries without a lens with the previous one. # + $equipment[$#equipment]->{'num'} += $ref->{'num'}; next; } push @equipment, $ref; @@ -187,11 +190,14 @@ sub handler { if (scalar @equipment > 0) { Sesse::pr0n::Templates::print_template($r, "equipment-start"); for my $e (@equipment) { - $r->print("
  • " . $e->{'model'}); - if (defined($e->{'lens'})) { - $r->print(", " . $e->{'lens'} . "
  • \n"); + my $eqspec = $e->{'model'}; + $eqspec .= ', ' . $e->{'lens'} if (defined($e->{'lens'})); + + # This isn't correct for all languages. Fix if we ever need to care. :-) + if ($e->{'num'} == 1) { + Sesse::pr0n::Templates::print_template($r, "equipment-item-singular", { eqspec => $eqspec }); } else { - $r->print("\n"); + Sesse::pr0n::Templates::print_template($r, "equipment-item", { eqspec => $eqspec, num => $e->{'num'} }); } } Sesse::pr0n::Templates::print_template($r, "equipment-end"); diff --git a/templates/bilder.knatten.com/equipment-item b/templates/bilder.knatten.com/equipment-item new file mode 100644 index 0000000..72ab8da --- /dev/null +++ b/templates/bilder.knatten.com/equipment-item @@ -0,0 +1 @@ +
  • %EQSPEC% (%NUM% bilder)
  • diff --git a/templates/bilder.knatten.com/equipment-item-singular b/templates/bilder.knatten.com/equipment-item-singular new file mode 100644 index 0000000..51e6465 --- /dev/null +++ b/templates/bilder.knatten.com/equipment-item-singular @@ -0,0 +1 @@ +
  • %EQSPEC% (ett bilde)
  • diff --git a/templates/default/equipment-item b/templates/default/equipment-item new file mode 100644 index 0000000..0e7e86d --- /dev/null +++ b/templates/default/equipment-item @@ -0,0 +1 @@ +
  • %EQSPEC% (%NUM% images)
  • diff --git a/templates/default/equipment-item-singular b/templates/default/equipment-item-singular new file mode 100644 index 0000000..b55a163 --- /dev/null +++ b/templates/default/equipment-item-singular @@ -0,0 +1 @@ +
  • %EQSPEC% (one image)
  • diff --git a/templates/images.tg05.gathering.org/equipment-item b/templates/images.tg05.gathering.org/equipment-item new file mode 100644 index 0000000..0e7e86d --- /dev/null +++ b/templates/images.tg05.gathering.org/equipment-item @@ -0,0 +1 @@ +
  • %EQSPEC% (%NUM% images)
  • diff --git a/templates/images.tg05.gathering.org/equipment-item-singular b/templates/images.tg05.gathering.org/equipment-item-singular new file mode 100644 index 0000000..b55a163 --- /dev/null +++ b/templates/images.tg05.gathering.org/equipment-item-singular @@ -0,0 +1 @@ +
  • %EQSPEC% (one image)
  • diff --git a/templates/skoyen.bilder.knatten.com/equipment-item b/templates/skoyen.bilder.knatten.com/equipment-item new file mode 100644 index 0000000..72ab8da --- /dev/null +++ b/templates/skoyen.bilder.knatten.com/equipment-item @@ -0,0 +1 @@ +
  • %EQSPEC% (%NUM% bilder)
  • diff --git a/templates/skoyen.bilder.knatten.com/equipment-item-singular b/templates/skoyen.bilder.knatten.com/equipment-item-singular new file mode 100644 index 0000000..51e6465 --- /dev/null +++ b/templates/skoyen.bilder.knatten.com/equipment-item-singular @@ -0,0 +1 @@ +
  • %EQSPEC% (ett bilde)
  • diff --git a/templates/skoyen.bildereks.knatten.com/equipment-item b/templates/skoyen.bildereks.knatten.com/equipment-item new file mode 100644 index 0000000..72ab8da --- /dev/null +++ b/templates/skoyen.bildereks.knatten.com/equipment-item @@ -0,0 +1 @@ +
  • %EQSPEC% (%NUM% bilder)
  • diff --git a/templates/skoyen.bildereks.knatten.com/equipment-item-singular b/templates/skoyen.bildereks.knatten.com/equipment-item-singular new file mode 100644 index 0000000..51e6465 --- /dev/null +++ b/templates/skoyen.bildereks.knatten.com/equipment-item-singular @@ -0,0 +1 @@ +
  • %EQSPEC% (ett bilde)
  • -- 2.39.2