Merge pull request #26 from Pear-Trading/finn/LeaderboardFix

Leaderboards corrected and fixes
This commit is contained in:
Finn 2017-08-14 16:11:10 +01:00 committed by GitHub
commit 89aac53c02
8 changed files with 28 additions and 27 deletions

View file

@ -201,10 +201,11 @@ sub startup {
while ( my $from_org_transaction = $from_org_transaction_rs->next ) {
$to_org->create_related(
'transactions', {
buyer_id => $from_org_transaction->buyer_id,
value => $from_org_transaction->value,
proof_image => $from_org_transaction->proof_image,
submitted_at => $from_org_transaction->submitted_at,
buyer_id => $from_org_transaction->buyer_id,
value => $from_org_transaction->value,
proof_image => $from_org_transaction->proof_image,
submitted_at => $from_org_transaction->submitted_at,
purchase_time => $from_org_transaction->purchase_time,
}
);
$from_org_transaction->delete;

View file

@ -73,7 +73,7 @@ sub run {
seller_id => $organisations[int(rand($#organisations))]->organisation_id,
value => int(rand(9999)) / 100,
proof_image => 'a',
submitted_at => $dtf->format_datetime($datetime->clone->add( minutes => int(rand(1440)) )),
purchase_time => $dtf->format_datetime($datetime->clone->add( minutes => int(rand(1440)) )),
});
}
}

View file

@ -12,7 +12,7 @@ sub search_between {
my $dtf = $self->result_source->schema->storage->datetime_parser;
return $self->search({
submitted_at => {
purchase_time => {
-between => [
$dtf->format_datetime($from),
$dtf->format_datetime($to),

View file

@ -73,7 +73,7 @@ for ( 11 .. 20 ) {
seller_id => $org_result->id,
value => $_,
proof_image => 'a',
submitted_at => $dtf->format_datetime(DateTime->today()->subtract( days => 5 )),
purchase_time => $dtf->format_datetime(DateTime->today()->subtract( days => 5 )),
});
}
@ -82,7 +82,7 @@ for ( 21 .. 30 ) {
seller_id => $org_result->id,
value => $_,
proof_image => 'a',
submitted_at => $dtf->format_datetime(DateTime->today()->subtract( days => 25 )),
purchase_time => $dtf->format_datetime(DateTime->today()->subtract( days => 25 )),
});
}
@ -91,7 +91,7 @@ for ( 31 .. 40 ) {
seller_id => $org_result->id,
value => $_,
proof_image => 'a',
submitted_at => $dtf->format_datetime(DateTime->today()->subtract( days => 50 )),
purchase_time => $dtf->format_datetime(DateTime->today()->subtract( days => 50 )),
});
}
@ -100,12 +100,12 @@ for ( 41 .. 50 ) {
seller_id => $org_result->id,
value => $_,
proof_image => 'a',
submitted_at => $dtf->format_datetime(DateTime->today()->subtract( days => 50 )),
purchase_time => $dtf->format_datetime(DateTime->today()->subtract( days => 50 )),
});
}
is $user_result->transactions->search({
submitted_at => {
purchase_time => {
-between => [
$dtf->format_datetime(DateTime->today()),
$dtf->format_datetime(DateTime->today()->add( days => 1 )),

View file

@ -87,7 +87,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 9,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -104,7 +104,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 1,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -121,7 +121,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 5,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -138,7 +138,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 3,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -154,7 +154,7 @@ sub test_leaderboard {
my $leaderboard_rs = $schema->resultset('Leaderboard');
$leaderboard_rs->create_new( $name, $date );
$t->post_ok('/api/stats/leaderboard' => json => { session_key => $session_key, type => $name } )
->status_is(200)
->or($framework->dump_error)

View file

@ -90,7 +90,7 @@ for my $user ( $user1, $user2, $user3, $user4 ) {
seller_id => $org_result->id,
value => $_ + $tweak,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 5 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 5 )),
});
}
@ -99,7 +99,7 @@ for my $user ( $user1, $user2, $user3, $user4 ) {
seller_id => $org_result->id,
value => $_ + $tweak,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 25 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 25 )),
});
}
@ -108,7 +108,7 @@ for my $user ( $user1, $user2, $user3, $user4 ) {
seller_id => $org_result->id,
value => $_ + $tweak,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 50 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 50 )),
});
}

View file

@ -87,7 +87,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 9,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -104,7 +104,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 1,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -121,7 +121,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 5,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}
@ -138,7 +138,7 @@ my $now = DateTime->today();
seller_id => $org_result->id,
value => 3,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 1 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 1 )),
});
}

View file

@ -90,7 +90,7 @@ for my $user ( $user1, $user2, $user3, $user4 ) {
seller_id => $org_result->id,
value => $_ + $tweak,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 5 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 5 )),
});
}
@ -99,7 +99,7 @@ for my $user ( $user1, $user2, $user3, $user4 ) {
seller_id => $org_result->id,
value => $_ + $tweak,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 25 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 25 )),
});
}
@ -108,7 +108,7 @@ for my $user ( $user1, $user2, $user3, $user4 ) {
seller_id => $org_result->id,
value => $_ + $tweak,
proof_image => 'a',
submitted_at => $dtf->format_datetime($now->clone->subtract( days => 50 )),
purchase_time => $dtf->format_datetime($now->clone->subtract( days => 50 )),
});
}
@ -122,7 +122,7 @@ sub test_leaderboard {
my $leaderboard_rs = $schema->resultset('Leaderboard');
$leaderboard_rs->create_new( $name, $date );
my $today_board = $leaderboard_rs->get_latest( $name );
is $today_board->values->count, 4, 'correct value count';