mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
Merge branch 'master' into reset-password
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
from flask import current_app
|
||||
from app import db
|
||||
from app.models import Notification
|
||||
from app.models import Notification, Job
|
||||
from sqlalchemy import desc
|
||||
|
||||
|
||||
def dao_create_notification(notification):
|
||||
if notification.job_id:
|
||||
db.session.query(Job).filter_by(
|
||||
id=notification.job_id
|
||||
).update({Job.notifications_sent: Job.notifications_sent + 1})
|
||||
db.session.add(notification)
|
||||
db.session.commit()
|
||||
|
||||
@@ -19,12 +23,12 @@ def get_notification_for_job(service_id, job_id, notification_id):
|
||||
|
||||
|
||||
def get_notifications_for_job(service_id, job_id, page=1):
|
||||
query = Notification.query.filter_by(service_id=service_id, job_id=job_id)\
|
||||
.order_by(desc(Notification.created_at))\
|
||||
query = Notification.query.filter_by(service_id=service_id, job_id=job_id) \
|
||||
.order_by(desc(Notification.created_at)) \
|
||||
.paginate(
|
||||
page=page,
|
||||
per_page=current_app.config['PAGE_SIZE']
|
||||
)
|
||||
page=page,
|
||||
per_page=current_app.config['PAGE_SIZE']
|
||||
)
|
||||
return query
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user