Repository navigation
Fix CommandSequence last_seen updates. Closes #1717 - #1835
anshulsharma200817-svg wants to merge 2 commits into
Conversation
|
Hi @regulartim, There was a ruff formating issue i fixed i rechecked the by running the project; there were no conflicts and test case failing. Can you trigger the workflow again and review the code to merge it |
regulartim
left a comment
There was a problem hiding this comment.
Hey @anshulsharma200817-svg !
There was a ruff formating issue i fixed i rechecked the by running the project; there were no conflicts and test case failing. Can you trigger the workflow again and review the code to merge it
Oh really? This should not happen. Normally develop always passes Ruff checks. Which one was it? Did you use our rule set (defined in pyproject.toml)?
CI fails. I think you need to adapt some tests to match the changes you made.
I think it would be better if you would not use ChatGPT like that, as it takes away some of the learning process and is on the edge of violating our AI policy. Did you write all code by hand or did you also include written by the agent / LLM? |
Description
Updated
_process_commands()ingreedybear/process_event.pyto separate command sequence creation from timestamp updates and use actual event timestamps instead of relying primarily on processing time.@timestamp) from the processed hits, falling back totimezone.now()only when no valid event timestamp is available.first_seenandlast_seenusing the observed event timestamp.last_seen, preserving the originalfirst_seen.last_seenis updated only when the newly observed event timestamp is later than the existing value, preventing older or delayed events from moving the timestamp backwards.Added regression tests to verify initial timestamps, repeated command sequence observations, and out-of-order event processing.
Related issues
Closes #1717
Previously,
_process_commands()relied on Django'sget_or_create()to manage command sequences. Sinceget_or_create()applies itsdefaultsonly when creating a new record, subsequent observations of an existing command sequence did not update itslast_seentimestamp.Additionally, timestamps were primarily based on processing time rather than the actual sensor event time, which could lead to inaccurate results when events were delayed or processed out of order.
AI disclosure
ChatGPT was used for code understanding, implementation guidance, debugging, suggesting regression test cases, and reviewing the changes. All suggested changes were reviewed, understood, and tested by the contributor.
Type of change
Checklist
Please complete this checklist carefully. It helps guide your contribution and lets maintainers verify that all requirements are met.
Formalities
<feature name>. Closes #999develop.develop.Docs and tests
Ruff) gave 0 errors.GUI changes
Review process