MCPcopy Index your code
hub / github.com/cameri/nostream / getEventCount

Function getEventCount

src/cli/commands/info.ts:26–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26const getEventCount = async (): Promise<number | null> => {
27 const db = knex({
28 client: 'pg',
29 connection: process.env.DB_URI
30 ? process.env.DB_URI
31 : {
32 host: process.env.DB_HOST,
33 port: Number(process.env.DB_PORT),
34 user: process.env.DB_USER,
35 password: process.env.DB_PASSWORD,
36 database: process.env.DB_NAME,
37 },
38 pool: {
39 min: 0,
40 max: 1,
41 idleTimeoutMillis: 1000,
42 acquireTimeoutMillis: 1000,
43 propagateCreateError: false,
44 },
45 acquireConnectionTimeout: 1000,
46 } as any)
47
48 try {
49 const result = await db('events').whereNull('deleted_at').count<{ count: string | number }>('* as count').first()
50 return Number(result?.count ?? 0)
51 } catch {
52 return null
53 } finally {
54 await db.destroy()
55 }
56}
57
58const getRelayUptimeSeconds = async (): Promise<number | null> => {
59 const idResult = await runCommandWithOutput('docker', ['compose', 'ps', '-q', 'nostream'], { timeoutMs: 1000 })

Callers 1

getInfoPayloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected