Skip to content

Commit b2a8abb

Browse files
committed
Update query for top visited articles
1 parent 3fec482 commit b2a8abb

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

app/src/main/java/org/wikipedia/history/db/HistoryEntryDao.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ interface HistoryEntryDao {
3030
@Query("SELECT COUNT(*) FROM (SELECT DISTINCT HistoryEntry.lang, HistoryEntry.apiTitle FROM HistoryEntry WHERE timestamp > :timestamp)")
3131
suspend fun getDistinctEntriesCountSince(timestamp: Long): Int?
3232

33-
@Query("SELECT DISTINCT displayTitle FROM HistoryEntry ORDER BY timestamp DESC LIMIT :limit")
34-
suspend fun getLatestArticleTitles(limit: Int): List<String>
33+
@Query("SELECT displayTitle FROM HistoryEntry WHERE timestamp > :timestamp GROUP BY displayTitle ORDER BY COUNT(displayTitle) DESC LIMIT :limit")
34+
suspend fun getTopVisitedEntriesSince(limit: Int, timestamp: Long): List<String>
3535

3636
@Query("SELECT COUNT(*) FROM HistoryEntry")
3737
suspend fun getHistoryCount(): Int

app/src/main/java/org/wikipedia/yearinreview/YearInReviewViewModel.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,14 @@ class YearInReviewViewModel() : ViewModel() {
6666
}
6767

6868
val topVisitedArticlesForTheYear = async {
69-
// TODO: update the query
70-
AppDatabase.instance.historyEntryDao().getLatestArticleTitles(MINIMUM_READ_COUNT)
69+
AppDatabase.instance.historyEntryDao().getTopVisitedEntriesSince(MINIMUM_READ_COUNT, yearAgo)
7170
.map { StringUtil.fromHtml(it).toString() }
7271
}
7372

7473
val totalTimeSpent = async {
7574
AppDatabase.instance.historyEntryWithImageDao().getTimeSpentSinceTimeStamp(yearAgo)
7675
}
7776

78-
// TODO: think about the actual data to show.
79-
8077
val impactDataJob = async {
8178
if (AccountUtil.isLoggedIn) {
8279
val wikiSite = WikipediaApp.instance.wikiSite

0 commit comments

Comments
 (0)