-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: endpoints for UI main page stats (#69)
- Loading branch information
1 parent
0f1ff0a
commit 9749df1
Showing
9 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
services/explorer-api/src/database/controllers/l2TxEffect/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./get-tx-effect.js"; | ||
export * from "./stats.js"; |
13 changes: 13 additions & 0 deletions
13
services/explorer-api/src/database/controllers/l2TxEffect/stats.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { count } from "drizzle-orm"; | ||
import { getDb as db } from "../../../database/index.js"; | ||
import { txEffect } from "../../../database/schema/index.js"; | ||
|
||
export const getTotalTxEffects = async (): Promise<number> => { | ||
const dbRes = await db().select({ count: count() }).from(txEffect).execute(); | ||
return dbRes[0].count; | ||
}; | ||
|
||
export const getTotalTxEffectsLast24h = (): number => { | ||
// TODO: we need l2Block.header.globalVariables.timestamp as number to sum this | ||
return -1; | ||
} |
1 change: 1 addition & 0 deletions
1
services/explorer-api/src/database/controllers/l2block/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./get-latest.js"; | ||
export * from "./get-block.js"; | ||
export * from "./store.js"; | ||
export * from "./stats.js"; |
14 changes: 14 additions & 0 deletions
14
services/explorer-api/src/database/controllers/l2block/stats.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// import { getDb as db } from "../../../database/index.js"; | ||
// import { l2Block } from "../../../database/schema/index.js"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export const getAverageFees = async (): Promise<number> => { | ||
// TODO: we need l2Block.header.totalFees as number to average this | ||
return -1; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export const getAverageBlockTime = async (): Promise<number> => { | ||
// TODO: we need l2Block.header.globalVariables.timestamp as number to average this | ||
return -1; | ||
}; |
1 change: 1 addition & 0 deletions
1
services/explorer-api/src/database/controllers/l2contract/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./get-contract-instance.js"; | ||
export * from "./get-contract-instances.js"; | ||
export * from "./store.js"; | ||
export * from "./stats.js"; |
8 changes: 8 additions & 0 deletions
8
services/explorer-api/src/database/controllers/l2contract/stats.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { count } from "drizzle-orm"; | ||
import { getDb as db } from "../../../database/index.js"; | ||
import { l2ContractClassRegistered } from "../../../database/schema/index.js"; | ||
|
||
export const getTotalContracts = async (): Promise<number> => { | ||
const dbRes = await db().select({ count: count() }).from(l2ContractClassRegistered).execute(); | ||
return dbRes[0].count; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters