Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
dheshanm committed Apr 12, 2023
2 parents d56f7fa + d168df7 commit 4124dbb
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 101 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId "com.mohandass.botforge"
minSdk 28
targetSdk 33
versionCode 22
versionName "1.2.2"
versionCode 23
versionName "1.2.3"

vectorDrawables {
useSupportLibrary true
Expand Down Expand Up @@ -126,7 +126,7 @@ dependencies {
implementation 'com.google.firebase:firebase-perf-ktx'
implementation 'com.google.firebase:firebase-appcheck-ktx'

implementation 'com.google.android.gms:play-services-auth:20.4.1'
implementation "com.google.android.gms:play-services-auth:$play_services_auth_version"

// gson
implementation "com.google.code.gson:gson:$gson_version"
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/mohandass/botforge/sync/model/dao/BotDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ interface BotDao {
offset: Int = 0
): List<BotE>

@Query(
"""
SELECT * FROM bots
ORDER BY bots.createdAt DESC
LIMIT :limit OFFSET :offset
"""
)
suspend fun getMostRecentBots(
limit: Int = 15,
offset: Int = 0
)
: List<BotE>

@Query(
"""
SELECT * FROM bots
ORDER BY RANDOM()
LIMIT :limit
"""
)
suspend fun getRandomBots(
limit: Int = 15,
): List<BotE>

// Delete bot with uuid
@Query("DELETE FROM bots WHERE uuid = :uuid")
suspend fun deleteBot(uuid: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ interface BotService {

suspend fun getBot(uuid: String): BotE?

suspend fun getMostRecentBots(limit: Int = 15, offset: Int = 0): List<BotE>

suspend fun getRandomBots(limit: Int = 15): List<BotE>

suspend fun searchBots(query: String): List<BotE>

suspend fun getBots(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class BotServiceImpl(
return botDao.getBot(uuid)
}

override suspend fun getMostRecentBots(limit: Int, offset: Int): List<BotE> {
return botDao.getMostRecentBots(limit, offset)
}

override suspend fun getRandomBots(limit: Int): List<BotE> {
return botDao.getRandomBots(limit)
}

// Get bots that match the query
override suspend fun searchBots(query: String): List<BotE> {
return botDao.search("*$query*")
Expand Down
Loading

0 comments on commit 4124dbb

Please sign in to comment.