Skip to content

Commit

Permalink
Check
Browse files Browse the repository at this point in the history
  • Loading branch information
michplunkett committed Jul 22, 2024
1 parent 2d2dcbd commit 2333bc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
7 changes: 4 additions & 3 deletions OpenOversight/app/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ def redirect_officer_profile(officer_id: int):
def officer_profile(officer_id: int):
form = AssignmentForm()
try:
officer = db.session.get(Officer, officer_id)
officer.incidents = sorted(
officer.incidents, key=lambda i: (i.date, i.time), reverse=True
officer = (
Officer.query.filter_by(id=officer_id)
.one()
.incidents.query.order_by(Incident.date.desc(), Incident.time.desc())
)
except NoResultFound:
abort(HTTPStatus.NOT_FOUND)
Expand Down
22 changes: 3 additions & 19 deletions OpenOversight/app/models/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import time
import uuid
from datetime import date, datetime
from decimal import Decimal
from typing import List, Optional

from authlib.jose import JoseError, JsonWebToken
Expand All @@ -14,7 +13,7 @@
from sqlalchemy import CheckConstraint, UniqueConstraint, func
from sqlalchemy.orm import DeclarativeMeta, declarative_mixin, declared_attr, validates
from sqlalchemy.sql import func as sql_func
from sqlalchemy.types import String, TypeDecorator
from sqlalchemy.types import Numeric
from werkzeug.security import check_password_hash, generate_password_hash

from OpenOversight.app.models.database_cache import (
Expand Down Expand Up @@ -350,21 +349,6 @@ def __repr__(self):
return f"<Officer ID {self.id}: {self.full_name()}>"


class Currency(TypeDecorator):
cache_ok = True
impl = String

def process_bind_param(self, value, dialect):
if value is not None:
return str(value)
return None

def process_result_value(self, value, dialect):
if value is not None:
return Decimal(value)
return None


class Salary(BaseModel, TrackUpdates):
__tablename__ = "salaries"

Expand All @@ -376,8 +360,8 @@ class Salary(BaseModel, TrackUpdates):
),
)
officer = db.relationship("Officer", back_populates="salaries")
salary = db.Column(Currency(), index=True, unique=False, nullable=False)
overtime_pay = db.Column(Currency(), index=True, unique=False, nullable=True)
salary = db.Column(db.Numeric(14, 2), index=True, unique=False, nullable=False)
overtime_pay = db.Column(Numeric(14, 2), index=True, unique=False, nullable=True)
year = db.Column(db.Integer, index=True, unique=False, nullable=False)
is_fiscal_year = db.Column(db.Boolean, index=False, unique=False, nullable=False)

Expand Down

0 comments on commit 2333bc6

Please sign in to comment.