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

feat: Added event existence check upon alert creation #149

Merged
merged 15 commits into from
Apr 5, 2021
Merged

Conversation

frgfm
Copy link
Member

@frgfm frgfm commented Apr 2, 2021

Following up on #146, this PR introduces the following modifications:

  • fixed fetch_ongoing_alerts
  • made event_id optional in alert creation payloads
  • added a check of existing event referred by similar alerts -> if none exists, it creates an event, otherwise takes the latest
  • updated client accordingly
  • added corresponding unittests

Any feedback is welcome!

@codecov
Copy link

codecov bot commented Apr 2, 2021

Codecov Report

Merging #149 (a8e88d7) into master (21810fd) will increase coverage by 0.34%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   89.98%   90.33%   +0.34%     
==========================================
  Files          28       28              
  Lines         839      859      +20     
==========================================
+ Hits          755      776      +21     
+ Misses         84       83       -1     
Flag Coverage Δ
unittests 90.33% <100.00%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/app/api/crud/alerts.py 67.74% <100.00%> (+39.17%) ⬆️
src/app/api/routes/alerts.py 98.14% <100.00%> (+1.92%) ⬆️
src/app/api/schemas.py 99.18% <100.00%> (+<0.01%) ⬆️
src/app/config.py 96.55% <100.00%> (+0.12%) ⬆️
src/app/db/tables.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21810fd...a8e88d7. Read the comment docs.

Copy link
Member

@fe51 fe51 left a comment

Choose a reason for hiding this comment

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

This PR looks good to me as long as it responds to the problem of linking an alert flow to an event !

Thanks for opening it !

lon: float,
device_id: int,
event_id: Optional[int] = None,
media_id: Optional[int] = None
Copy link
Member

Choose a reason for hiding this comment

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

By setting media_id optional, an alert can be sent without related media ? (I am just wandering if its related to this PR but why not ! )

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh no, this is something that we decided a long time ago 😅 (cf. the SQL table field ;) )
It's for the future case when someone notifies an alert but has no mean to send the picture

@frgfm frgfm merged commit f9e46fc into master Apr 5, 2021
@frgfm frgfm deleted the alert-event branch April 5, 2021 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants