Skip to content

Commit

Permalink
Code Review Feedback
Browse files Browse the repository at this point in the history
* Use constant for 2024
  • Loading branch information
dhaselhan committed Jan 6, 2025
1 parent 2d106d5 commit 57021b8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion backend/lcfs/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class LCFS_Constants:
]
TRANSACTIONS_EXPORT_SHEETNAME = "Transactions"
TRANSACTIONS_EXPORT_FILENAME = "BC-LCFS-transactions"
LEGISLATION_TRANSITION_YEAR = "2024"


class FILE_MEDIA_TYPE(Enum):
Expand Down Expand Up @@ -93,5 +94,5 @@ class FILE_MEDIA_TYPE(Enum):
"HDRD",
"Other diesel",
"Alternative jet fuel",
"Other"
"Other",
]
4 changes: 3 additions & 1 deletion backend/lcfs/web/api/allocation_agreement/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from lcfs.db.models.fuel.FuelCode import FuelCode

from lcfs.db.models.fuel.FuelType import QuantityUnitsEnum
from lcfs.utils.constants import LCFS_Constants
from lcfs.web.api.fuel_code.repo import FuelCodeRepository
from lcfs.web.api.allocation_agreement.schema import AllocationAgreementSchema
from lcfs.web.api.base import PaginationRequestSchema
Expand All @@ -38,7 +39,8 @@ async def get_table_options(self, compliance_period: str) -> dict:
"""Get all table options"""
fuel_categories = await self.fuel_code_repo.get_fuel_categories()
fuel_types = await self.fuel_code_repo.get_formatted_fuel_types(
include_legacy=compliance_period < "2024"
include_legacy=compliance_period
< LCFS_Constants.LEGISLATION_TRANSITION_YEAR
)
units_of_measure = [unit.value for unit in QuantityUnitsEnum]
allocation_transaction_types = (
Expand Down
3 changes: 2 additions & 1 deletion backend/lcfs/web/api/fuel_export/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)
from lcfs.db.base import UserTypeEnum, ActionTypeEnum
from lcfs.db.models.compliance.ComplianceReport import ComplianceReport
from lcfs.utils.constants import LCFS_Constants
from lcfs.web.api.base import PaginationRequestSchema
from sqlalchemy import and_, or_, select, func, delete
from sqlalchemy.orm import joinedload, selectinload
Expand Down Expand Up @@ -164,7 +165,7 @@ async def get_fuel_export_table_options(self, compliance_period: str):
)
)

include_legacy = compliance_period < "2024"
include_legacy = compliance_period < LCFS_Constants.LEGISLATION_TRANSITION_YEAR
if not include_legacy:
query = query.where(FuelType.is_legacy == False)

Expand Down
5 changes: 3 additions & 2 deletions backend/lcfs/web/api/fuel_supply/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
UnitOfMeasure,
EndUseType,
)
from lcfs.utils.constants import LCFS_Constants
from lcfs.web.api.base import PaginationRequestSchema
from lcfs.web.api.fuel_supply.schema import FuelSupplyCreateUpdateSchema
from lcfs.web.core.decorators import repo_handler
Expand Down Expand Up @@ -184,7 +185,7 @@ async def get_fuel_supply_table_options(self, compliance_period: str):
)
)

include_legacy = compliance_period < "2024"
include_legacy = compliance_period < LCFS_Constants.LEGISLATION_TRANSITION_YEAR
if not include_legacy:
query.where(FuelType.is_legacy == False)

Expand Down Expand Up @@ -474,7 +475,7 @@ async def get_effective_fuel_supplies(
FuelSupply.version == valid_fuel_supplies_subq.c.max_version,
user_type_priority == valid_fuel_supplies_subq.c.max_role_priority,
),
isouter=False # Explicit inner join
isouter=False, # Explicit inner join
)
.order_by(FuelSupply.create_date.asc())
)
Expand Down
4 changes: 3 additions & 1 deletion backend/lcfs/web/api/other_uses/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from lcfs.db.models.fuel.FuelCode import FuelCode
from lcfs.db.models.fuel.FuelType import FuelType, QuantityUnitsEnum
from lcfs.db.models.fuel.FuelInstance import FuelInstance
from lcfs.utils.constants import LCFS_Constants
from lcfs.web.api.fuel_code.repo import FuelCodeRepository
from lcfs.web.api.other_uses.schema import OtherUsesSchema
from lcfs.web.api.base import PaginationRequestSchema
Expand All @@ -39,7 +40,8 @@ async def get_table_options(self, compliance_period: str) -> dict:
"""Get all table options"""
fuel_categories = await self.fuel_code_repo.get_fuel_categories()
fuel_types = await self.get_formatted_fuel_types(
include_legacy=compliance_period < "2024"
include_legacy=compliance_period
< LCFS_Constants.LEGISLATION_TRANSITION_YEAR
)
expected_uses = await self.fuel_code_repo.get_expected_use_types()
units_of_measure = [unit.value for unit in QuantityUnitsEnum]
Expand Down

0 comments on commit 57021b8

Please sign in to comment.