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

Alex M Vandiver alexmv at bestpractical.com
Tue Aug 4 12:59:21 EDT 2009


The branch, master has been updated
       via  d8f521ca8d1c5ba62b7e7c355e90869c79772011 (commit)
      from  7ca43f2789f9ddd2714bef8df6eeffc48df5dee4 (commit)

Summary of changes:
 lib/App/Changeloggr/CurrentUser.pm     |    3 ++-
 lib/App/Changeloggr/Model/Changelog.pm |    4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit d8f521ca8d1c5ba62b7e7c355e90869c79772011
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Aug 4 12:59:18 2009 -0400

    Fixes for starting position in empty changelog

diff --git a/lib/App/Changeloggr/CurrentUser.pm b/lib/App/Changeloggr/CurrentUser.pm
index 430cae7..119c82f 100644
--- a/lib/App/Changeloggr/CurrentUser.pm
+++ b/lib/App/Changeloggr/CurrentUser.pm
@@ -23,7 +23,8 @@ sub position_for {
     my $position = $session->get($key);
     if (!defined($position)) {
         $position = $changelog->get_starting_position;
-        $self->set_position_for($changelog, $position);
+        # Don't set if we have no changes
+        $self->set_position_for($changelog, $position) if defined $position;
     }
 
     return $position;
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index c73c7fa..5eaa227 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -196,7 +196,8 @@ sub get_starting_position {
         function => 'random()',
     });
 
-    return $changes->first->id;
+    # No valid changes
+    return $changes->first ? $changes->first->id : undef;
 }
 
 sub choose_change {
@@ -208,6 +209,7 @@ sub choose_change {
     my $changes = $self->unvoted_changes;
 
     my $start = $self->current_user->position_for($self);
+    return undef unless defined $start; # No valid changes, bail
     if ($start) {
         $changes->limit(
             column   => 'id',

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



More information about the Bps-public-commit mailing list