Skip to content

Commit

Permalink
Merge pull request #107 from Meesho/fix-transactions-orderby
Browse files Browse the repository at this point in the history
Fetch transactions with requestDate newest to oldest
  • Loading branch information
vibin authored Apr 8, 2024
2 parents 05fa5e7 + cb849dc commit 171e197
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public object Chucker {

public suspend fun generateHar(context: Context, transactionsLimit: Int = 1000): ByteArray {
val transactions: List<HttpTransaction> =
RepositoryProvider.transaction().getTransactions(transactionsLimit)
RepositoryProvider.transaction().getLastTransactions(transactionsLimit)
val sharable = TransactionDetailsHarSharable(
content = HarUtils.harStringFromTransactions(
transactions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ internal class HttpTransactionDatabaseRepository(private val database: ChuckerDa

override suspend fun getAllTransactions(): List<HttpTransaction> = transactionDao.getAll()

override suspend fun getTransactions(limit: Int): List<HttpTransaction> = transactionDao.getN(limit)
override suspend fun getLastTransactions(limit: Int): List<HttpTransaction> = transactionDao.getLastN(limit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ internal interface HttpTransactionRepository {

suspend fun getAllTransactions(): List<HttpTransaction>

suspend fun getTransactions(limit: Int): List<HttpTransaction>
suspend fun getLastTransactions(limit: Int): List<HttpTransaction>
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ internal interface HttpTransactionDao {
@Query("SELECT * FROM transactions")
suspend fun getAll(): List<HttpTransaction>

@Query("SELECT * FROM transactions LIMIT :limit")
suspend fun getN(limit: Int): List<HttpTransaction>
@Query("SELECT * FROM transactions ORDER BY requestDate DESC LIMIT :limit")
suspend fun getLastN(limit: Int): List<HttpTransaction>
}

0 comments on commit 171e197

Please sign in to comment.