Repository navigation
Conversation
… so it plays well with its database uniqueness constraint Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Annotation rows are shared by every account, asset and sensor they are linked to. Re-posting a label with a prior and a different end to one sensor therefore also moved it on the other sensors showing it. Only update the end when the annotation is linked to nothing but the annotated entity; otherwise, the POST endpoints now return 409. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
BelhsanHmida
left a comment
Contributor
There was a problem hiding this comment.
Looks good, tested: on main, re-posting a label with a prior and a later end gave a 500; with this branch it updates the end, and the new tests go red on main.
One thing I found: annotations are shared rows, so updating the end from sensor 2 also moved it on sensor 1. I pushed a fix: the end is only updated when nothing else shows the annotation, otherwise the API returns 409.
If you agree that's how annotations should behave, then the PR is approved.
…ing-existing Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Posting an annotation with a changed end time can return HTTP 500. The lookup includes end and omits belief_time, while the database uniqueness constraint includes belief_time and excludes end. Extending an existing EV label from 07:00 to 07:15 therefore attempts a conflicting insert.
Align the lookup with the database identity: content, start, belief time, source and type. When an annotation already exists, update its end time and reuse it. Preserve separate annotations for different belief times.
Regression tests cover extending an annotation, repeating the request and preserving distinct belief times. The failure and fix were also reproduced locally using v1.1.1’s annotation model on an isolated SQLite database; the full server test suite has not been run.
Found while working on the HEMS script, as I made annotations longer.
documentation/changelog.rst