[Bps-public-commit] App-Changeloggr branch, master, updated. c1f25d874dc13334a207a99c35e73046df749684
sartak at bestpractical.com
sartak at bestpractical.com
Wed Jul 29 14:40:44 EDT 2009
The branch, master has been updated
via c1f25d874dc13334a207a99c35e73046df749684 (commit)
via 1c0a48066affac9911d9f060b4663511c637fc29 (commit)
from 9671c372661bd58d6ecdb0476d0cd4a75cb144b2 (commit)
Summary of changes:
lib/App/Changeloggr/Model/Changelog.pm | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit 1c0a48066affac9911d9f060b4663511c637fc29
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Jul 29 14:39:54 2009 -0400
Changelog->get_starting_position
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index dfe21dc..4d1ebb3 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -159,6 +159,17 @@ sub unvoted_changes {
return $changes;
}
+sub get_starting_position {
+ my $self = shift;
+
+ my $changes = M('ChangeCollection', changelog_id => $self);
+ $changes->order_by({
+ function => 'random()',
+ });
+
+ return $changes->first->id;
+}
+
sub choose_change {
my $self = shift;
commit c1f25d874dc13334a207a99c35e73046df749684
Author: Shawn M Moore <sartak at gmail.com>
Date: Wed Jul 29 14:40:24 2009 -0400
Limit changes to be >= the starting position
But wrap around if there are no changes left
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 4d1ebb3..b055c59 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -156,6 +156,21 @@ sub unvoted_changes {
operator => 'IS',
value => 'NULL',
);
+
+ my $start = $self->current_user->position_for($self);
+ if ($start) {
+ $changes->limit(
+ column => 'id',
+ operator => '>=',
+ value => $start,
+ );
+ }
+
+ if ($changes->count == 0 && $start > 0) {
+ $self->current_user->set_position_for($self, 0);
+ return $self->unvoted_changes(@_);
+ }
+
return $changes;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list