Skip to content

Expose session regrouping as a job stage when syncing images #1157

@mihow

Description

@mihow

Summary

When syncing captures from storage, the session regrouping step is buried inside Deployment.save() and not visible as a job stage. Users have no visibility into how many sessions were created/updated, or whether captures were left ungrouped (e.g., due to missing timestamps).

Current behavior

  • sync_captures() calls self.save(regroup_async=False) which triggers group_images_into_events() internally
  • The job logs show "Saving and recalculating sessions for deployment" as an INFO message but it's not a tracked stage
  • If images have NULL timestamps, they silently remain ungrouped with no warning in the job

Desired behavior

  • Add a "Recalculate sessions" stage to the sync job progress
  • Show number of sessions created/updated as a stage parameter
  • Warn if any captures are not assigned to a session (e.g., ungrouped_captures param)
  • Log a warning with the count of ungrouped images

Related

  • PR Fix incorrect session grouping  #904 refactors group_images_into_events and may be a good place to implement this
  • Discovered while debugging Farmscape NSCF camera imports where 2-digit year timestamps caused NULL timestamps on all 183 captures

Key code locations

  • ami/main/models.py:782-851sync_captures() method
  • ami/main/models.py:979-993Deployment.save() regroup logic
  • ami/main/models.py:1290-1372group_images_into_events() function
  • ami/jobs/models.py:596-640DataStorageSyncJob job type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions