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

update bundling workflow and add task locking for bundles #2524

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

CollinBeczak
Copy link
Collaborator

@CollinBeczak CollinBeczak commented Jan 25, 2025

Simplified rebase of #2500
partially resolves: #2540
potentially resolves: #1495

Issue

Bundles are not being reset or deleted when a user remains inactive for an extended period, allowing them to bypass the bundle reset conditions. This leads to various issues, such as finalized conditions in the completion step not being properly set.

Solution

Instead of updating bundles in the database every time they are created or edited, they will now only be modified when a user completes a task. The task lock status will prevent other users from bundling tasks that have already been bundled by another user.

New Functionality

  • Add individual tasks to a bundle
  • Delete bundles when creating a new bundle
  • Improved bundle editing flexibility:
    • Users can now delete existing bundles and which allows them to also utilize the lasso tool
    • If a bundle exists when opening a task, users can reset it to its initial state
    • The "Review Nearby Tasks" widget has been updated and will likely be available in both the completion and review flow

@CollinBeczak CollinBeczak force-pushed the update-bundling-workflow-and-add-task-locking-for-bundles branch 3 times, most recently from 6f6d47b to b3258b1 Compare February 1, 2025 01:45
@CollinBeczak CollinBeczak force-pushed the update-bundling-workflow-and-add-task-locking-for-bundles branch from 58baf90 to 8a9a1fe Compare February 11, 2025 03:55
@CollinBeczak CollinBeczak force-pushed the update-bundling-workflow-and-add-task-locking-for-bundles branch from c6d541a to 544e31c Compare February 12, 2025 04:26
@CollinBeczak CollinBeczak marked this pull request as ready for review February 12, 2025 07:01
jake-low
jake-low previously approved these changes Feb 12, 2025
Copy link
Contributor

@jake-low jake-low left a comment

Choose a reason for hiding this comment

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

LGTM

src/components/TaskAnalysisTable/TaskAnalysisTable.jsx Outdated Show resolved Hide resolved
Comment on lines 79 to 83
const showAsClusters =
((this.props.criteria?.zoom ?? 0) < MAX_ZOOM &&
(wantToShowAsClusters || this.state.taskCount > UNCLUSTER_THRESHOLD) &&
!this.props.createTaskBundle &&
this.state.taskCount > UNCLUSTER_THRESHOLD) ||
!this.props.createTaskBundle) ||
!this.props.criteria.boundingBox;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see there was a bug in this logic that you fixed already. FWIW I like to write complex conditionals like this in pieces, like this, which IMO helps with readability.

const isAtMaxZoom = (this.props.criteria?.zoom ?? 0) >= MAX_ZOOM;
const tooManyTasksToShowUnclustered = this.state.taskCount > UNCLUSTER_THRESHOLD;
const showAsClusters = !isAtMaxZoom && (wantToShowAsClusters || tooManyTasksToShowUnclustered) && !this.props.createTaskBundle;

Another trick is to move the logic into a helper function where you can use the early return pattern.

function showAsClusters() {
  if ((this.props.criteria?.zoom ?? 0) >= MAX_ZOOM) {
    return false; // don't cluster at max zoom
  }
  if (this.props.createTaskBundle) {
    return false; // don't cluster when the user is creating a task bundle
  }
  if (this.state.taskCount > UNCLUSTER_THRESHOLD) {
    return true; // always cluster if there are tons of tasks visible
  }
  // otherwise respect the user's preference for whether or not to cluster
  return wantsToShowAsClusters;
}

The latter is more verbose, but that actually has a hidden benefit: combinations of conditions that aren't tested will show up in code coverage results (whereas a single big conditional expression will always be hit, so you may not realize that your tests don't exercise every possible combination).

@CollinBeczak CollinBeczak marked this pull request as draft February 13, 2025 02:20
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.

Ocean of errors multi-tasking bbox don't complete enclose POIs
2 participants