Skip to content

Fix priority rules and bounds updates#1233

Merged
CollinBeczak merged 12 commits into
mainfrom
fix-priority-rules-and-bounds-updates
Jun 5, 2026
Merged

Fix priority rules and bounds updates#1233
CollinBeczak merged 12 commits into
mainfrom
fix-priority-rules-and-bounds-updates

Conversation

@CollinBeczak

@CollinBeczak CollinBeczak commented May 26, 2026

Copy link
Copy Markdown
Contributor

Replaces the batched, per-task Scala recompute in updateTaskPriorities with a
single SQL UPDATE … SET priority = CASE … END issued against the whole
challenge. Priority rules and bounds are translated to SQL once
(buildPriorityCaseExpression) and the same expression is reused by
previewTaskPriorities, so the editor preview is byte-for-byte identical to
what a save will write. (Preview is used for mr4)

  • Pagination loop and 3 follow-up UPDATE tasks WHERE id IN (…) per batch
    collapse into one statement, executed in one transaction.
  • WHERE priority IS DISTINCT FROM (…) skips no-op rows; RETURNING priority
    • GROUP BY gives the (high, medium, low) tally of rows actually changed.
  • Polygon bounds → ST_Intersects(geom, ST_GeomFromGeoJSON(…)).
  • Property rules → EXISTS (… jsonb_array_elements(features) … jsonb_each_text(properties) …)
    with case-insensitive key match (mirrors the old Scala
    equalsIgnoreCase) and case-sensitive value match.
  • Bbox-operator rules (contains/not_contains) → location && ST_MakeEnvelope(…, 4326).
  • fixes issue where only first 1000 tasks were getting the updated priority.

Should resolve maproulette/maproulette3#2800

…ment, improving performance and safety by utilizing parameter binding for user-supplied values. Removed outdated methods for priority calculation based on rules and bounds.
…g and state management. Added support for tracking recompute errors and improved UI feedback during priority updates.
- Updated the `recomputePriorities` method to return the count of rows whose priority actually changed, improving clarity on task updates.
- Enhanced error handling by introducing `InvalidException` for untranslatable rules, ensuring better feedback on priority computation failures.
- Removed outdated comments and streamlined the logic for counting task priority changes, aligning with the new return structure.
- Adjusted the `updateTaskPriorities` method to reflect the changes in priority computation, providing a clearer response for clients.
@CollinBeczak CollinBeczak marked this pull request as ready for review June 5, 2026 18:40
@CollinBeczak CollinBeczak requested a review from jake-low June 5, 2026 18:41
jake-low
jake-low previously approved these changes Jun 5, 2026

@jake-low jake-low left a comment

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.

This looks like a nice improvement. I left a couple suggestions but overall this LGTM. If it's a hassle to make changes and retest this then I'm okay merging as-is.

Comment thread app/org/maproulette/models/dal/ChallengeDAL.scala
Comment thread app/org/maproulette/models/dal/ChallengeDAL.scala
Comment thread app/org/maproulette/models/dal/ChallengeDAL.scala Outdated
…f task count tuples, now returning `Unit` instead.

- Updated the `ChallengeController` to reflect changes in the priority update process, focusing on the post-recompute priority distribution.
- Enhanced comments for clarity regarding the priority distribution and the implications of zero counts.
- Streamlined the SQL logic in `recomputePriorities` to improve efficiency and maintainability.
@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

@CollinBeczak CollinBeczak merged commit b520724 into main Jun 5, 2026
9 checks passed
@CollinBeczak CollinBeczak deleted the fix-priority-rules-and-bounds-updates branch June 5, 2026 20:52
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.

Not getting priority tasks from defined high priority bounds.

2 participants