Tagging system for snippets#93
Open
AgilityB wants to merge 2 commits into
Open
Conversation
- Implement real Stellar SDK integration (submitHashToStellar, submitBatchHashToStellar) replacing mock stubs; embeds snippet created_at timestamp in on-chain memo for proof-of-existence - Add DB functions: getSnippetWithHash, storeSnippetHash (immutable, rejects overwrites), verifySnippetIntegrity, getVerifiedSnippets - Update POST /api/snippets/[id]/verify to anchor creation timestamp on-chain; return 409 if already verified - Add migration script for on_chain_hash, transaction_hash, verified_at columns with indexes
- Add GET /api/snippets/tags returning all unique tags with usage counts - Add findAllTags() to SnippetRepository using jsonb_array_elements_text to unnest tags array and aggregate counts per tag
|
@AgilityB is attempting to deploy a commit to the Sudipta 's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Tagging System for Snippets
Completes the tagging feature by adding tag discoverability. The core tagging system (DB column, validation, storage, and tag-based filtering) was already in place — this PR adds the missing piece that allows clients to know which tags exist.
Context
Tags were already fully wired through the stack:
tags jsonb column on the snippets table
Zod validation enforcing at least one tag on create
Repository search() filtering via tags @> jsonb
GET /api/snippets?tags=React,DSA already working
The gap was discoverability — no endpoint existed to list available tags, making it impossible to build a tag filter UI without hardcoding values.
What changed
snippet.repository.ts
Added findAllTags() — unnests the tags jsonb array across all non-deleted snippets using jsonb_array_elements_text, groups by tag, and returns each unique tag with its usage count ordered by popularity.
route.ts
(new file)
New GET /api/snippets/tags endpoint that calls findAllTags() and returns:
{
"tags": [
{ "tag": "React", "count": 12 },
{ "tag": "DSA", "count": 7 },
{ "tag": "API", "count": 4 }
],
"total": 3
}
Usage
Discover available tags
GET /api/snippets/tags
Filter snippets by one or more tags (already supported)
GET /api/snippets?tags=React,DSA
No migrations required
The tags column already exists. This PR only adds read logic on top of existing data.
Closes #43