Compare commits
2 Commits
a184909957
...
a1495ff23f
| Author | SHA1 | Date | |
|---|---|---|---|
| a1495ff23f | |||
| 4dad370e66 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -59,3 +59,5 @@ result
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.venv/
|
||||
|
||||
.env.phaseflow
|
||||
|
||||
@@ -206,12 +206,12 @@ export async function POST(request: Request) {
|
||||
user.activeOverrides,
|
||||
);
|
||||
|
||||
// Create DailyLog entry
|
||||
// Upsert DailyLog entry - update existing record for today or create new one
|
||||
// Store default value 100 for body battery when Garmin returns null.
|
||||
// This prevents PocketBase's number field null-to-0 coercion from
|
||||
// causing the dashboard to display 0 instead of a meaningful value.
|
||||
// Use YYYY-MM-DD format for PocketBase date field compatibility
|
||||
await pb.collection("dailyLogs").create({
|
||||
const dailyLogData = {
|
||||
user: user.id,
|
||||
date: today,
|
||||
cycleDay,
|
||||
@@ -225,7 +225,18 @@ export async function POST(request: Request) {
|
||||
trainingDecision: decision.status,
|
||||
decisionReason: decision.reason,
|
||||
notificationSentAt: null,
|
||||
});
|
||||
};
|
||||
|
||||
// Check if record already exists for this user today
|
||||
try {
|
||||
const existing = await pb
|
||||
.collection("dailyLogs")
|
||||
.getFirstListItem(`user="${user.id}" && date="${today}"`);
|
||||
await pb.collection("dailyLogs").update(existing.id, dailyLogData);
|
||||
} catch {
|
||||
// No existing record - create new one
|
||||
await pb.collection("dailyLogs").create(dailyLogData);
|
||||
}
|
||||
|
||||
// Log sync complete with metrics
|
||||
const userSyncDuration = Date.now() - userSyncStartTime;
|
||||
|
||||
Reference in New Issue
Block a user