fix: sort scores in descending order (#100)

pull/104/head
Allison Ryan 4 years ago committed by GitHub
parent de963cbc86
commit e6eacfa9e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -91,7 +91,7 @@ class LeaderboardRepository {
try {
final querySnapshot = await _firebaseFirestore
.collection('leaderboard')
.orderBy('score')
.orderBy('score', descending: true)
.limit(10)
.get();
documents = querySnapshot.docs;
@ -130,7 +130,7 @@ class LeaderboardRepository {
try {
final querySnapshot = await _firebaseFirestore
.collection('leaderboard')
.orderBy('score')
.orderBy('score', descending: true)
.get();
// TODO(allisonryan0002): see if we can find a more performant solution.

@ -82,7 +82,7 @@ void main() {
when(() => firestore.collection('leaderboard'))
.thenAnswer((_) => collectionReference);
when(() => collectionReference.orderBy('score'))
when(() => collectionReference.orderBy('score', descending: true))
.thenAnswer((_) => query);
when(() => query.limit(10)).thenAnswer((_) => query);
when(query.get).thenAnswer((_) async => querySnapshot);
@ -173,7 +173,7 @@ void main() {
.thenAnswer((_) => collectionReference);
when(() => collectionReference.add(any()))
.thenAnswer((_) async => documentReference);
when(() => collectionReference.orderBy('score'))
when(() => collectionReference.orderBy('score', descending: true))
.thenAnswer((_) => query);
when(query.get).thenAnswer((_) async => querySnapshot);
when(() => querySnapshot.docs).thenReturn(queryDocumentSnapshots);
@ -203,7 +203,8 @@ void main() {
test(
'throws FetchPlayerRankingException when Exception occurs '
'when trying to retrieve information from firestore', () async {
when(() => collectionReference.orderBy('score')).thenThrow(Exception());
when(() => collectionReference.orderBy('score', descending: true))
.thenThrow(Exception());
expect(
() => leaderboardRepository.addLeaderboardEntry(leaderboardEntry),

Loading…
Cancel
Save