Skip to content

Commit 0d21bdb

Browse files
authored
Removes dead/ unused code (Netflix#1452)
* Removes dead/ unused code * Removes unused tests
1 parent 00e2889 commit 0d21bdb

File tree

34 files changed

+20
-535
lines changed

34 files changed

+20
-535
lines changed

src/dispatch/cli.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
log = logging.getLogger(__name__)
3535

3636

37-
def abort_if_false(ctx, param, value):
38-
if not value:
39-
ctx.abort()
40-
41-
4237
@click.group()
4338
@click.version_option(version=__version__)
4439
def dispatch_cli():
@@ -54,7 +49,7 @@ def plugins_group():
5449

5550
@plugins_group.command("list")
5651
def list_plugins():
57-
"""Shows all available plugins"""
52+
"""Shows all available plugins."""
5853
from dispatch.database.core import SessionLocal
5954
from dispatch.plugin import service as plugin_service
6055

@@ -129,7 +124,7 @@ def install_plugins(force):
129124
if force:
130125
click.secho(f"Updating plugin... Slug: {p.slug} Version: {p.version}", fg="blue")
131126
# we only update values that should change
132-
record.tile = p.title
127+
record.title = p.title
133128
record.version = p.version
134129
record.author = p.author
135130
record.author_url = p.author_url

src/dispatch/common/utils/cli.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,3 @@ def install_plugins():
3838
logger.info(f"Failed to load plugin {ep.name} due to missing configuration items. {e}")
3939
except Exception:
4040
logger.error(f"Failed to load plugin {ep.name}:{traceback.format_exc()}")
41-
42-
43-
def get_plugin_properties(json_schema):
44-
for _, v in json_schema["definitions"].items():
45-
return v["properties"]

src/dispatch/common/utils/json_schema.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/dispatch/conference/service.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@ def get_by_resource_id(*, db_session, resource_id: str) -> Optional[Conference]:
1313
return db_session.query(Conference).filter(Conference.resource_id == resource_id).one_or_none()
1414

1515

16-
def get_by_resource_type(*, db_session, resource_type: str) -> List[Optional[Conference]]:
17-
"""Fetch a list of all conferences matching a given resource type.
18-
May return an empty list if no conferences are available."""
19-
return db_session.query(Conference).filter(Conference.resource_type == resource_type).all()
20-
21-
22-
def get_by_conference_id(db_session, conference_id: str) -> Optional[Conference]:
23-
"""Fetch a conference by it's `conference_id`."""
24-
return (
25-
db_session.query(Conference).filter(Conference.conference_id == conference_id).one_or_none()
26-
)
27-
28-
2916
def get_by_incident_id(*, db_session, incident_id: str) -> Optional[Conference]:
3017
"""Fetch a conference by it's associated `incident_id`."""
3118
return db_session.query(Conference).filter(Conference.incident_id == incident_id).one()
@@ -42,5 +29,4 @@ def create(*, db_session, conference_in: ConferenceCreate) -> Conference:
4229
db_session.add(conference)
4330
db_session.commit()
4431
db_session.flush(conference)
45-
4632
return conference

src/dispatch/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def __str__(self) -> str:
8989

9090
DISPATCH_UI_URL = config("DISPATCH_UI_URL", default="http://localhost:8000 ")
9191
DISPATCH_HELP_EMAIL = config("DISPATCH_HELP_EMAIL", default="help@example.com")
92-
DISPATCH_HELP_SLACK_CHANNEL = config("DISPATCH_HELP_SLACK_CHANNEL", default="#general")
9392

9493
# authentication
9594
DISPATCH_AUTHENTICATION_PROVIDER_SLUG = config(

src/dispatch/conversation/service.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ def get(*, db_session, conversation_id: int) -> Optional[Conversation]:
1212
return db_session.query(Conversation).filter(Conversation.id == conversation_id).one_or_none()
1313

1414

15-
def get_by_channel_id(db_session, channel_id: str) -> Optional[Conversation]:
16-
"""Fetch a conversation by its `channel_id`."""
17-
return (
18-
db_session.query(Conversation).filter(Conversation.channel_id == channel_id).one_or_none()
19-
)
20-
21-
2215
def get_by_channel_id_ignoring_channel_type(db_session, channel_id: str) -> Optional[Conversation]:
2316
"""Fetch a conversation by its `channel_id` ignoring the channel type
2417
and update the channel id in the database if the channel type has changed."""

src/dispatch/database/service.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,6 @@ def apply_model_specific_joins(model: Base, query: orm.query):
9393
return query
9494

9595

96-
def paginate(query: orm.Query, page: int, items_per_page: int):
97-
# Never pass a negative OFFSET value to SQL.
98-
offset_adj = 0 if page <= 0 else page - 1
99-
items = query.limit(items_per_page).offset(offset_adj * items_per_page).all()
100-
total = query.order_by(None).count()
101-
return items, total
102-
103-
10496
def composite_search(*, db_session, query_str: str, models: List[Base], current_user: DispatchUser):
10597
"""Perform a multi-table search based on the supplied query."""
10698
s = CompositeSearch(db_session, models)

src/dispatch/event/service.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,46 +25,13 @@ def get(*, db_session, event_id: int) -> Optional[Event]:
2525
return db_session.query(Event).filter(Event.id == event_id).one_or_none()
2626

2727

28-
def get_by_uuid(*, db_session, uuid: UUID) -> Optional[Event]:
29-
"""
30-
Get an event by uuid.
31-
"""
32-
return db_session.query(Event).filter(Event.uuid == uuid).one_or_none()
33-
34-
3528
def get_by_incident_id(*, db_session, incident_id: int) -> List[Optional[Event]]:
3629
"""
3730
Get events by incident id.
3831
"""
3932
return db_session.query(Event).filter(Event.incident_id == incident_id)
4033

4134

42-
def get_by_incident_id_and_source(
43-
*, db_session, incident_id: int, source: str
44-
) -> List[Optional[Event]]:
45-
"""
46-
Get events by incident id and source.
47-
"""
48-
return (
49-
db_session.query(Event)
50-
.filter(Event.incident_id == incident_id)
51-
.filter(Event.source == source)
52-
)
53-
54-
55-
def get_by_incident_id_and_individual_id(
56-
*, db_session, incident_id: int, individual_id: int
57-
) -> List[Optional[Event]]:
58-
"""
59-
Get events by incident id and individual id.
60-
"""
61-
return (
62-
db_session.query(Event)
63-
.filter(Event.incident_id == incident_id)
64-
.filter(Event.source == individual_id)
65-
)
66-
67-
6835
def get_all(*, db_session) -> List[Optional[Event]]:
6936
"""
7037
Get all events.

src/dispatch/feedback/service.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ def get_all(*, db_session):
1818
return db_session.query(Feedback)
1919

2020

21-
def get_all_last_x_hours(*, db_session, hours: int = 24) -> List[Optional[Feedback]]:
22-
"""Returns all feedback provided in the last x hours. Defaults to 24 hours."""
23-
return (
24-
db_session.query(Feedback)
25-
.filter(Feedback.created_at >= datetime.utcnow() - timedelta(hours=hours))
26-
.all()
27-
)
28-
29-
3021
def get_all_last_x_hours_by_project_id(
3122
*, db_session, hours: int = 24, project_id: int
3223
) -> List[Optional[Feedback]]:

src/dispatch/incident/flows.py

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,6 @@ def create_participant_groups(
250250
return tactical_group, notification_group
251251

252252

253-
def delete_participant_groups(incident: Incident, db_session: SessionLocal):
254-
"""Deletes the external participant groups."""
255-
plugin = plugin_service.get_active_instance(
256-
db_session=db_session, project_id=incident.project.id, plugin_type="participant-group"
257-
)
258-
plugin.instance.delete(email=incident.tactical_group.email)
259-
plugin.instance.delete(email=incident.notifications_group.email)
260-
261-
event_service.log(
262-
db_session=db_session,
263-
source=plugin.plugin.title,
264-
description="Tactical and notification groups deleted",
265-
incident_id=incident.id,
266-
)
267-
268-
269253
def create_conference(incident: Incident, participants: List[str], db_session: SessionLocal):
270254
"""Create external conference room."""
271255
plugin = plugin_service.get_active_instance(
@@ -285,24 +269,6 @@ def create_conference(incident: Incident, participants: List[str], db_session: S
285269
return conference
286270

287271

288-
def delete_conference(incident: Incident, db_session: SessionLocal):
289-
"""Deletes the conference."""
290-
conference = conference_service.get_by_incident_id(
291-
db_session=db_session, incident_id=incident.id
292-
)
293-
plugin = plugin_service.get_active_instance(
294-
db_session=db_session, project_id=incident.project.id, plugin_type="conference"
295-
)
296-
plugin.instance.delete(conference.conference_id)
297-
298-
event_service.log(
299-
db_session=db_session,
300-
source=plugin.plugin.title,
301-
description="Incident conference deleted",
302-
incident_id=incident.id,
303-
)
304-
305-
306272
def create_incident_storage(
307273
incident: Incident, participant_group_emails: List[str], db_session: SessionLocal
308274
):
@@ -499,7 +465,7 @@ def remove_participant_from_tactical_group(
499465

500466
@background_task
501467
def incident_create_stable_flow(
502-
*, incident_id: int, checkpoint: str = None, organization_slug: str = None, db_session=None
468+
*, incident_id: int, organization_slug: str = None, db_session=None
503469
):
504470
"""Creates all resources necessary when an incident is created as 'stable'."""
505471
incident_create_flow(incident_id=incident_id, db_session=db_session)
@@ -509,7 +475,7 @@ def incident_create_stable_flow(
509475

510476
@background_task
511477
def incident_create_closed_flow(
512-
*, incident_id: int, checkpoint: str = None, organization_slug: str = None, db_session=None
478+
*, incident_id: int, organization_slug: str = None, db_session=None
513479
):
514480
"""Creates all resources necessary when an incident is created as 'closed'."""
515481
incident = incident_service.get(db_session=db_session, incident_id=incident_id)
@@ -533,14 +499,8 @@ def incident_create_closed_flow(
533499
db_session.commit()
534500

535501

536-
# TODO create some ability to checkpoint
537-
# We could use the model itself as the checkpoint, commiting resources as we go
538-
# Then checking for the existence of those resources before creating them for
539-
# this incident.
540502
@background_task
541-
def incident_create_flow(
542-
*, organization_slug: str, incident_id: int, checkpoint: str = None, db_session=None
543-
):
503+
def incident_create_flow(*, organization_slug: str, incident_id: int, db_session=None):
544504
"""Creates all resources required for new incidents."""
545505
incident = incident_service.get(db_session=db_session, incident_id=incident_id)
546506

0 commit comments

Comments
 (0)