[Bps-public-commit] App-Changeloggr branch, master, updated. 7d87856bac4ee4bd6127f926862575c97ad0e9a7

sartak at bestpractical.com sartak at bestpractical.com
Fri May 22 18:18:42 EDT 2009


The branch, master has been updated
       via  7d87856bac4ee4bd6127f926862575c97ad0e9a7 (commit)
      from  16f1735309f864f755aaf9e41daf3233c0b32925 (commit)

Summary of changes:
 lib/App/Changeloggr/Model/Change.pm |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 7d87856bac4ee4bd6127f926862575c97ad0e9a7
Author: Shawn M Moore <sartak at gmail.com>
Date:   Fri May 22 18:18:29 2009 -0400

    First stab at ordering a change's tags based on vote frequency

diff --git a/lib/App/Changeloggr/Model/Change.pm b/lib/App/Changeloggr/Model/Change.pm
index 9609ec8..1628b97 100644
--- a/lib/App/Changeloggr/Model/Change.pm
+++ b/lib/App/Changeloggr/Model/Change.pm
@@ -120,9 +120,38 @@ sub numeric_importance {
     return $numeric_importance;
 }
 
+# This will order the tags for this change by the frequency that people have
+# voted on this change with each tag. If ten people vote a tag "documentation"
+# then that will show up before a tag "performance" that one joker voted.
 sub prioritized_tags {
     my $self = shift;
-    return $self->changelog->visible_tags;
+    my $tags = $self->changelog->visible_tags;
+
+    my $votes = $tags->join(
+        type        => 'left',
+        column1     => 'text',
+        table2      => 'votes',
+        column2     => 'tag',
+        is_distinct => 1,
+    );
+    $tags->limit(
+        leftjoin => $votes,
+        column   => 'change_id',
+        value    => $self->id,
+    );
+
+    $tags->column(
+        column => 'text',
+    );
+    $tags->group_by(
+        column => 'text',
+    );
+    $tags->order_by(
+        function => 'count(main.text)',
+        order    => 'DESC',
+    );
+
+    return $tags;
 }
 
 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list