File tree Expand file tree Collapse file tree
apps/flipcash/shared/persistence/db/src/main/kotlin/com/flipcash/app/persistence/dao Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,17 +77,23 @@ interface PoolDao {
7777 @Query(" SELECT * FROM pool_metadata ORDER BY timestamp DESC" )
7878 suspend fun getAll (): List <PoolWithBetsEntity >
7979
80- @Query(" SELECT * FROM pool_metadata ORDER BY isOpen DESC, timestamp DESC" )
80+ @Query(
81+ """
82+ SELECT * FROM pool_metadata
83+ ORDER BY isOpen DESC,
84+ CASE WHEN isOpen THEN timestamp ELSE closedTimestamp END DESC
85+ """
86+ )
8187 fun observePools (): PagingSource <Int , PoolEntity >
8288
83- @Query(" SELECT * FROM pool_metadata WHERE idBase58 = :id ORDER BY timestamp DESC " )
89+ @Query(" SELECT * FROM pool_metadata WHERE idBase58 = :id" )
8490 fun observe (id : String ): Flow <PoolWithBetsEntity ?>
8591 fun observe (id : ID ): Flow <PoolWithBetsEntity ?> {
8692 return observe(id.base58)
8793 }
8894
8995 @Transaction
90- @Query(" SELECT * FROM pool_metadata WHERE idBase58 = :id ORDER BY timestamp DESC " )
96+ @Query(" SELECT * FROM pool_metadata WHERE idBase58 = :id" )
9197 suspend fun getPoolWithBets (id : String ): PoolWithBetsEntity ?
9298 suspend fun getPoolWithBets (id : ID ): PoolWithBetsEntity ? {
9399 return getPoolWithBets(id.base58)
You can’t perform that action at this time.
0 commit comments