[Bps-public-commit] App-Changeloggr branch, master, updated. 0f18e75d1a9143bc71fa78ab3882983c72d7fbbe
sartak at bestpractical.com
sartak at bestpractical.com
Wed May 27 13:40:35 EDT 2009
The branch, master has been updated
via 0f18e75d1a9143bc71fa78ab3882983c72d7fbbe (commit)
via c048cca1ae6accffb06d0c33ee650e258b8bcece (commit)
from 5dc7a2df9c731dda3385cc1ed8fb7909c7f935d2 (commit)
Summary of changes:
lib/App/Changeloggr/Model/Change.pm | 25 +++++++++++++++++++++----
lib/App/Changeloggr/View.pm | 6 ++++--
2 files changed, 25 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit c048cca1ae6accffb06d0c33ee650e258b8bcece
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed May 27 13:32:13 2009 -0400
Don't reuse id directly for counting votes of a tag
diff --git a/lib/App/Changeloggr/Model/Change.pm b/lib/App/Changeloggr/Model/Change.pm
index dbc1b57..6432e29 100644
--- a/lib/App/Changeloggr/Model/Change.pm
+++ b/lib/App/Changeloggr/Model/Change.pm
@@ -141,10 +141,6 @@ sub prioritized_tags {
);
$tags->column(
- column => 'id',
- function => "count($votes.tag) + 1",
- );
- $tags->column(
column => 'text',
);
$tags->group_by(
@@ -158,5 +154,29 @@ sub prioritized_tags {
return $tags;
}
+sub count_of_tag {
+ my $self = shift;
+ my $tag = shift;
+
+ my $text = ref($tag) ? $tag->text : $tag;
+
+ my $tags = $self->changelog->tags;
+ $tags->limit(
+ column => 'text',
+ operator => '=',
+ value => $text,
+ );
+ $tags->column(
+ column => 'id',
+ function => 'count(main.text)',
+ );
+ $tags->order_by({});
+ $tags->group_by(
+ column => 'text',
+ );
+
+ return $tags->first->id;
+}
+
1;
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 4b24b24..a007240 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -241,11 +241,13 @@ sub show_vote_form {
my $voted_cusp = 0;
while (my $valid_tag = $valid_tags->next) {
my $label;
+ my $count = $change->count_of_tag($valid_tag);
+
# This is actually checking count+1, not id. It's count+1
# because id 0 (aka count 0) records are not loaded. :/
++$tag_number;
- if ($valid_tag->id - 1 > 0) {
- $label = _('%1 (%2)', $valid_tag->text, $valid_tag->id - 1);
+ if ($count > 0) {
+ $label = _('%1 (%2)', $valid_tag->text, $count);
}
else {
$label = $valid_tag->text;
commit 0f18e75d1a9143bc71fa78ab3882983c72d7fbbe
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed May 27 13:40:24 2009 -0400
group_by doesn't actually make sense here
diff --git a/lib/App/Changeloggr/Model/Change.pm b/lib/App/Changeloggr/Model/Change.pm
index 6432e29..523f631 100644
--- a/lib/App/Changeloggr/Model/Change.pm
+++ b/lib/App/Changeloggr/Model/Change.pm
@@ -171,9 +171,6 @@ sub count_of_tag {
function => 'count(main.text)',
);
$tags->order_by({});
- $tags->group_by(
- column => 'text',
- );
return $tags->first->id;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list