From ad4d941ac55359a3a46799f6c01808277be1ba9f Mon Sep 17 00:00:00 2001 From: Yang Date: Wed, 27 Dec 2023 17:23:57 +1100 Subject: [PATCH] Add `issueNumber` to `KotlinWeekly` entry. --- .../backend/datafetcher/mapper/KotlinWeeklyEntryMapper.kt | 1 + src/main/resources/schema/kstreamlined.graphqls | 2 ++ .../backend/datafetcher/FeedEntryDataFetcherTest.kt | 2 ++ .../backend/datafetcher/mapper/KotlinWeeklyEntryMapperTest.kt | 1 + 4 files changed, 6 insertions(+) diff --git a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapper.kt b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapper.kt index 1d31cb3..445ff6a 100644 --- a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapper.kt +++ b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapper.kt @@ -13,5 +13,6 @@ fun KotlinWeeklyItem.toKotlinWeeklyEntry(): KotlinWeekly { .parse(pubDate, DateTimeFormatter.RFC_1123_DATE_TIME) .toInstant(), contentUrl = link, + issueNumber = title.substringAfter("#").toInt(), ) } diff --git a/src/main/resources/schema/kstreamlined.graphqls b/src/main/resources/schema/kstreamlined.graphqls index e91b626..22ecb59 100644 --- a/src/main/resources/schema/kstreamlined.graphqls +++ b/src/main/resources/schema/kstreamlined.graphqls @@ -96,6 +96,8 @@ type KotlinWeekly implements FeedEntry { publishTime: Instant! "Url of the content." contentUrl: String! + "Issue number." + issueNumber: Int! } type KotlinWeeklyIssueEntry { diff --git a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt index d70c58e..7b1f41d 100644 --- a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt +++ b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt @@ -56,6 +56,7 @@ class FeedEntryDataFetcherTest { } ... on KotlinWeekly { __typename + issueNumber } } } @@ -85,6 +86,7 @@ class FeedEntryDataFetcherTest { assertEquals(dummyKotlinWeeklyEntry.title, context.read("data.feedEntries[0].title")) assertEquals(dummyKotlinWeeklyEntry.publishTime, context.read("data.feedEntries[0].publishTime").toInstant()) assertEquals(dummyKotlinWeeklyEntry.contentUrl, context.read("data.feedEntries[0].contentUrl")) + assertEquals(dummyKotlinWeeklyEntry.issueNumber, context.read("data.feedEntries[0].issueNumber")) val dummyKotlinBlogEntry = DummyKotlinBlogItem.toKotlinBlogEntry() assertEquals(dummyKotlinBlogEntry.id, context.read("data.feedEntries[1].id")) diff --git a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapperTest.kt b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapperTest.kt index 8aa3bbd..e4c50a2 100644 --- a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapperTest.kt +++ b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/KotlinWeeklyEntryMapperTest.kt @@ -15,6 +15,7 @@ class KotlinWeeklyEntryMapperTest { title = "Kotlin Weekly #381", publishTime = Instant.parse("2023-11-19T09:13:00Z"), contentUrl = "https://mailchi.mp/kotlinweekly/kotlin-weekly-381", + issueNumber = 381, ) val actual = KotlinWeeklyItem( title = "Kotlin Weekly #381",