Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add && separator for tags filter param on queryStatuses endpoint #3261

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

foysalit
Copy link
Contributor

This PR adds a special separator character in the tags filter param array on tools.ozone.moderation.queryStatuses endpoint which allows moderators to filter queue items for multiple tags using the AND operator instead of the default OR operator which is applied between different items in the array.

So, currently, there is no way for a moderator to find all subjects that have both embed:image and lang:ja tags because passing tags: ['lang:ja', 'embed:image'] will return all items with either of the tags. This PR makes way for us to apply the expected filter using the syntax tags: ['lang:ja && embed:image']

Comment on lines 809 to 815
return sql`(${sql.join(
subTags.map(
(subTag) =>
sql`${ref('moderation_subject_status.tags')} ? ${subTag}`,
),
sql` AND `,
)})`
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ignore empty queries ? Or maybe even throw an error ?

Suggested change
return sql`(${sql.join(
subTags.map(
(subTag) =>
sql`${ref('moderation_subject_status.tags')} ? ${subTag}`,
),
sql` AND `,
)})`
// False is neutral in a union ("OR")
if (!subTags.length) return sql`FALSE`
return sql`(${sql.join(
subTags.map(
(subTag) =>
sql`${ref('moderation_subject_status.tags')} ? ${subTag}`,
),
sql` AND `,
)})`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch! handled these edge cases through boolean filters.

@foysalit foysalit merged commit 6a3e781 into main Dec 18, 2024
10 checks passed
@foysalit foysalit deleted the ozone-advanced-tag-filter branch December 18, 2024 22:46
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