"""StatementPeriod Model. It is a READ ONLY model for accessing data. The real business logic lives in the ows-royalties repository. """ from abacus_common_logic.connectors.database import db from sqlalchemy import select from sqlalchemy.sql import literal_column, table class StatementPeriod: """StatementPeriod Model.""" @classmethod def get_statement_periods(cls, years: list) -> list: """Get a list of statement periods by statement years. Args: years (list): a list of statement years Returns: a list of statement periods """ statement_period_query = ( select([literal_column('sp.*')]) .where(literal_column('sp.statement_year').in_(years)) .select_from(table('statement_period').alias('sp')) ) return db.session.execute(statement_period_query).fetchall()