Skip to content

Commit ba07cb4

Browse files
committed
fix(analytics): reversed scan_logs sort order so newest entries appear first
- inverted timestamp prefix so Firebase Console sorts newest-to-oldest - doc ID format: {inverted_timestamp}_{date}_{uid_prefix} - keeps ISO date in the ID for human readability
1 parent 25e132d commit ba07cb4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/stores/scores.svelte.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class ScoresStore {
160160
try {
161161
const user = authStore.user;
162162
const now = new Date();
163-
const docId = `${now.toISOString().replace(/[:.]/g, '-')}_${uid.slice(0, 6)}`;
163+
// inverted timestamp so newest logs sort first in Firebase Console
164+
const inverted = (9999999999999 - now.getTime()).toString().padStart(13, '0');
165+
const docId = `${inverted}_${now.toISOString().slice(0, 10)}_${uid.slice(0, 6)}`;
164166
await setDoc(doc(db, 'scan_logs', docId), {
165167
uid,
166168
email: user?.email ?? null,

0 commit comments

Comments
 (0)