mirror of
https://github.com/djdevin/recflare.git
synced 2026-10-26 15:38:52 -07:00
[www] token drop functionality
This commit is contained in:
@@ -238,6 +238,25 @@ export async function getPlayerIdsInRoom(
|
||||
return results.map((r) => r.accountId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Everyone online right now, anywhere — the same population {@link countOnlinePlayers}
|
||||
* counts, as ids. Unexpired presence only, one row per account, lobby (null-instance)
|
||||
* presence included: a player sat in a menu is as online as one in a room, and a gift to
|
||||
* "everyone online" that skipped them would look to them like being skipped on purpose.
|
||||
* Ordered so a pass over it is deterministic.
|
||||
*/
|
||||
export async function getOnlinePlayerIds(db: D1Database, now = nowSeconds()): Promise<number[]> {
|
||||
const { results } = await db
|
||||
.prepare(
|
||||
`SELECT DISTINCT account_id AS accountId FROM presence
|
||||
WHERE expires_at > ?1
|
||||
ORDER BY account_id`
|
||||
)
|
||||
.bind(now)
|
||||
.all<{ accountId: number }>()
|
||||
return results.map((r) => r.accountId)
|
||||
}
|
||||
|
||||
/**
|
||||
* How many players are online right now, anywhere — one row per account, so this is
|
||||
* the player count a status page means. Counts unexpired presence only: rows outlive
|
||||
|
||||
Reference in New Issue
Block a user