Skip to content

Commit

Permalink
Merge branch 'master' into feature/workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgliss committed Oct 2, 2020
2 parents 7f8424c + d4d875d commit 605b519
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/dispatch/common/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def install_plugins():
plugin = ep.load()
register(plugin)
logger.info(f"Successfully loaded plugin: {ep.name}")
except KeyError as e:
logger.warning(
f"Failed to load plugin {ep.name} due to missing configuration items. {e}"
)
except SQLAlchemyError:
logger.error(
"Something went wrong with creating plugin rows, is the database setup correctly?"
Expand Down
1 change: 0 additions & 1 deletion src/dispatch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def __str__(self) -> str:
INCIDENT_RESOURCE_INCIDENT_TASK = config(
"INCIDENT_RESOURCE_INCIDENT_TASK", default="google-docs-incident-task"
)
ONCALL_PLUGIN_SLUG = config("ONCALL_PLUGIN_SLUG", default="opsgenie-oncall")

# Incident Cost Configuration
ANNUAL_COST_EMPLOYEE = config("ANNUAL_COST_EMPLOYEE", cast=int, default="650000")
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/incident/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from dispatch.participant_role.models import ParticipantRoleType
from dispatch.plugin import service as plugin_service
from dispatch.tag import service as tag_service
from dispatch.tag.models import TagUpdate, TagCreate
from dispatch.tag.models import TagCreate
from dispatch.term import service as term_service
from dispatch.term.models import TermUpdate

Expand Down Expand Up @@ -239,7 +239,7 @@ def update(*, db_session, incident: Incident, incident_in: IncidentUpdate) -> In

tags = []
for t in incident_in.tags:
tags.append(tag_service.get_or_create(db_session=db_session, tag_in=TagUpdate(**t)))
tags.append(tag_service.get_or_create(db_session=db_session, tag_in=TagCreate(**t)))

terms = []
for t in incident_in.terms:
Expand Down
1 change: 0 additions & 1 deletion src/dispatch/service/service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Optional

from fastapi.encoders import jsonable_encoder
from dispatch.config import ONCALL_PLUGIN_SLUG

from dispatch.incident_priority import service as incident_priority_service
from dispatch.incident_type import service as incident_type_service
Expand Down
7 changes: 2 additions & 5 deletions src/dispatch/tag/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ def create(*, db_session, tag_in: TagCreate) -> Tag:
return tag


def get_or_create(*, db_session, tag_in) -> Tag:
if hasattr(tag_in, "id"):
q = db_session.query(Tag).filter(Tag.id == tag_in.id)
else:
q = db_session.query(Tag).filter_by(**tag_in.dict())
def get_or_create(*, db_session, tag_in: TagCreate) -> Tag:
q = db_session.query(Tag).filter_by(**tag_in.dict())

instance = q.first()
if instance:
Expand Down

0 comments on commit 605b519

Please sign in to comment.