Skip to content

Handle redeploy missing middle haul#30

Open
chrisj-er wants to merge 3 commits intomainfrom
release-2026-03-28
Open

Handle redeploy missing middle haul#30
chrisj-er wants to merge 3 commits intomainfrom
release-2026-03-28

Conversation

@chrisj-er
Copy link
Copy Markdown

@chrisj-er chrisj-er commented Mar 28, 2026

  • processor.py:233-252: Added is_redeployment parameter to _create_haul_payload
  • processor.py:285-293: When is_redeployment=True and no dateRecovered is found, uses dateDeployed - 1s as a deterministic recorded_at instead of falling back to lastUpdated (which would truncate to the same second as dateDeployed, causing an ER unique constraint collision)
  • processor.py:268: Uses self._utcnow() instead of datetime.now(timezone.utc) for testability
  • processor.py:343-345: Uses self._utcnow() for haul device last_updated for consistency
  • processor.py:855: Pass is_redeployment=serial_number_user_id in to_deploy when calling _create_haul_payload

  - processor.py:233-252: Added is_redeployment parameter to _create_haul_payload
  - processor.py:280-284: When is_redeployment=True and no dateRecovered is found, the method keeps datetime.now(timezone.utc) as recorded_at instead of falling back to lastUpdated (which would
  truncate to the same second as dateDeployed)
  - processor.py:855: Pass is_redeployment=serial_number_user_id in to_deploy when calling _create_haul_payload
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates EdgeTech re-deployment haul handling to avoid (device_id, recorded_at) uniqueness collisions in EarthRanger when EdgeTech data lacks any dateRecovered (i.e., “skipped haul” cases), and documents the new behavior.

Changes:

  • Added an is_redeployment flag to _create_haul_payload and altered timestamp selection logic to avoid using lastUpdated during re-deployments when no dateRecovered is available.
  • Updated processing to pass the re-deployment context into _create_haul_payload.
  • Added a regression test and expanded README documentation around re-deployment haul timestamp collision scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
app/actions/edgetech/processor.py Adds is_redeployment to haul payload creation and changes fallback behavior to reduce recorded_at collisions.
app/actions/tests/test_edgetech_processor.py Adds a regression test for “skipped haul” re-deployment timestamp collision behavior.
README.md Documents why collisions occur (seconds truncation + unique constraint) and the chosen mitigation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…deterministic, guaranteed no collision regardless of when the processor runs

  2. self._utcnow() instead of datetime.now(timezone.utc) (processor.py:268) — uses the existing testable helper for the default fallback
  3. Deterministic test (test file) — asserts the exact expected value (dateDeployed - 1s) instead of just !=
  4. README x2 — updated both references to describe dateDeployed - 1s instead of datetime.now(UTC)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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