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

sartak at bestpractical.com sartak at bestpractical.com
Thu Jul 30 15:23:37 EDT 2009


The branch, master has been updated
       via  a400b459c4345efb1f331511535536269c88026a (commit)
       via  ff8b05ce77d111d35eb741ac90fc568697b0f544 (commit)
       via  69b73b10a12c1d72da4a3b54bab543819f040bec (commit)
      from  49fa6d6bb5fe1677117fb432974b5217889d59b5 (commit)

Summary of changes:
 lib/App/Changeloggr/Dispatcher.pm           |    6 ++++-
 lib/App/Changeloggr/Model/VoteCollection.pm |   17 ++++++++++++++
 lib/App/Changeloggr/View.pm                 |    3 ++
 lib/App/Changeloggr/View/Leaderboard.pm     |   32 +++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100644 lib/App/Changeloggr/View/Leaderboard.pm

- Log -----------------------------------------------------------------
commit 69b73b10a12c1d72da4a3b54bab543819f040bec
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Jul 30 15:22:56 2009 -0400

    Votes->group_by_voter

diff --git a/lib/App/Changeloggr/Model/VoteCollection.pm b/lib/App/Changeloggr/Model/VoteCollection.pm
index 745cf2e..4eeb042 100644
--- a/lib/App/Changeloggr/Model/VoteCollection.pm
+++ b/lib/App/Changeloggr/Model/VoteCollection.pm
@@ -15,5 +15,22 @@ sub limit_to_commented {
     return $self;
 }
 
+sub group_by_voter {
+    my $self = shift;
+
+    $self->columns('user_id');
+
+    $self->group_by(
+        column => 'user_id',
+    );
+
+    $self->order_by(
+        function => 'COUNT(*)',
+        order    => 'DESC',
+    );
+
+    return $self;
+}
+
 1;
 

commit ff8b05ce77d111d35eb741ac90fc568697b0f544
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Jul 30 15:23:13 2009 -0400

    First stab at leaderboard

diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index c8d494d..3ea29a2 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -10,6 +10,9 @@ alias App::Changeloggr::View::Admin under '/admin';
 require App::Changeloggr::View::Account;
 alias App::Changeloggr::View::Account under '/account';
 
+require App::Changeloggr::View::Leaderboard;
+alias App::Changeloggr::View::Leaderboard under '/leaderboard';
+
 require Jifty::Plugin::SiteNews::View::News;
 alias Jifty::Plugin::SiteNews::View::News under '/news';
 
diff --git a/lib/App/Changeloggr/View/Leaderboard.pm b/lib/App/Changeloggr/View/Leaderboard.pm
new file mode 100644
index 0000000..0f2a798
--- /dev/null
+++ b/lib/App/Changeloggr/View/Leaderboard.pm
@@ -0,0 +1,32 @@
+package App::Changeloggr::View::Leaderboard;
+use Jifty::View::Declare -base;
+use JiftyX::ModelHelpers;
+use strict;
+use warnings;
+
+template '/' => page {
+    my $votes = M('VoteCollection');
+    $votes->unlimit;
+    show_leaderboard($votes);
+};
+
+template '/changelog' => page {
+    my $changelog = Changelog(name => get('changelog'));
+    show_leaderboard($changelog->votes);
+};
+
+sub show_leaderboard {
+    my $votes = shift;
+
+    $votes->group_by_voter;
+    ol {
+        for (0 .. 25) {
+            my $vote = $votes->next
+                or last;
+            li { $vote->user->name || 'anonymous' }
+        }
+    }
+}
+
+1;
+

commit a400b459c4345efb1f331511535536269c88026a
Author: Shawn M Moore <sartak at gmail.com>
Date:   Thu Jul 30 15:23:25 2009 -0400

    Dispatcher rule for /changelog/Perl 5.11/leaderboard

diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index 4f83b07..9f3b7f9 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -50,12 +50,16 @@ on '/changelog/*/*/Changes' => run {
     show '/changelog/download';
 };
 
+on '/changelog/*/leaderboard' => run {
+    set changelog => $1;
+    show '/leaderboard/changelog';
+};
+
 on '/changelog/*/*' => run {
     set changelog => $1;
     show "/changelog/$2";
 };
 
-
 # match /admin/changelog/SUBTAB/UUID
 # or    /admin/changelog/UUID
 on qr{^/admin/changelog((?:/[^/]+)*)/([^/]+)$} => run {

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



More information about the Bps-public-commit mailing list