-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt # android/festago/presentation/src/main/res/values/strings.xml
- Loading branch information
Showing
249 changed files
with
5,268 additions
and
5,469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
android/festago/data/src/main/java/com/festago/festago/data/dao/RecentSearchQueryDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.festago.festago.data.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Query | ||
import androidx.room.Upsert | ||
import com.festago.festago.data.model.RecentSearchQueryEntity | ||
|
||
@Dao | ||
interface RecentSearchQueryDao { | ||
@Query(value = "SELECT * FROM recentSearchQueries ORDER BY created_at DESC LIMIT :limit") | ||
suspend fun getRecentSearchQueryEntities(limit: Int): List<RecentSearchQueryEntity> | ||
|
||
@Upsert | ||
suspend fun insertOrReplaceRecentSearchQuery(recentSearchQuery: RecentSearchQueryEntity) | ||
|
||
@Delete | ||
suspend fun deleteRecentSearchQuery(recentSearchQuery: RecentSearchQueryEntity) | ||
|
||
@Query(value = "DELETE FROM recentSearchQueries") | ||
suspend fun clearRecentSearchQueries() | ||
} |
11 changes: 11 additions & 0 deletions
11
android/festago/data/src/main/java/com/festago/festago/data/database/FestagoDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.festago.festago.data.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import com.festago.festago.data.dao.RecentSearchQueryDao | ||
import com.festago.festago.data.model.RecentSearchQueryEntity | ||
|
||
@Database(entities = [RecentSearchQueryEntity::class], version = 1) | ||
abstract class FestagoDatabase : RoomDatabase() { | ||
abstract fun recentSearchQueryDao(): RecentSearchQueryDao | ||
} |
17 changes: 17 additions & 0 deletions
17
android/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/DaosModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.festago.festago.data.di.singletonscope | ||
|
||
import com.festago.festago.data.dao.RecentSearchQueryDao | ||
import com.festago.festago.data.database.FestagoDatabase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object DaosModule { | ||
|
||
@Provides | ||
fun providesRecentSearchQueryDao(database: FestagoDatabase): RecentSearchQueryDao = | ||
database.recentSearchQueryDao() | ||
} |
25 changes: 25 additions & 0 deletions
25
...d/festago/data/src/main/java/com/festago/festago/data/di/singletonscope/DatabaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.festago.festago.data.di.singletonscope | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import com.festago.festago.data.database.FestagoDatabase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object DatabaseModule { | ||
@Provides | ||
@Singleton | ||
fun providesFestagoDatabase( | ||
@ApplicationContext context: Context, | ||
): FestagoDatabase = Room.databaseBuilder( | ||
context, | ||
FestagoDatabase::class.java, | ||
"festago-database", | ||
).build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...id/festago/data/src/main/java/com/festago/festago/data/dto/artist/ArtistSearchResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.festago.festago.data.dto.artist | ||
|
||
import com.festago.festago.domain.model.search.ArtistSearch | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ArtistSearchResponse( | ||
val id: Long, | ||
val name: String, | ||
val profileImageUrl: String, | ||
val todayStage: Int, | ||
val upcomingStage: Int, | ||
) { | ||
fun toDomain() = ArtistSearch( | ||
id = id, | ||
name = name, | ||
profileImageUrl = profileImageUrl, | ||
todayStage = todayStage, | ||
upcomingStage = upcomingStage, | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
...id/festago/data/src/main/java/com/festago/festago/data/dto/school/SchoolSearchResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.festago.festago.data.dto.school | ||
|
||
import com.festago.festago.domain.model.search.SchoolSearch | ||
import kotlinx.serialization.Serializable | ||
import java.time.LocalDate | ||
|
||
@Serializable | ||
data class SchoolSearchResponse( | ||
val id: Long, | ||
val name: String, | ||
val logoUrl: String, | ||
val upcomingFestivalStartDate: String?, | ||
) { | ||
fun toDomain() = SchoolSearch( | ||
id = id, | ||
name = name, | ||
logoUrl = logoUrl, | ||
upcomingFestivalStartDate = upcomingFestivalStartDate?.let { LocalDate.parse(it) }, | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
android/festago/data/src/main/java/com/festago/festago/data/model/RecentSearchQueryEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.festago.festago.data.model | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import com.festago.festago.domain.model.recentsearch.RecentSearchQuery | ||
|
||
@Entity( | ||
tableName = "recentSearchQueries", | ||
) | ||
data class RecentSearchQueryEntity( | ||
@PrimaryKey | ||
val query: String, | ||
@ColumnInfo(name = "created_at") | ||
val createdAt: Long, | ||
) { | ||
fun toDomain() = RecentSearchQuery(query = query, queriedDate = createdAt) | ||
} |
39 changes: 39 additions & 0 deletions
39
...o/data/src/main/java/com/festago/festago/data/repository/DefaultRecentSearchRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.festago.festago.data.repository | ||
|
||
import com.festago.festago.data.dao.RecentSearchQueryDao | ||
import com.festago.festago.data.model.RecentSearchQueryEntity | ||
import com.festago.festago.domain.model.recentsearch.RecentSearchQuery | ||
import com.festago.festago.domain.repository.RecentSearchRepository | ||
import kotlinx.coroutines.flow.map | ||
import javax.inject.Inject | ||
|
||
class DefaultRecentSearchRepository @Inject constructor( | ||
private val recentSearchQueryDao: RecentSearchQueryDao, | ||
) : RecentSearchRepository { | ||
|
||
override suspend fun insertOrReplaceRecentSearch(searchQuery: String) { | ||
recentSearchQueryDao.insertOrReplaceRecentSearchQuery( | ||
RecentSearchQueryEntity( | ||
query = searchQuery, | ||
createdAt = System.currentTimeMillis(), | ||
), | ||
) | ||
} | ||
|
||
override suspend fun deleteRecentSearch(searchQuery: String) { | ||
recentSearchQueryDao.deleteRecentSearchQuery( | ||
RecentSearchQueryEntity( | ||
query = searchQuery, | ||
createdAt = System.currentTimeMillis(), | ||
), | ||
) | ||
} | ||
|
||
override suspend fun getRecentSearchQueries(limit: Int): List<RecentSearchQuery> { | ||
return recentSearchQueryDao.getRecentSearchQueryEntities(limit).map { recentSearchQueries -> | ||
recentSearchQueries.toDomain() | ||
} | ||
} | ||
|
||
override suspend fun clearRecentSearches() = recentSearchQueryDao.clearRecentSearchQueries() | ||
} |
33 changes: 33 additions & 0 deletions
33
...festago/data/src/main/java/com/festago/festago/data/repository/DefaultSearchRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.festago.festago.data.repository | ||
|
||
import com.festago.festago.data.service.SearchRetrofitService | ||
import com.festago.festago.data.util.onSuccessOrCatch | ||
import com.festago.festago.data.util.runCatchingResponse | ||
import com.festago.festago.domain.model.festival.Festival | ||
import com.festago.festago.domain.model.search.ArtistSearch | ||
import com.festago.festago.domain.model.search.SchoolSearch | ||
import com.festago.festago.domain.repository.SearchRepository | ||
import javax.inject.Inject | ||
|
||
class DefaultSearchRepository @Inject constructor( | ||
private val searchRetrofitService: SearchRetrofitService, | ||
) : SearchRepository { | ||
|
||
override suspend fun searchFestivals(searchQuery: String): Result<List<Festival>> { | ||
return runCatchingResponse { searchRetrofitService.searchFestivals(searchQuery) }.onSuccessOrCatch { festivalResponses -> | ||
festivalResponses.map { it.toDomain() } | ||
} | ||
} | ||
|
||
override suspend fun searchArtists(searchQuery: String): Result<List<ArtistSearch>> { | ||
return runCatchingResponse { | ||
searchRetrofitService.searchArtists(searchQuery) | ||
}.onSuccessOrCatch { artistSearchResponses -> artistSearchResponses.map { it.toDomain() } } | ||
} | ||
|
||
override suspend fun searchSchools(searchQuery: String): Result<List<SchoolSearch>> { | ||
return runCatchingResponse { | ||
searchRetrofitService.searchSchools(searchQuery) | ||
}.onSuccessOrCatch { schoolSearchResponses -> schoolSearchResponses.map { it.toDomain() } } | ||
} | ||
} |
Oops, something went wrong.