fix(backend): auto-generate tag seed data from hashtags in items.json#672
Open
fix(backend): auto-generate tag seed data from hashtags in items.json#672
Conversation
Extend prepare-seed.js to extract hashtags from item text fields and generate tags.json automatically during the seeding process. This ensures hashtag click filtering works correctly in the application. Changes: - Extract all #hashtag patterns from items.json text fields - Generate tags.json with unique tags and auto-assigned colors - Preserve existing tag colors when re-running the script - Add tags.json to .gitignore (auto-generated file) The script runs as part of seed.sh, so CI/CD pipelines and local development will automatically have matching tags for all hashtags used in seed data items.
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.
Motivation
While implementing E2E tests for the TipTap rich text editor integration (PR #670), we discovered that clicking hashtags in item popups did not trigger map filtering.
Investigation revealed that the seed data (
items.json) contains items with hashtags (e.g.,#sustainability,#community), but thetagscollection was empty. The hashtag click handler only triggers filtering when it finds a matching tag registered in the backend.Current Status (on
main)#sustainability) in the popuptagscollection is empty, so filtering silently failscurl http://localhost:8055/items/tagsreturns{"data":[]}Solution
Extended
backend/prepare-seed.jsto automatically:#hashtagpatterns from text fields initems.jsontags.jsonwith unique tags and auto-assigned colorsThe generated
tags.jsonis added to.gitignoresince it's derived fromitems.json.How to Test
docker compose down && sudo rm -rf ./data/database && docker compose up -dcd backend && ./push.sh && ./seed.sh#sustainabilityin the popup?tags=sustainabilityand map filters accordinglycurl http://localhost:8055/items/tagsreturns 34 tags