diff --git a/lib/Pear/LocalLoop/Schema/ResultSet/Transaction.pm b/lib/Pear/LocalLoop/Schema/ResultSet/Transaction.pm index 05d264d..822abf2 100644 --- a/lib/Pear/LocalLoop/Schema/ResultSet/Transaction.pm +++ b/lib/Pear/LocalLoop/Schema/ResultSet/Transaction.pm @@ -21,6 +21,15 @@ sub search_between { }); } +sub search_before { + my ( $self, $date ) = @_; + + my $dtf = $self->result_source->schema->storage->datetime_parser; + return $self->search({ + purchase_time => { '<' => $dtf->format_datetime( $date ) }, + }); +} + sub today_rs { my ( $self ) = @_; diff --git a/t/schema/leaderboard.t b/t/schema/leaderboard.t index 9f0e72f..5d09595 100644 --- a/t/schema/leaderboard.t +++ b/t/schema/leaderboard.t @@ -215,10 +215,10 @@ test_leaderboard( 'all_time_total', $now, [ - { user_id => 4, value => 980 }, - { user_id => 3, value => 940 }, - { user_id => 2, value => 900 }, - { user_id => 1, value => 860 }, + { user_id => 4, value => 885 }, + { user_id => 3, value => 855 }, + { user_id => 2, value => 825 }, + { user_id => 1, value => 795 }, ] ); @@ -227,10 +227,10 @@ test_leaderboard( 'all_time_count', $now, [ - { user_id => 1, value => 40 }, - { user_id => 2, value => 40 }, - { user_id => 3, value => 40 }, - { user_id => 4, value => 40 }, + { user_id => 1, value => 30 }, + { user_id => 2, value => 30 }, + { user_id => 3, value => 30 }, + { user_id => 4, value => 30 }, ] ); diff --git a/t/schema/resultset_leaderboard.t b/t/schema/resultset_leaderboard.t index 7245283..c1ab6b1 100644 --- a/t/schema/resultset_leaderboard.t +++ b/t/schema/resultset_leaderboard.t @@ -217,10 +217,10 @@ test_leaderboard( 'all_time_total', $now, [ - { user_id => 4, value => 980, position => 1 }, - { user_id => 3, value => 940, position => 2 }, - { user_id => 2, value => 900, position => 3 }, - { user_id => 1, value => 860, position => 4 }, + { user_id => 4, value => 885, position => 1 }, + { user_id => 3, value => 855, position => 2 }, + { user_id => 2, value => 825, position => 3 }, + { user_id => 1, value => 795, position => 4 }, ] ); @@ -229,10 +229,10 @@ test_leaderboard( 'all_time_count', $now, [ - { user_id => 1, value => 40, position => 1 }, - { user_id => 2, value => 40, position => 2 }, - { user_id => 3, value => 40, position => 3 }, - { user_id => 4, value => 40, position => 4 }, + { user_id => 1, value => 30, position => 1 }, + { user_id => 2, value => 30, position => 2 }, + { user_id => 3, value => 30, position => 3 }, + { user_id => 4, value => 30, position => 4 }, ] );