@homie-rocks/studio 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/bin/homie-studio.mjs +26 -2
- package/lib/build.mjs +38 -12
- package/lib/look.mjs +101 -0
- package/lib/markdown.mjs +121 -0
- package/lib/scaffold.mjs +68 -5
- package/lib/site.mjs +437 -0
- package/lib/studio.mjs +1 -1
- package/package.json +3 -2
- package/site/SITE.md +128 -0
- package/worker/index.mjs +297 -143
- package/worker/pages.mjs +149 -212
- package/worker/room.mjs +28 -1
- package/worker/site.mjs +1052 -0
- package/worker/stats.mjs +8 -5
- package/worker/version.mjs +2 -0
package/worker/stats.mjs
CHANGED
|
@@ -284,19 +284,22 @@ export async function readStats(env, cat, { range, only = null, studios = new Se
|
|
|
284
284
|
},
|
|
285
285
|
crossings: { fromHub: byKind('hub'), fromStudios: byKind('studio'), fromSearch: byKind('search'), fromWeb: byKind('web'), fromLinks: byKind('link') },
|
|
286
286
|
// The studio's own pages: its home, and the /music/ and /videos/ lists (a catalogue's road).
|
|
287
|
-
pages:
|
|
287
|
+
pages: Object.fromEntries(['home', 'games', 'rooms', 'posts', 'music', 'videos'].map((p) => [p, sum((r) => r.metric === 'visit' && r.subject === p)])),
|
|
288
288
|
games: perGame, songs: media(songs, 'song', 'music'), videos: media(videos, 'video', 'videos'), referrers, days,
|
|
289
289
|
note: 'Counts, never people: a visit is a page a browser opened, a play is a Play press, a round is a finished round. Prefetches, crawlers and house QA are not counted. Times are UTC days.',
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
/**
|
|
294
|
-
|
|
293
|
+
/**
|
|
294
|
+
* What a studio that shares may tell the directory: Play presses and rounds with people in the last 7 days. With
|
|
295
|
+
* `game`, one game's (a landing shows them).
|
|
296
|
+
*/
|
|
297
|
+
export async function playedThisWeek(env, game = null) {
|
|
295
298
|
if (!env?.DB) return null;
|
|
296
299
|
const to = today();
|
|
297
300
|
try {
|
|
298
|
-
const row = await env.DB.prepare(
|
|
299
|
-
.bind(dayOffset(to, -6), to).first();
|
|
301
|
+
const row = await env.DB.prepare(`SELECT SUM(CASE WHEN metric = 'play' THEN n ELSE 0 END) AS plays, SUM(CASE WHEN metric = 'round' AND source = 'people' THEN n ELSE 0 END) AS rounds FROM stats_daily WHERE day >= ?1 AND day <= ?2 AND metric IN ('play', 'round')${game ? ' AND subject = ?3' : ''}`)
|
|
302
|
+
.bind(dayOffset(to, -6), to, ...(game ? [String(game)] : [])).first();
|
|
300
303
|
return { days: 7, plays: Number(row?.plays) || 0, rounds: Number(row?.rounds) || 0, to };
|
|
301
304
|
} catch { return null; }
|
|
302
305
|
}
|