Skip to content

Commit

Permalink
Run ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Jun 20, 2024
1 parent bbb84a9 commit 60af3be
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions posthog/management/commands/backfill_sessions_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def source_column(column_name: str) -> str:
igshid_property = source_column("igshid")
ttclid_property = source_column("ttclid")

def select_query(select_date: Optional[datetime] = None, team_id = None) -> str:
def select_query(select_date: Optional[datetime] = None, team_id=None) -> str:
if select_date:
where = f"toStartOfDay(timestamp) = '{select_date.strftime('%Y-%m-%d')}'"
else:
Expand Down Expand Up @@ -134,7 +134,9 @@ def select_query(select_date: Optional[datetime] = None, team_id = None) -> str:
for i in range(num_days):
date = self.start_date + timedelta(days=i)
logging.info("Writing the sessions for day %s", date.strftime("%Y-%m-%d"))
insert_query = f"""INSERT INTO writable_sessions {select_query(select_date=date)} SETTINGS max_execution_time=3600"""
insert_query = (
f"""INSERT INTO writable_sessions {select_query(select_date=date)} SETTINGS max_execution_time=3600"""
)
sync_execute(
query=insert_query,
workload=Workload.OFFLINE if self.use_offline_workload else Workload.DEFAULT,
Expand Down Expand Up @@ -167,9 +169,7 @@ def add_arguments(self, parser):
parser.add_argument(
"--print-counts", action="store_true", help="print events and session count beforehand and afterwards"
)
parser.add_argument(
"--team-id", type=int, help="Team id (will do all teams if not set)"
)
parser.add_argument("--team-id", type=int, help="Team id (will do all teams if not set)")

def handle(
self,
Expand All @@ -188,5 +188,6 @@ def handle(
end_datetime = datetime.strptime(end_date, "%Y-%m-%d")

BackfillQuery(start_datetime, end_datetime, use_offline_workload, team_id=team_id).execute(
dry_run=not live_run, print_counts=print_counts,
dry_run=not live_run,
print_counts=print_counts,
)

0 comments on commit 60af3be

Please sign in to comment.