-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,156 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
src/dispatch/database/revisions/tenant/versions/2023-09-15_3538650dc471.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Adds type to events | ||
Revision ID: 3538650dc471 | ||
Revises: e875e9544048 | ||
Create Date: 2023-09-12 13:43:42.539336 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "3538650dc471" | ||
down_revision = "e875e9544048" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column("event", sa.Column("type", sa.String(), nullable=True)) | ||
op.add_column("event", sa.Column("owner", sa.String(), nullable=True)) | ||
op.add_column("event", sa.Column("pinned", sa.Boolean(), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("event", "type") | ||
op.drop_column("event", "pinned") | ||
op.drop_column("event", "owner") | ||
# ### end Alembic commands ### |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import logging | ||
|
||
from dispatch.decorators import background_task | ||
from dispatch.event import service as event_service | ||
from dispatch.incident import service as incident_service | ||
from dispatch.individual import service as individual_service | ||
from dispatch.event.models import EventUpdate, EventCreateMinimal | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@background_task | ||
def log_incident_event( | ||
user_email: str, | ||
incident_id: int, | ||
event_in: EventCreateMinimal, | ||
db_session=None, | ||
organization_slug: str = None, | ||
): | ||
incident = incident_service.get(db_session=db_session, incident_id=incident_id) | ||
individual = individual_service.get_by_email_and_project( | ||
db_session=db_session, email=user_email, project_id=incident.project.id | ||
) | ||
event_in.source = f"Custom event created by {individual.name}" | ||
event_in.owner = individual.name | ||
|
||
event_service.log_incident_event( | ||
db_session=db_session, | ||
incident_id=incident_id, | ||
**event_in.__dict__, | ||
) | ||
|
||
|
||
@background_task | ||
def update_incident_event( | ||
event_in: EventUpdate, | ||
db_session=None, | ||
organization_slug: str = None, | ||
): | ||
event_service.update_incident_event( | ||
db_session=db_session, | ||
event_in=event_in, | ||
) | ||
|
||
|
||
@background_task | ||
def delete_incident_event( | ||
event_uuid: str, | ||
db_session=None, | ||
organization_slug: str = None, | ||
): | ||
event_service.delete_incident_event( | ||
db_session=db_session, | ||
uuid=event_uuid, | ||
) |
This file contains 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
This file contains 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
Oops, something went wrong.