Skip to content

Commit

Permalink
meh, lets leave that for another time
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels committed Sep 28, 2021
1 parent 3b72c91 commit bc8ac8b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 54 deletions.
3 changes: 1 addition & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ def register_blueprint(application):
letter_branding_blueprint.before_request(requires_admin_auth)
application.register_blueprint(letter_branding_blueprint)

# support_blueprint.before_request(requires_admin_auth)
support_blueprint.before_request(requires_no_auth)
support_blueprint.before_request(requires_admin_auth)
application.register_blueprint(support_blueprint, url_prefix="/support")


Expand Down
12 changes: 0 additions & 12 deletions app/dao/notifications_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,6 @@ def get_notification_by_id(notification_id, service_id=None, _raise=False):
return query.one() if _raise else query.first()


@statsd(namespace="dao")
def get_notification_history_by_id(notification_history_id, service_id=None, _raise=False):
filters = [NotificationHistory.id == notification_history_id]

if service_id:
filters.append(NotificationHistory.service_id == service_id)

query = db.on_reader().query(NotificationHistory).filter(*filters)

return query.one() if _raise else query.first()


def get_notifications(filter_dict=None):
return _filter_query(Notification.query, filter_dict=filter_dict)

Expand Down
57 changes: 17 additions & 40 deletions app/support/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
from sqlalchemy.orm.exc import NoResultFound

from app.dao.jobs_dao import dao_get_job_by_id
from app.dao.notifications_dao import get_notification_by_id, get_notification_history_by_id
from app.dao.notifications_dao import get_notification_by_id
from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id
from app.dao.users_dao import get_user_by_id
from app.errors import register_errors
from flask import current_app

support_blueprint = Blueprint("support", __name__)
register_errors(support_blueprint)
Expand Down Expand Up @@ -35,33 +34,10 @@ def notification_query(id):
pass


def notification_history_query(id):
try:
notification = get_notification_history_by_id(id)
if notification:
return {
"type": "notification_history",
"id": notification.id,
"notification_type": notification.notification_type,
"status": notification.status,
"created_at": notification.created_at,
"sent_at": notification.sent_at,
"to": "expired",
"service_id": notification.service_id,
"service_name": notification.service.name,
"job_id": notification.job_id,
"job_row_number": notification.job_row_number,
"api_key_id": notification.api_key_id,
}
except NoResultFound:
pass


def template_query(id):
try:
template = dao_get_template_by_id(id)
if template:

return {
"type": "template",
"id": template.id,
Expand All @@ -85,20 +61,21 @@ def service_query(id):
def job_query(id):
try:
job = dao_get_job_by_id(id)
return {
"type": "job",
"id": job.id,
"original_file_name": job.original_file_name,
"created_at": job.created_at,
"created_by_id": job.created_by_id,
"created_by_name": job.created_by.name,
"processing_started": job.processing_started,
"processing_finished": job.processing_finished,
"notification_count": job.notification_count,
"job_status": job.job_status,
"service_id": job.service_id,
"service_name": job.service.name,
}
if job:
return {
"type": "job",
"id": job.id,
"original_file_name": job.original_file_name,
"created_at": job.created_at,
"created_by_id": job.created_by_id,
"created_by_name": job.created_by.name,
"processing_started": job.processing_started,
"processing_finished": job.processing_finished,
"notification_count": job.notification_count,
"job_status": job.job_status,
"service_id": job.service_id,
"service_name": job.service.name,
}
except NoResultFound:
pass

Expand All @@ -120,7 +97,7 @@ def user_query(id):
@support_blueprint.route("/<uuid:id>", methods=["GET"])
def get_id_info(id):

for query_func in [user_query, service_query, template_query, job_query, notification_query, notification_history_query]:
for query_func in [user_query, service_query, template_query, job_query, notification_query]:
results = query_func(id)
if results:
return jsonify(results)
Expand Down

0 comments on commit bc8ac8b

Please sign in to comment.