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: add merge incidents endpoint [dnm] #2259

Conversation

Kiryous
Copy link
Contributor

@Kiryous Kiryous commented Oct 21, 2024

Closes #2258

This PR targeting feature branch and a part of the whole feature.

TODO:

  • Add tests
  • Explore more optimal way to remove alerttoincident relations

Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
keep ⬜️ Ignored (Inspect) Visit Preview Oct 22, 2024 4:05pm

@Kiryous Kiryous changed the base branch from main to feature/2042-split-merge-incidents-feature October 21, 2024 18:47
@Kiryous Kiryous changed the title Feature/2258 split merge incidents feat: add merge incidents endpoint Oct 21, 2024
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 36.11111% with 23 lines in your changes missing coverage. Please review.

Please upload report for BASE (feature/2042-split-merge-incidents-feature@7bf3c83). Learn more about missing BASE report.

Files with missing lines Patch % Lines
keep/api/core/db.py 11.53% 23 Missing ⚠️
Additional details and impacted files
@@                              Coverage Diff                              @@
##             feature/2042-split-merge-incidents-feature    #2259   +/-   ##
=============================================================================
  Coverage                                              ?   31.61%           
=============================================================================
  Files                                                 ?       63           
  Lines                                                 ?     6674           
  Branches                                              ?        0           
=============================================================================
  Hits                                                  ?     2110           
  Misses                                                ?     4564           
  Partials                                              ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kiryous Kiryous marked this pull request as ready for review October 22, 2024 08:11
@Kiryous Kiryous changed the title feat: add merge incidents endpoint feat: add merge incidents endpoint [dnm] Oct 22, 2024
@Kiryous Kiryous requested a review from Matvey-Kuk October 22, 2024 08:12
Copy link
Contributor

@Matvey-Kuk Matvey-Kuk left a comment

Choose a reason for hiding this comment

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

Very cool! ✌️

keep/api/core/db.py Outdated Show resolved Hide resolved
)

try:
add_alerts_to_incident(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably suggest moving add_alerts_to_incident close to remove_alerts_to_incident_by_incident_id. So it will remove and immediately add... Per-incident. In this case exception in add_alerts_to_incident will damage only one Incident, not all.

updated_incident_dto = IncidentDto.from_db_incident(updated_incident)
return updated_incident_dto
except DestinationIncidentNotFound as e:
raise HTTPException(status_code=400, detail=str(e))
Copy link
Contributor

Choose a reason for hiding this comment

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

You could actually just inherit DestinationIncidentNotFound from HTTPException and call merge_incidents_to_id without try/except here to let fastapi error handling to the magic. Not critical

Copy link
Contributor Author

@Kiryous Kiryous Oct 22, 2024

Choose a reason for hiding this comment

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

just inherit DestinationIncidentNotFound from HTTPException

yes, but it will link the service layer with view layer. e.g. db.py will be refactored to incidents_service some day and this method could be used in non-routes methods, therefore I propose to keep it not linked.

@Kiryous Kiryous merged commit 2dee447 into feature/2042-split-merge-incidents-feature Oct 23, 2024
14 checks passed
@Kiryous Kiryous deleted the feature/2258-split-merge-incidents branch October 23, 2024 07:02
@Kiryous Kiryous mentioned this pull request Oct 29, 2024
4 tasks
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.

[ + Feature]: Create POST /incidents/merge endpoint
2 participants