Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion stats/bin/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
migrateEvaluateDB,
migrateStatsDB
} from '@filecoin-station/spark-stats-db'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please undo this change to keep the diff clean

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, noted

const pgPools = await getPgPools()
await migrateStatsDB(pgPools.stats)
await migrateEvaluateDB(pgPools.evaluate)
2 changes: 1 addition & 1 deletion stats/lib/platform-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ export const addPlatformRoutes = (app) => {

app.get('/participants/summary', async (request, reply) => {
reply.header('cache-control', `public, max-age=${24 * 3600 /* one day */}`)
reply.send(await fetchParticipantsSummary(request.server.pg.evaluate))
reply.send(await fetchParticipantsSummary(request.server.pg))
})
}
4 changes: 2 additions & 2 deletions stats/lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export const addRoutes = (app, SPARK_API_BASE_URL) => {
reply.send(await fetchDailyClientRSRSummary(request.server.pg, request.filter, request.params.clientId))
})
app.get('/allocators/retrieval-success-rate/summary', async (/** @type {RequestWithFilter} */ request, reply) => {
reply.send(await fetchAllocatorsRSRSummary(pgPools, request.filter))
reply.send(await fetchAllocatorsRSRSummary(request.server.pg, request.filter))
})
app.get('/allocator/:allocatorId/retrieval-success-rate/summary', async (/** @type {RequestWithFilterAndClientId} */ request, reply) => {
reply.send(await fetchDailyAllocatorRSRSummary(pgPools, request.filter, request.params.allocatorId))
reply.send(await fetchDailyAllocatorRSRSummary(request.server.pg, request.filter, request.params.allocatorId))
})
})

Expand Down
12 changes: 6 additions & 6 deletions stats/lib/stats-fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ export const fetchDailyClientRSRSummary = async (pg, { from, to }, clientId) =>

/**
* Fetches the retrieval stats summary for all allocators for given date range.
* @param {PgPools} pgPools
* @param {FastifyPg} pg - Fastify pg object with database connections
* @param {import('./typings.js').DateRangeFilter} filter
*/
export const fetchAllocatorsRSRSummary = async (pgPools, filter) => {
const { rows } = await pgPools.evaluate.query(`
export const fetchAllocatorsRSRSummary = async (pg, filter) => {
const { rows } = await pg.evaluate.query(`
SELECT
allocator_id,
SUM(total) as total,
Expand Down Expand Up @@ -472,12 +472,12 @@ export const fetchAllocatorsRSRSummary = async (pgPools, filter) => {

/**
* Fetches the retrieval stats summary for a single allocator for given date range.
* @param {PgPools} pgPools
* @param {FastifyPg} pg - Fastify pg object with database connections
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the name pgPools to keep the diff smaller?

Suggested change
* @param {FastifyPg} pg - Fastify pg object with database connections
* @param {FastifyPg} pgPools - Fastify pg object with database connections

Same comment applies to all other similar places too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, noted

* @param {import('./typings.js').DateRangeFilter} filter
* @param {string} allocatorId
*/
export const fetchDailyAllocatorRSRSummary = async (pgPools, { from, to }, allocatorId) => {
const { rows } = await pgPools.evaluate.query(`
export const fetchDailyAllocatorRSRSummary = async (pg, { from, to }, allocatorId) => {
const { rows } = await pg.evaluate.query(`
SELECT
day::TEXT,
SUM(total) as total, SUM(successful) as successful,
Expand Down
2 changes: 1 addition & 1 deletion stats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@fastify/cors": "^11.0.1",
"@fastify/url-data": "^6.0.3",
"@fastify/postgres": "^5.2.0",
"@fastify/postgres": "^6.0.2",
"@filecoin-station/spark-stats-db": "^1.0.0",
"@sentry/node": "^9.10.0",
"@sentry/profiling-node": "^9.10.0",
Expand Down
Loading
Loading