Skip to content

Commit

Permalink
Resolve PEP-8 and mypy issues with SQLAlchemy boolean filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro committed Dec 4, 2023
1 parent 974e60d commit f3250fe
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/admin/dashboard_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from sqlalchemy.orm import Session
from sqlalchemy.sql import func, select
from sqlalchemy.sql.expression import and_, or_
from sqlalchemy.sql.expression import and_, false, or_, true

from api.admin.model.dashboard_statistics import (
CollectionInventory,
Expand Down Expand Up @@ -35,16 +35,16 @@ def generate_statistics(admin: Admin, db: Session) -> StatisticsResponse:


class Statistics:
METERED_LICENSE_FILTER = and_( # type: ignore[type-var]
METERED_LICENSE_FILTER = and_(
LicensePool.licenses_owned > 0,
LicensePool.unlimited_access == False,
LicensePool.open_access == False,
LicensePool.unlimited_access == false(),
LicensePool.open_access == false(),
)
UNLIMITED_LICENSE_FILTER = and_( # type: ignore[type-var]
LicensePool.unlimited_access == True,
LicensePool.open_access == False,
UNLIMITED_LICENSE_FILTER = and_(
LicensePool.unlimited_access == true(),
LicensePool.open_access == false(),
)
OPEN_ACCESS_FILTER = LicensePool.open_access == True
OPEN_ACCESS_FILTER = LicensePool.open_access == true()
AT_LEAST_ONE_LOANABLE_FILTER = or_(
UNLIMITED_LICENSE_FILTER,
OPEN_ACCESS_FILTER,
Expand Down Expand Up @@ -204,7 +204,7 @@ def _gather_patron_stats(self, library: Library) -> PatronStatistics:
)

def stats(self, admin: Admin) -> StatisticsResponse:
"""Build and return a statistics response for admin's authorized libraries."""
"""Build and return a statistics response for admin user's authorized libraries."""

# Determine which libraries and collections are authorized for this user.
authorized_libraries = self._libraries_for_admin(admin)
Expand Down

0 comments on commit f3250fe

Please sign in to comment.