-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
122 additions
and
18 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
6 changes: 6 additions & 0 deletions
6
capy/src/main/java/com/jocmp/capy/accounts/reader/TagNameExt.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,6 @@ | ||
package com.jocmp.capy.accounts.reader | ||
|
||
import com.jocmp.readerclient.Tag | ||
|
||
val Tag.name: String | ||
get() = id.split("/").lastOrNull().orEmpty() |
16 changes: 16 additions & 0 deletions
16
capy/src/main/java/com/jocmp/capy/persistence/SavedSearchRecords.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,16 @@ | ||
package com.jocmp.capy.persistence | ||
|
||
import com.jocmp.capy.db.Database | ||
|
||
internal class SavedSearchRecords(private val database: Database) { | ||
internal fun upsert(id: String, name: String) { | ||
savedSearchQueries.upsert(id = id, name = name) | ||
} | ||
|
||
internal fun deleteOrphaned(excludedIDs: List<String>) { | ||
savedSearchQueries.deleteOrphaned(excludedIDs = excludedIDs) | ||
} | ||
|
||
private val savedSearchQueries | ||
get() = database.saved_searchesQueries | ||
} |
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
5 changes: 5 additions & 0 deletions
5
capy/src/main/sqldelight/com/jocmp/capy/db/8_AddSavedSearches.sqm
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,5 @@ | ||
CREATE TABLE saved_searches ( | ||
id TEXT NOT NULL PRIMARY KEY, | ||
name TEXT NOT NULL, | ||
query TEXT | ||
); |
5 changes: 5 additions & 0 deletions
5
capy/src/main/sqldelight/com/jocmp/capy/db/9_AddSavedSearchArticles.sqm
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,5 @@ | ||
CREATE TABLE saved_search_articles ( | ||
saved_search_id TEXT NOT NULL REFERENCES saved_searches(id), | ||
article_id TEXT NOT NULL REFERENCES saved_searches(id), | ||
PRIMARY KEY (saved_search_id, article_id) | ||
); |
15 changes: 15 additions & 0 deletions
15
capy/src/main/sqldelight/com/jocmp/capy/db/saved_searches.sq
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,15 @@ | ||
upsert: | ||
INSERT OR REPLACE INTO saved_searches( | ||
id, | ||
name | ||
) | ||
VALUES ( | ||
:id, | ||
:name | ||
); | ||
|
||
deleteOrphaned { | ||
DELETE FROM saved_searches WHERE id NOT IN :excludedIDs; | ||
|
||
DELETE FROM saved_search_articles WHERE saved_search_id NOT IN :excludedIDs; | ||
} |
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
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.jocmp.readerclient | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class Tag( | ||
val id: String, | ||
val type: Type?, | ||
) { | ||
enum class Type { | ||
@Json(name = "folder") | ||
FOLDER, | ||
@Json(name = "tag") | ||
TAG | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
readerclient/src/main/java/com/jocmp/readerclient/TagListResult.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,8 @@ | ||
package com.jocmp.readerclient | ||
|
||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class TagListResult( | ||
val tags: List<Tag> | ||
) |