Repository navigation
feat: estimated reading time badge on articles (REST, GraphQL, frontend) - #233
Open
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an estimated reading time to every article, built on the #232 modernization branch (Java 21 / Boot 3.5 / DGS 10 / Next 15).
It's computed on the server from the article body, so REST and GraphQL always return the same number. There's no DB column and no migration:
ArticleData.getReadingTimeMinutes()is a read-only derived getter, soreadingTimeMinutesnow shows up inGET/POST /articles/{slug}and/articleslist entries.Article.readingTimeMinutes: Int!, set inArticleDatafetcher.buildArticleResult. The schema snapshot tests (SchemaContractTest,GraphqlContractTest) are updated; this new field is the only contract change.ReadingTimeBadgecomponent shows "N min read" (.reading-time-badge) inArticleMeta(article page) andArticlePreview(feeds). It shows nothing if the field is missing or less than 1.Tests
ReadingTimeCalculatorTestcovers null/blank input, the 200/201/1000-word boundaries, markdown/link/image stripping, HTML, contractions and accented letters.ArticlesApiTest(450 words → 3),ArticlesContractTest(650 words → 4 on POST, GET and in the list),ArticleQueryTest(GraphQL),JsonSerializationTest.__tests__/components/readingTime.test.tsxcovers the badge, the preview, the article meta, and the case where the field is missing.ReadingTimeBadgeTest(added totestng-smoke.xml) registers a user, publishes a 650-word article, and checks for "4 min read" in the home feed preview and on the article page.Local results: backend 391 tests pass, plus spotless and the JaCoCo gate (94.2% instruction / 84.7% branch). Frontend 158 Vitest tests pass, plus lint, typecheck and build. Selenium 6/6 pass.
Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/375491084ef84a0da00047c334354739
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/375491084ef84a0da00047c334354739?variant=devin
Requested by: @mbatchelor81