Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework updated_at to act as arrived_at #651

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ internal class ArticleRecords internal constructor(
articleIDs = articleIDs,
read = true,
lastReadAt = updated,
updatedAt = updated
)
}

Expand All @@ -143,23 +142,20 @@ internal class ArticleRecords internal constructor(
articleIDs = listOf(articleID),
read = false,
lastReadAt = null,
updatedAt = nowUTC().toEpochSecond()
)
}

fun addStar(articleID: String, updatedAt: ZonedDateTime = nowUTC()) {
database.articlesQueries.markStarred(
articleID = articleID,
starred = true,
updatedAt = updatedAt.toEpochSecond()
)
}

fun removeStar(articleID: String, updatedAt: ZonedDateTime = nowUTC()) {
database.articlesQueries.markStarred(
articleID = articleID,
starred = false,
updatedAt = updatedAt.toEpochSecond()
)
}

Expand Down
11 changes: 3 additions & 8 deletions capy/src/main/sqldelight/com/jocmp/capy/db/articles.sq
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,8 @@ VALUES (
)
ON CONFLICT(article_id) DO UPDATE
SET
updated_at = updated_at,
last_read_at = excluded.last_read_at,
read = excluded.read,
starred = starred;
read = excluded.read;

updateStaleUnreads:
UPDATE article_statuses SET read = 1 WHERE article_id NOT IN :excludedIDs;
Expand All @@ -279,17 +277,14 @@ VALUES (
)
ON CONFLICT(article_id) DO UPDATE
SET
updated_at = updated_at,
last_read_at = last_read_at,
read = read,
starred = excluded.starred;

markRead:
UPDATE article_statuses SET read = :read, last_read_at = :lastReadAt, updated_at = :updatedAt
UPDATE article_statuses SET read = :read, last_read_at = :lastReadAt
WHERE article_statuses.article_id IN :articleIDs;

markStarred:
UPDATE article_statuses SET starred = :starred, updated_at = :updatedAt
UPDATE article_statuses SET starred = :starred
WHERE article_statuses.article_id = :articleID;

deleteAllArticles {
Expand Down
Loading