diff --git a/core/test/src/commonTest/kotlin/xyz/ksharma/core/test/fakes/FakeSandook.kt b/core/test/src/commonTest/kotlin/xyz/ksharma/core/test/fakes/FakeSandook.kt index 4ee491b4..79a4b900 100644 --- a/core/test/src/commonTest/kotlin/xyz/ksharma/core/test/fakes/FakeSandook.kt +++ b/core/test/src/commonTest/kotlin/xyz/ksharma/core/test/fakes/FakeSandook.kt @@ -3,6 +3,7 @@ package xyz.ksharma.core.test.fakes import xyz.ksharma.krail.sandook.NswStops import xyz.ksharma.krail.sandook.Sandook import xyz.ksharma.krail.sandook.SavedTrip +import xyz.ksharma.krail.sandook.SelectProductClassesForStop import xyz.ksharma.krail.sandook.SelectServiceAlertsByJourneyId class FakeSandook : Sandook { @@ -89,42 +90,20 @@ class FakeSandook : Sandook { productClasses.add(productClass) } - override fun selectStopsByPartialName(stopName: String): List { - return stops.filter { it.stopName.contains(stopName, ignoreCase = true) } + override fun insertTransaction(block: () -> Unit) { + block() } - override fun selectStopsByNameAndProductClass( - stopName: String, - includeProductClassList: List, - ): List { - return stops.filter { stop -> - stop.stopName.contains(stopName, ignoreCase = true) && - stopProductClasses[stop.stopId]?.any { it in includeProductClassList } == true - } + override fun clearNswStopsTable() { } - override fun selectStopsByNameExcludingProductClass( - stopName: String, - excludeProductClassList: List, - ): List { - return stops.filter { stop -> - stop.stopName.contains(stopName, ignoreCase = true) && - stopProductClasses[stop.stopId]?.none { it in excludeProductClassList } == true - } + override fun clearNswProductClassTable() { } - override fun selectStopsByNameExcludingProductClassOrExactId( + override fun selectStops( stopName: String, excludeProductClassList: List, - ): List { - return stops.filter { stop -> - (stop.stopName.contains(stopName, ignoreCase = true) || - stop.stopId == stopName) && - stopProductClasses[stop.stopId]?.none { it in excludeProductClassList } == true - } - } - - override fun insertTransaction(block: () -> Unit) { - block() + ): List { + TODO("Not yet implemented") } } diff --git a/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/RealSandook.kt b/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/RealSandook.kt index 394b6721..23eaf464 100644 --- a/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/RealSandook.kt +++ b/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/RealSandook.kt @@ -106,48 +106,9 @@ internal class RealSandook(factory: SandookDriverFactory) : Sandook { nswStopsQueries.insertStopProductClass(stopId, productClass.toLong()) } - override fun selectStopsByPartialName(stopName: String): List { - return nswStopsQueries.selectStopsByPartialName(stopName).executeAsList() - } - - override fun selectStopsByNameAndProductClass( - stopName: String, - includeProductClassList: List, - ): List { - return nswStopsQueries.selectStopsByNameAndProductClass( - stopName, - includeProductClassList.map { it.toLong() } - ).executeAsList() - } - - override fun selectStopsByNameExcludingProductClass( - stopName: String, - excludeProductClassList: List - ): List { - return nswStopsQueries.selectStopsByNameExcludingProductClass( - stopName, - excludeProductClassList.map { it.toLong() } - ).executeAsList() - } - - /** - * Combines exact stopId and partial [stopName] search logic while excluding stops - * based on the given list of product classes. - */ - override fun selectStopsByNameExcludingProductClassOrExactId( - stopName: String, - excludeProductClassList: List - ): List { - val stopId = stopName - return nswStopsQueries.selectStopsByNameExcludingProductClassOrExactStopId( - stopId, - stopName, - excludeProductClassList.map { it.toLong() } - ).executeAsList() - } - override fun insertTransaction(block: () -> Unit) { nswStopsQueries.transaction { block() } + } override fun clearNswStopsTable() { nswStopsQueries.clearNswStopsTable() @@ -159,8 +120,8 @@ internal class RealSandook(factory: SandookDriverFactory) : Sandook { override fun selectStops( stopName: String, - excludeProductClassList: List - ) : List{ + excludeProductClassList: List, + ): List { return nswStopsQueries.selectProductClassesForStop( stopName, stopName, diff --git a/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/Sandook.kt b/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/Sandook.kt index d93a3a68..7b377f00 100644 --- a/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/Sandook.kt +++ b/sandook/src/commonMain/kotlin/xyz/ksharma/krail/sandook/Sandook.kt @@ -40,40 +40,6 @@ interface Sandook { fun insertNswStopProductClass(stopId: String, productClass: Int) - fun selectStopsByPartialName(stopName: String): List - - /** - * Select stops by name and product class. This is useful for selecting stops that are of a certain product class. - * Use with care, because it may also include those stops which are of multiple product classes, - * that are not included in the include list. - */ - fun selectStopsByNameAndProductClass( - stopName: String, - includeProductClassList: List, - ): List - - /** - * Select stops by name excluding product classes. This is useful for selecting stops that are - * not of a certain product class. - */ - fun selectStopsByNameExcludingProductClass( - stopName: String, - excludeProductClassList: List = emptyList(), - ): List - - /** - * Retrieves stops by matching an exact stop \id\ or partially matching a stop \name\. - * Excludes stops having product classes in the given \excludeProductClassList\. - * \param stopId Exact stop \id\ to match. - * \param stopName Partial stop \name\ to match. - * \param excludeProductClassList Product class IDs to exclude. - * \return List of matching NswStops. - */ - fun selectStopsByNameExcludingProductClassOrExactId( - stopName: String, - excludeProductClassList: List = emptyList(), - ): List - /** * Inserts a list of stops in a single transaction. */ @@ -84,8 +50,8 @@ interface Sandook { fun clearNswProductClassTable() /** - * * Retrieves stops by matching an exact stop \id\ or partially matching a stop \name\. - * * Excludes stops having product classes in the given \excludeProductClassList\. + * Retrieves stops by matching an exact stop \id\ or partially matching a stop \name\. + * Excludes stops having product classes in the given \excludeProductClassList\. */ fun selectStops( stopName: String,