feat: trending hashtags and bookmarks - #2076
Merged
Merged
Conversation
Both were already half-built and completely unreachable. The cron job has been counting hashtag use per window — 1h, 12h, 1d, 3d, 10d — into social_hashtag.trend for as long as the table has existed, and nothing ever read it. GET /api/v1/trends/tags now serves those counts as Mastodon Tag entities, and the sidebar lists the top five with how often each was used; picking one opens its timeline. The ordering happens in PHP because the counts live in a JSON column that no supported database can be asked to sort on portably, and the table holds one row per hashtag the instance has ever seen — cheaper than a schema for it. `accounts` in the history is always 0: this instance counts uses, not distinct accounts, and saying so beats inventing a number. Bookmarks were the same story as blocked accounts: the action worked, /api/v1/bookmarks returned the list, and the word 'bookmark' did not appear anywhere in src/. There is now a bookmark entry in every post's menu and a Bookmarks timeline in the sidebar. Removing a bookmark while reading that list takes the post off it, and a refusal from the server puts the flag back rather than leaving the UI lying. Also corrects the README, which still said creating polls was not supported three PRs after it shipped. Signed-off-by: Frank Karlitschek <frank.karlitschek@nextcloud.com> Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Frank Karlitschek <frank.karlitschek@nextcloud.com>
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.
Stacks on #2075 (→ #2074 → #2073). Merge in that order.
Both features were already half-built and completely unreachable from the app.
Trending hashtags
The cron job has been counting hashtag use per window — 1 h, 12 h, 1 d, 3 d, 10 d — into
social_hashtag.trendfor as long as the table has existed (HashtagService::manageHashtags()), and nothing ever read it.GET /api/v1/trends/tagsserves those counts as MastodonTagentities (limit, capped at 20;period, defaulting to1d).Two deliberate choices worth reviewing:
accountsis always0. Mastodon reports distinct accounts per tag; this app counts uses. Reporting 0 and documenting it beats inventing a number that clients would display as fact.Bookmarks
Exactly the same story as blocked accounts two PRs ago: the
bookmarkaction worked,/api/v1/bookmarksreturned the list, and the word "bookmark" appeared nowhere insrc/.Also
The README still said "Creating own polls is not supported" — three PRs after own polls shipped. Corrected.
Tests
5 service specs (window ordering, the window deciding the order, unused tags excluded, limit honoured, unknown window falling back, quiet instance), 3 controller specs (entity shape, limit cap, readable without a viewer), 4 sidebar specs (listing with counts, opening a tag, quiet instance, unreadable counts staying silent), 4 store specs (bookmark/unbookmark optimism and rollback, plus removal from the bookmarks list). 1847 PHP, 691 vitest, lint clean.
Verified on devel
🤖 Generated with Claude Code