mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
Added a new rates table.
We only need one rate per channel. This reflects that. The provider_rates has been left for now, it is still not being used. New dao has been added to select the right rate for the given notification_type and date of notificaiton.
This commit is contained in:
11
app/dao/rates_dao.py
Normal file
11
app/dao/rates_dao.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from sqlalchemy import desc
|
||||
|
||||
from app import db
|
||||
from app.models import Rates
|
||||
|
||||
|
||||
def get_rate_for_type_and_date(notification_type, date_sent):
|
||||
return db.session.query(Rates).filter(Rates.notification_type == notification_type,
|
||||
Rates.valid_from <= date_sent
|
||||
).order_by(Rates.valid_from.desc()
|
||||
).limit(1).first()
|
||||
@@ -944,3 +944,12 @@ class Event(db.Model):
|
||||
nullable=False,
|
||||
default=datetime.datetime.utcnow)
|
||||
data = db.Column(JSON, nullable=False)
|
||||
|
||||
|
||||
class Rates(db.Model):
|
||||
__tablename__ = 'rates'
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
valid_from = db.Column(db.DateTime, nullable=False)
|
||||
rate = db.Column(db.Numeric(), nullable=False)
|
||||
notification_type = db.Column(notification_types, index=True, nullable=False)
|
||||
|
||||
Reference in New Issue
Block a user