Skip to content

Commit

Permalink
Places: Also order by last used as a tie-breaker
Browse files Browse the repository at this point in the history
  • Loading branch information
Inky-developer committed Dec 1, 2024
1 parent 49253c2 commit bec2e85
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.Flow

@Dao
interface PlaceDao {
@Query("SELECT Place.*, COUNT(Activity.place_id) as count FROM Place LEFT JOIN Activity ON Place.uid = Activity.place_id GROUP BY place.uid ORDER BY count DESC")
@Query("SELECT Place.*, COUNT(Activity.place_id) as count, MAX(Activity.start_time) AS last_used FROM Place LEFT JOIN Activity ON Place.uid = Activity.place_id GROUP BY place.uid ORDER BY count DESC, last_used DESC ")
fun getAll(): Flow<List<Place>>

@Query("SELECT place_id, COUNT(*) AS count FROM Activity WHERE place_id IS NOT NULL GROUP BY place_id")
Expand Down

0 comments on commit bec2e85

Please sign in to comment.