Skip to content

[CORE-325] Get Filters#188

Open
S-h-u-a-n wants to merge 6 commits into
mainfrom
feat/CORE-325-get-filters
Open

[CORE-325] Get Filters#188
S-h-u-a-n wants to merge 6 commits into
mainfrom
feat/CORE-325-get-filters

Conversation

@S-h-u-a-n

Copy link
Copy Markdown
Contributor

Type of changes

  • Feature

Purpose

  • Implement filters API 1 to get the filters of a column

Additional Information

@S-h-u-a-n S-h-u-a-n changed the title [CORE-325] get filters [CORE-325] Get Filters Jul 4, 2026
@S-h-u-a-n
S-h-u-a-n marked this pull request as ready for review July 7, 2026 13:13
@S-h-u-a-n
S-h-u-a-n requested review from Dada8825252 and linoil July 7, 2026 13:13
Comment thread cmd/backend/main.go
for _, raw := range answers {
var data map[string]any
err = json.Unmarshal(raw, &data)
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The unmarshal error is silently ignored. Please log a warning so that malformed data in the database can be traced.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for the misleading comment — this should actually be logged as error rather than logged as warn. A failed unmarshal here means the data already stored in the database is malformed, which is an unexpected state that should be surfaced clearly.

Comment thread internal/form/answer/service.go Outdated
seen := make(map[uuid.UUID]bool)

for _, raw := range answers {
var data map[string]any

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unmarshal into the existing structs (e.g. SingleChoiceAnswer for single-choice, MultipleChoiceAnswer / DetailedMultipleChoiceAnswer for multi-choice) instead of using a raw map[string]any. This makes the code more readable and safer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK!

Files []shared.UploadFileEntry `json:"files"`
}

type FilterAnswerRequest struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The outer filters wrapper in FilterAnswerRequest seems unnecessary since this endpoint already targets a specific questionId via the path. Consider flattening the request body to just { "answers": [{ "option": "uuid" }] }.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FilterAnswerRequest records the answers that had already been chosen, so there might be multiple questionId and their answers. ( And the questionId might not be the one in the path ) That's why I use the outer filters to wrap the struct.

@Dada8825252 Dada8825252 Jul 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation. On the other hand, Answers []struct currently only contains Option, but if there's a chance more fields will be added in the future, consider extracting it into a named struct for readability and easier extension.

@S-h-u-a-n S-h-u-a-n Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to the previous discussion, I think we will named it Option for now... since every column representing matchValue is named Option

defer span.End()
logger := logutil.WithContext(traceCtx, h.logger)

formIdStr := r.PathValue("formId")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

formId and viewId are parsed from the path but not used in any business logic — they are only echoed back in the response. Consider whether they should be validated), or if parsing them is unnecessary.

@S-h-u-a-n S-h-u-a-n Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I remember that we discussed in the meeting and decided to parse formId and viewId, but actually I don't remember why...QQ
Should I bring this out in the next meeting?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this might have been included under the assumption that it would be used. We may discuss this further in the next meeting.

Comment thread internal/form/answer/handler.go Outdated
Comment thread internal/form/answer/handler.go Outdated
@S-h-u-a-n
S-h-u-a-n requested review from Dada8825252 and linoil July 12, 2026 06:40
@Dada8825252
Dada8825252 requested review from Dada8825252 and removed request for Dada8825252 and linoil July 14, 2026 12:39
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.

3 participants