Skip to content

Conversation

@Pravalika-Batchu
Copy link

Add tag support for saved queries (Issue #73)

Summary:
Implemented tag support for saved queries as described in Issue #73.

Changes:

  • Added 'tags' field to Query model
  • Updated database schema
  • Implemented tag parsing in create and update handlers
  • Ensured tags return correctly in GET endpoints
  • Added example test using curl to validate tag functionality

Result:
Users can now:

  • Save a query with tags (type + value)
  • Update a query’s tags
  • Retrieve tags for a query

This completes the backend portion required for Issue #73.

@Pravalika-Batchu Pravalika-Batchu marked this pull request as ready for review November 19, 2025 16:52
@Pravalika-Batchu Pravalika-Batchu marked this pull request as draft November 20, 2025 15:18
@Pravalika-Batchu Pravalika-Batchu marked this pull request as ready for review November 20, 2025 15:18
owner_id TEXT NOT NULL,
active INTEGER NOT NULL,
description TEXT NOT NULL,
tags TEXT DEFAULT '[]',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new table with tags linked to queries instead of adding to the queries table

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback!

I will update the implementation to match the expected design:

Next Steps I Will Implement

Create a separate query_tags table:

id

query_id (foreign key)

type

value

Remove the tags column from the main queries table.

Update:

Repository layer (to insert, update, delete tags)

QueryService

QueryHandler

API responses (to return tags joined from the new table)

This aligns with the intended data model for issue #73.
I’ll push the updated changes shortly. Thanks for the review.

@@ -0,0 +1,38 @@
package main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this used for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right to point out that adding a separate cmd/query_api/main.go ended up duplicating functionality that already exists in backend/server.go. I originally added it as a small standalone server to test the Queries feature during development, but I agree it does not fit the project’s structure.

Here is what I will update:
Remove the entire cmd/query_api/main.go file.
Move all routing logic for Queries into the existing server by registering the routes inside backend/routes.go along with the existing queries and api endpoints.
Make sure all Query handlers run through the main backend server in backend/server.go instead of using a separate entry point.

I will push an updated commit with these changes.

"encoding/json"
"net/http"

"github.com/gorilla/mux"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why switch to gorilla/mux from julienschmidt/httprouter?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right, switching to gorilla/mux was unnecessary.
I'll revert this change and keep using julienschmidt/httprouter to stay consistent with the existing backend architecture.

I initially added mux because I created a temporary standalone query_api server for local testing during development, but since this is not needed, I'll remove that file and integrate everything into the existing server.go + routes.go structure that already uses httprouter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants