Populate Article::image_url instead of re-fetching the thumbnail on every publish #119
Labels
No labels
bug
devops
duplicate
enhancement
good first issue
layout
next major release
next minor release
question
research
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lvl0/fedi-feed-router#119
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
articles.image_urlexists but is never written by production code. The thumbnail is instead re-extracted from the live article page on every publish, which means an avoidable HTTP request per post and no thumbnail available anywhere else in the app.Current state
Only three references exist:
app/Models/Article.php:41'image_url'in$fillabledatabase/migrations/2024_01_01_000001_create_articles_and_publications.php:18$table->string('image_url')->nullable();database/factories/ArticleFactory.php:27'image_url' => $this->faker->optional()->imageUrl(),Nothing in
app/writes it, nothing inresources/reads it, and no test asserts it. In the dev database, 0 of 53 articles have a value.How the thumbnail flows today
PublishNextArticleJob→ArticleFetcher::fetchArticleData($article)→{Belga,Vrt,Guardian}ArticlePageParser::extractThumbnail()→LemmyPublisher::createPost()→LemmyApiServicesetscustom_thumbnail.fetchArticleData()performs a live HTTP fetch of the article page each time it runs. Since it is called at publish time, publishing an article to N routes re-fetches the same page N times, purely to recover a value that was already available when the article was first discovered.Proposed
Persist the thumbnail when the article's content is fetched, and read from the column at publish time.
image_urlduring article fetch/validation, whereextractData()is already being calledLemmyPublisheruses$article->image_urlwhen present, falling back to live extraction when null (so existing articles keep working)Design questions
ValidationService::validate()already fetches article content and setsvalidated_at, so it is the natural point. ConfirmextractData()is called there and that itsthumbnailkey is available.CleanupArticlesJob), this is likely acceptable — but worth a deliberate decision rather than an accident.image_urltriggers live extraction (safer, keeps current behaviour) or is treated as "no thumbnail" (simpler, but changes behaviour for existing rows).Follow-on value
With
image_urlpopulated, the Articles page could show thumbnails in the review list — useful when triaging what to approve. Out of scope here, but the reason to populate rather than drop the column.Alternative considered
Dropping the column entirely. It is genuinely unused and removal would be clean (3 references, no tests, no views, no data). Rejected because the thumbnail is real data the app already extracts and currently discards, and re-fetching it per publish is wasteful — the column is under-used rather than dead.
Acceptance criteria
image_urlis populated when an article's content is fetchedimage_urlstill publish with a thumbnail (fallback path)Related