Skip to content

Commit

Permalink
renamed from numSolved to score
Browse files Browse the repository at this point in the history
  • Loading branch information
AyadLaouissi committed Mar 6, 2024
1 parent f975d55 commit 1ef3e74
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LeaderboardPlayer extends Equatable {
const LeaderboardPlayer({
required this.id,
required this.initials,
required this.numSolved,
required this.score,
});

/// {@macro leaderboard_player}
Expand All @@ -26,7 +26,7 @@ class LeaderboardPlayer extends Equatable {

/// Number of crosswords solved.
@JsonKey()
final int numSolved;
final int score;

/// Initials of the player.
@JsonKey()
Expand All @@ -36,5 +36,5 @@ class LeaderboardPlayer extends Equatable {
Map<String, dynamic> toJson() => _$LeaderboardPlayerToJson(this);

@override
List<Object?> get props => [id, numSolved, initials];
List<Object?> get props => [id, score, initials];
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LeaderboardRepository {
///
/// The players are ordered by longest streak and returns the top 10.
Future<List<LeaderboardPlayer>> getLeaderboard() async {
final results = await _dbClient.orderBy('leaderboard', 'numSolved');
final results = await _dbClient.orderBy('leaderboard', 'score');

return results
.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ void main() {
const playerOne = LeaderboardPlayer(
id: 'id',
initials: 'AAA',
numSolved: 20,
score: 20,
);
const playerTwo = LeaderboardPlayer(
id: 'id2',
initials: 'BBB',
numSolved: 10,
score: 10,
);

when(() => dbClient.orderBy('leaderboard', 'numSolved'))
when(() => dbClient.orderBy('leaderboard', 'score'))
.thenAnswer((_) async {
return [
DbEntityRecord(
id: 'id',
data: {
'initials': playerOne.initials,
'numSolved': 20,
'score': 20,
},
),
DbEntityRecord(
id: 'id2',
data: {
'initials': playerTwo.initials,
'numSolved': 10,
'score': 10,
},
),
];
Expand All @@ -71,7 +71,7 @@ void main() {
});

test('returns empty list if results are empty', () async {
when(() => dbClient.orderBy('leaderboard', 'numSolved'))
when(() => dbClient.orderBy('leaderboard', 'score'))
.thenAnswer((_) async {
return [];
});
Expand All @@ -86,7 +86,7 @@ void main() {
final leaderboardPlayer = LeaderboardPlayer(
id: 'id',
initials: 'initials',
numSolved: 40,
score: 40,
);

when(() => dbClient.add('leaderboard', leaderboardPlayer.toJson()))
Expand Down

0 comments on commit 1ef3e74

Please sign in to comment.