Skip to content

Commit

Permalink
Billing Enums & Filter fixes (#663)
Browse files Browse the repository at this point in the history
* Fixing Billing Enum imports.

* Adding missing Billing Filter for day for gcp_billing_daily_cost table.
  • Loading branch information
milo-hyben authored Jan 25, 2024
1 parent 11002af commit e63bda6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/routes/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from api.settings import BILLING_CACHE_RESPONSE_TTL, BQ_AGGREG_VIEW
from api.utils.db import BqConnection, get_author
from db.python.layers.billing import BillingLayer
from models.enums import BillingSource
from models.models import (
BillingColumn,
BillingCostBudgetRecord,
BillingHailBatchCostRecord,
BillingSource,
BillingTotalCostQueryModel,
BillingTotalCostRecord,
)
Expand Down
4 changes: 1 addition & 3 deletions db/python/layers/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
from db.python.tables.bq.billing_daily_extended import BillingDailyExtendedTable
from db.python.tables.bq.billing_gcp_daily import BillingGcpDailyTable
from db.python.tables.bq.billing_raw import BillingRawTable
from models.enums import BillingSource, BillingTimeColumn, BillingTimePeriods
from models.models import (
BillingColumn,
BillingCostBudgetRecord,
BillingHailBatchCostRecord,
BillingSource,
BillingTimeColumn,
BillingTimePeriods,
BillingTotalCostQueryModel,
)

Expand Down
2 changes: 1 addition & 1 deletion db/python/tables/bq/billing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from db.python.tables.bq.billing_filter import BillingFilter
from db.python.tables.bq.function_bq_filter import FunctionBQFilter
from db.python.tables.bq.generic_bq_filter import GenericBQFilter
from models.enums import BillingTimePeriods
from models.models import (
BillingColumn,
BillingCostBudgetRecord,
BillingCostDetailsRecord,
BillingTimePeriods,
BillingTotalCostQueryModel,
)

Expand Down
9 changes: 9 additions & 0 deletions db/python/tables/bq/billing_gcp_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def _query_to_partitioned_filter(
if query.end_date
else None,
)
# add day filter after partition filter is applied
billing_filter.day = GenericBQFilter[datetime](
gte=datetime.strptime(query.start_date, '%Y-%m-%d')
if query.start_date
else None,
lte=datetime.strptime(query.end_date, '%Y-%m-%d')
if query.end_date
else None,
)
return billing_filter

async def _last_loaded_day(self):
Expand Down
1 change: 1 addition & 0 deletions models/enums/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from models.enums.analysis import AnalysisStatus
from models.enums.billing import BillingSource, BillingTimeColumn, BillingTimePeriods
from models.enums.search import SearchResponseType
from models.enums.web import MetaSearchEntityPrefix
3 changes: 0 additions & 3 deletions models/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
BillingCostDetailsRecord,
BillingHailBatchCostRecord,
BillingInternal,
BillingSource,
BillingTimeColumn,
BillingTimePeriods,
BillingTotalCostQueryModel,
BillingTotalCostRecord,
)
Expand Down

0 comments on commit e63bda6

Please sign in to comment.