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

[1.260.*] Pre-release merge #842

Merged
merged 5 commits into from
Feb 27, 2025
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 @@ -99,19 +99,20 @@ class RssRepository(
?: Instant.DISTANT_PAST.toEpochMilliseconds()

feedPayload.posts.forEach { post ->
if (post.date > feedLastCleanUpAtEpochMilli) {
postQueries.upsert(
id = nameBasedUuidOf(post.link).toString(),
sourceId = feedId,
title = post.title,
description = post.description,
imageUrl = post.imageUrl,
date = Instant.fromEpochMilliseconds(post.date),
link = post.link,
commnetsLink = post.commentsLink,
rawContent = post.rawContent
)
}
if (post.date < feedLastCleanUpAtEpochMilli) return@forEach

postQueries.upsert(
id = nameBasedUuidOf(post.link).toString(),
sourceId = feedId,
title = post.title,
description = post.description,
imageUrl = post.imageUrl,
date = Instant.fromEpochMilliseconds(post.date),
link = post.link,
commnetsLink = post.commentsLink,
rawContent = post.rawContent,
isDateParsedCorrectly = post.isDateParsedCorrectly,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ upsert:
INSERT INTO post(id, sourceId, title, description, rawContent, imageUrl, date, link, commentsLink)
VALUES (:id, :sourceId, :title, :description, :rawContent, :imageUrl, :date, :link, :commnetsLink)
ON CONFLICT(id) DO
UPDATE SET title = excluded.title, description = excluded.description, rawContent = excluded.rawContent, imageUrl = excluded.imageUrl;
UPDATE SET
title = excluded.title,
description = excluded.description,
rawContent = excluded.rawContent,
imageUrl = excluded.imageUrl,
date = CASE WHEN :isDateParsedCorrectly AND date < excluded.date THEN excluded.date ELSE date END,
read = CASE WHEN :isDateParsedCorrectly AND date < excluded.date THEN excluded.read ELSE read END;

count:
SELECT COUNT(DISTINCT post.id) FROM post
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ data class PostPayload(
val rawContent: String?,
val imageUrl: String?,
val date: Long,
val commentsLink: String?
val commentsLink: String?,
val isDateParsedCorrectly: Boolean
) {
companion object
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ internal object AtomContentParser : ContentParser() {
}

return PostPayload(
link = FeedParser.cleanText(link)!!,
title = FeedParser.cleanText(title).orEmpty().decodeHTMLString(),
link = FeedParser.cleanText(link)!!,
description = content.orEmpty().decodeHTMLString(),
rawContent = rawContent,
imageUrl = UrlUtils.safeUrl(hostLink, image),
date = postPubDateInMillis ?: Clock.System.now().toEpochMilliseconds(),
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = postPubDateInMillis != null
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ internal object RDFContentParser : ContentParser() {
}

return PostPayload(
link = FeedParser.cleanText(link)!!,
title = FeedParser.cleanText(title).orEmpty().decodeHTMLString(),
link = FeedParser.cleanText(link)!!,
description = description.orEmpty().decodeHTMLString(),
rawContent = rawContent,
imageUrl = UrlUtils.safeUrl(hostLink, image),
date = postPubDateInMillis ?: Clock.System.now().toEpochMilliseconds(),
commentsLink = commentsLink?.trim()
commentsLink = commentsLink?.trim(),
isDateParsedCorrectly = postPubDateInMillis != null
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ internal object RSSContentParser : ContentParser() {
}

return PostPayload(
link = FeedParser.cleanText(link)!!,
title = FeedParser.cleanText(title).orEmpty().decodeHTMLString(),
link = FeedParser.cleanText(link)!!,
description = description.orEmpty().decodeHTMLString(),
rawContent = rawContent,
imageUrl = UrlUtils.safeUrl(hostLink, image),
date = postPubDateInMillis ?: Clock.System.now().toEpochMilliseconds(),
commentsLink = commentsLink?.trim()
commentsLink = commentsLink?.trim(),
isDateParsedCorrectly = postPubDateInMillis != null
)
}

Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "2.1.10"
android_gradle_plugin = "8.8.1"
android_gradle_plugin = "8.8.2"
compose = "1.8.0-alpha03"
compose_material_icons_extended = "1.7.3"

Expand All @@ -14,17 +14,17 @@ kotlinx_coroutines = "1.10.1"
kotlinx_date_time = "0.6.2"
kotlinx_immutable_collections = "0.3.8"
kotlinx_serialization_json = "1.8.0"
kotlinx_io = "0.6.0"
kotlinx_io = "0.7.0"
decompose = "3.0.0"
essenty = "2.5.0"
androidx_activity = "1.10.0"
androidx_activity = "1.10.1"
androidx_appcompat = "1.7.0"
androidx_core = "1.15.0"
androidx_collection = "1.4.5"
androidx_test_runner = "1.6.2"
androidx_test_rules = "1.6.1"
androidx_work = "2.10.0"
androidx_datastore = "1.1.2"
androidx_datastore = "1.1.3"
androidx_browser = "1.8.0"
androidx_annotation = "1.9.1"
coil = "3.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class FeedParserTest {
rawContent = "First post description.",
imageUrl = "https://example.com/first-post-media-url",
date = 1685005200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post without image",
Expand All @@ -57,7 +58,8 @@ class FeedParserTest {
rawContent = "Second post description.",
imageUrl = null,
date = 1684999800000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Podcast post",
Expand All @@ -66,7 +68,8 @@ class FeedParserTest {
rawContent = "Third post description.",
imageUrl = null,
date = 1684924200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post with enclosure image",
Expand All @@ -75,7 +78,8 @@ class FeedParserTest {
rawContent = "Fourth post description.",
imageUrl = "https://example.com/enclosure-image",
date = 1684924200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post with description and encoded content",
Expand All @@ -89,7 +93,8 @@ class FeedParserTest {
.trimIndent(),
imageUrl = "https://example.com/encoded-image",
date = 1684924200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post with relative path image",
Expand All @@ -98,7 +103,8 @@ class FeedParserTest {
rawContent = "Relative image post description.",
imageUrl = "http://example.com/relative-media-url",
date = 1685005200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post with comments",
Expand All @@ -107,7 +113,8 @@ class FeedParserTest {
rawContent = "Really long post with comments.",
imageUrl = null,
date = 1685005200000,
commentsLink = "https://example/post-with-comments/comments"
commentsLink = "https://example/post-with-comments/comments",
isDateParsedCorrectly = true
),
)
)
Expand Down Expand Up @@ -139,7 +146,8 @@ class FeedParserTest {
rawContent = "First post description.",
imageUrl = null,
date = 1685005200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post with encoded description",
Expand All @@ -153,7 +161,8 @@ class FeedParserTest {
.trimIndent(),
imageUrl = "https://example.com/encoded-image",
date = 1684924200000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
)
)
Expand Down Expand Up @@ -190,7 +199,8 @@ class FeedParserTest {
.trimIndent(),
imageUrl = "https://example.com/image.jpg",
date = 1685008800000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Second post",
Expand All @@ -203,7 +213,8 @@ class FeedParserTest {
.trimIndent(),
imageUrl = null,
date = 1684917000000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post without image",
Expand All @@ -216,7 +227,8 @@ class FeedParserTest {
.trimIndent(),
imageUrl = null,
date = 1684936800000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
PostPayload(
title = "Post with relative image",
Expand All @@ -230,7 +242,8 @@ class FeedParserTest {
.trimIndent(),
imageUrl = "http://example.com/resources/image.jpg",
date = 1685008800000,
commentsLink = null
commentsLink = null,
isDateParsedCorrectly = true
),
)
)
Expand Down
Loading