-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add blocks and tx count to slot feed (#1346)
* feat: add Slot Analytics influx * fix: add slot stats to landing page + update useEpochStats + fix burnedManaCache * fix: display 0 if stat undefined * fix: burned mana cell * fix: change no_payload_count to validation_count * hotfix: slots feed links not absolute --------- Co-authored-by: Begoña Alvarez <[email protected]>
- Loading branch information
1 parent
2b2b647
commit 2c4836c
Showing
16 changed files
with
332 additions
and
29 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
api/src/models/api/nova/stats/slot/ISlotAnalyticStatsRequest.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,11 @@ | ||
export interface ISlotAnalyticStatsRequest { | ||
/** | ||
* The network to search on. | ||
*/ | ||
network: string; | ||
|
||
/** | ||
* The slot index to get the stats for. | ||
*/ | ||
slotIndex: string; | ||
} |
12 changes: 12 additions & 0 deletions
12
api/src/models/api/nova/stats/slot/ISlotAnalyticStatsResponse.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,12 @@ | ||
import { IResponse } from "../../IResponse"; | ||
|
||
export interface ISlotAnalyticStatsResponse extends IResponse { | ||
slotIndex?: number; | ||
blockCount?: number; | ||
perPayloadType?: { | ||
transaction?: number; | ||
candidacy?: number; | ||
taggedData?: number; | ||
noPayload?: number; | ||
}; | ||
} |
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
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,42 @@ | ||
import { ServiceFactory } from "../../../../../factories/serviceFactory"; | ||
import { ISlotAnalyticStatsRequest } from "../../../../../models/api/nova/stats/slot/ISlotAnalyticStatsRequest"; | ||
import { ISlotAnalyticStatsResponse } from "../../../../../models/api/nova/stats/slot/ISlotAnalyticStatsResponse"; | ||
import { IConfiguration } from "../../../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../../../services/networkService"; | ||
import { InfluxServiceNova } from "../../../../../services/nova/influx/influxServiceNova"; | ||
import { ValidationHelper } from "../../../../../utils/validationHelper"; | ||
|
||
/** | ||
* Fetch the slot stats from influx nova. | ||
* @param _ The configuration. | ||
* @param request The request. | ||
* @returns The response. | ||
*/ | ||
export async function get(_: IConfiguration, request: ISlotAnalyticStatsRequest): Promise<ISlotAnalyticStatsResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
ValidationHelper.numberFromString(request.slotIndex, "slotIndex"); | ||
|
||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return {}; | ||
} | ||
|
||
const influxService = ServiceFactory.get<InfluxServiceNova>(`influxdb-${networkConfig.network}`); | ||
|
||
if (influxService) { | ||
const slotIndex = Number.parseInt(request.slotIndex, 10); | ||
const slotStats = await influxService.getSlotAnalyticStats(slotIndex); | ||
|
||
if (slotStats) { | ||
return slotStats; | ||
} | ||
|
||
return { error: `Could not fetch stats for slot ${request.slotIndex}` }; | ||
} | ||
|
||
return { error: "Influx service not found for this network." }; | ||
} |
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
Oops, something went wrong.