CQ fixes
This commit is contained in:
@@ -3,7 +3,7 @@ name: Refresh Showcase Data
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# Run daily at 3 AM UTC
|
# Run daily at 3 AM UTC
|
||||||
- cron: '0 3 * * *'
|
- cron: "0 3 * * *"
|
||||||
workflow_dispatch: # Allow manual triggering
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -71,3 +71,7 @@ markers = [
|
|||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
module = "redis.*"
|
module = "redis.*"
|
||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
|
|
||||||
|
[[tool.mypy.overrides]]
|
||||||
|
module = "showcase_data_definitions.*"
|
||||||
|
ignore_missing_imports = true
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Seed test data into the database for demo purposes."""
|
"""Seed test data into the database for demo purposes."""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@@ -96,14 +95,18 @@ def seed_database(reference_time: datetime | None = None) -> None:
|
|||||||
|
|
||||||
if child_id is None:
|
if child_id is None:
|
||||||
# Create new child
|
# Create new child
|
||||||
child_id = child_repo.create(
|
created_child = child_repo.create(
|
||||||
name=child_data["name"],
|
name=child_data["name"],
|
||||||
birth_time=child_data["birth_time"],
|
birth_time=child_data["birth_time"],
|
||||||
birth_weight=child_data["birth_weight"],
|
birth_weight=child_data["birth_weight"],
|
||||||
user_id=user_ids[0],
|
user_id=user_ids[0],
|
||||||
)
|
)
|
||||||
|
child_id = created_child["id"]
|
||||||
print(f"✓ Created child '{child_data['name']}'")
|
print(f"✓ Created child '{child_data['name']}'")
|
||||||
|
|
||||||
|
# Ensure child_id is set
|
||||||
|
assert child_id is not None, "Child ID must be set at this point"
|
||||||
|
|
||||||
# Share child with second user if not already shared
|
# Share child with second user if not already shared
|
||||||
parent_ids = child_repo.get_parent_ids(child_id)
|
parent_ids = child_repo.get_parent_ids(child_id)
|
||||||
if user_ids[1] not in parent_ids:
|
if user_ids[1] not in parent_ids:
|
||||||
@@ -111,9 +114,6 @@ def seed_database(reference_time: datetime | None = None) -> None:
|
|||||||
msg = f"✓ Shared child with '{test_data['users'][1]['username']}'"
|
msg = f"✓ Shared child with '{test_data['users'][1]['username']}'"
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
# Ensure child_id is set
|
|
||||||
assert child_id is not None, "Child ID must be set at this point"
|
|
||||||
|
|
||||||
# Clear existing logs to avoid duplicates
|
# Clear existing logs to avoid duplicates
|
||||||
print("Clearing existing logs...")
|
print("Clearing existing logs...")
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"""Definition of showcase data to be used for presenting the app."""
|
"""Definition of showcase data to be used for presenting the app."""
|
||||||
|
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import random
|
import random
|
||||||
|
|
||||||
@@ -69,18 +68,18 @@ def get_feeding_schedule(reference_time: datetime) -> list[dict]:
|
|||||||
start_time = current_time
|
start_time = current_time
|
||||||
end_time_feeding = start_time + timedelta(minutes=duration_minutes)
|
end_time_feeding = start_time + timedelta(minutes=duration_minutes)
|
||||||
|
|
||||||
feedings.append({
|
feedings.append(
|
||||||
|
{
|
||||||
"start_time": start_time,
|
"start_time": start_time,
|
||||||
"end_time": end_time_feeding,
|
"end_time": end_time_feeding,
|
||||||
"feeding_type": feeding_type,
|
"feeding_type": feeding_type,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
current_time += timedelta(hours=interval_hours)
|
current_time += timedelta(hours=interval_hours)
|
||||||
|
|
||||||
# Move to next day
|
# Move to next day
|
||||||
prev_date = (
|
prev_date = (current_time - timedelta(hours=interval_hours)).date()
|
||||||
current_time - timedelta(hours=interval_hours)
|
|
||||||
).date()
|
|
||||||
if current_time.date() != prev_date:
|
if current_time.date() != prev_date:
|
||||||
day_number += 1
|
day_number += 1
|
||||||
|
|
||||||
@@ -114,9 +113,7 @@ def get_diaper_changes(reference_time: datetime) -> list[dict]:
|
|||||||
changes_per_day = random.randint(6, 8)
|
changes_per_day = random.randint(6, 8)
|
||||||
|
|
||||||
# Distribute changes throughout the day
|
# Distribute changes throughout the day
|
||||||
day_start = current_time.replace(
|
day_start = current_time.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
hour=0, minute=0, second=0, microsecond=0
|
|
||||||
)
|
|
||||||
day_end = day_start + timedelta(days=1)
|
day_end = day_start + timedelta(days=1)
|
||||||
|
|
||||||
for _ in range(changes_per_day):
|
for _ in range(changes_per_day):
|
||||||
@@ -188,8 +185,10 @@ def get_diaper_changes(reference_time: datetime) -> list[dict]:
|
|||||||
day_number += 1
|
day_number += 1
|
||||||
current_time = day_end
|
current_time = day_end
|
||||||
|
|
||||||
# Sort by time
|
# Sort by time (type: ignore for mypy - we know time is datetime)
|
||||||
diapers.sort(key=lambda x: x["time"])
|
diapers.sort(
|
||||||
|
key=lambda x: x["time"] # type: ignore[arg-type,return-value]
|
||||||
|
)
|
||||||
return diapers
|
return diapers
|
||||||
|
|
||||||
|
|
||||||
@@ -224,10 +223,7 @@ def get_sleep_sessions(reference_time: datetime) -> list[dict]:
|
|||||||
sleep_duration_range = (60, 240)
|
sleep_duration_range = (60, 240)
|
||||||
|
|
||||||
# Random wake time with variation
|
# Random wake time with variation
|
||||||
wake_minutes = random.randint(
|
wake_minutes = random.randint(int(avg_wake_time * 45), int(avg_wake_time * 75))
|
||||||
int(avg_wake_time * 45),
|
|
||||||
int(avg_wake_time * 75)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Sleep start time
|
# Sleep start time
|
||||||
start_time = current_time + timedelta(minutes=wake_minutes)
|
start_time = current_time + timedelta(minutes=wake_minutes)
|
||||||
@@ -244,10 +240,12 @@ def get_sleep_sessions(reference_time: datetime) -> list[dict]:
|
|||||||
|
|
||||||
end_time_sleep = start_time + timedelta(minutes=duration_minutes)
|
end_time_sleep = start_time + timedelta(minutes=duration_minutes)
|
||||||
|
|
||||||
sleep_sessions.append({
|
sleep_sessions.append(
|
||||||
|
{
|
||||||
"start_time": start_time,
|
"start_time": start_time,
|
||||||
"end_time": end_time_sleep,
|
"end_time": end_time_sleep,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
current_time = end_time_sleep
|
current_time = end_time_sleep
|
||||||
birth_time = reference_time - timedelta(days=CHILD_AGE_DAYS)
|
birth_time = reference_time - timedelta(days=CHILD_AGE_DAYS)
|
||||||
@@ -278,4 +276,3 @@ def generate_showcase_data(reference_time: datetime | None = None) -> dict:
|
|||||||
"sleep": get_sleep_sessions(reference_time),
|
"sleep": get_sleep_sessions(reference_time),
|
||||||
"reference_time": reference_time,
|
"reference_time": reference_time,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user