Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add daily statistics charts #1280

Merged
merged 30 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5073c25
feat: add tokens held daily by output type chart
brancoder Mar 8, 2024
abb0356
feat: add addresses with balance chart
brancoder Mar 8, 2024
2da5293
feat: add daily active addresses
brancoder Mar 8, 2024
dbcef2a
feat: add daily sent tokens chart
brancoder Mar 8, 2024
c564d3b
feat: add anchor activity daily chart
brancoder Mar 8, 2024
970471d
feat: add nft activity daily chart
brancoder Mar 8, 2024
9f42a20
Merge branch 'dev' into feat/add-daily-statistics
brancoder Mar 8, 2024
644088d
feat: add Account daily activity chart
brancoder Mar 8, 2024
e59fe24
feat: add foundry daily activity chart
brancoder Mar 8, 2024
89fcc7c
feat: add delegation activity daily chart
brancoder Mar 11, 2024
4432563
fix: delegation query
brancoder Mar 11, 2024
c90faf2
feat: add validators activity daily chart
brancoder Mar 11, 2024
441f698
feat: add delegators daily statistics chart
brancoder Mar 11, 2024
24c8e98
feat: add delegations daily activity chart
brancoder Mar 11, 2024
1bab456
feat: add staking daily activity chart
brancoder Mar 11, 2024
362d2d2
feat: add tokens with UC daily activity chart
brancoder Mar 11, 2024
ef516f8
feat: add total outputs with special unlock conditions statistics
brancoder Mar 11, 2024
317d985
feat: add total outputs with special unlock conditions statistics
brancoder Mar 11, 2024
78ae890
feat: add ledger size and total storage deposit charts
brancoder Mar 11, 2024
b25bb6b
feat: add block issuers daily charts
brancoder Mar 11, 2024
442fb71
feat: add mana burned daily chart
brancoder Mar 11, 2024
1a06ffe
Merge branch 'dev' into feat/add-daily-statistics
msarcev Mar 12, 2024
8bad5cd
fix: influx queries
brancoder Mar 13, 2024
d10f707
Merge branch 'feat/add-daily-statistics' of github.com:iotaledger/exp…
brancoder Mar 13, 2024
9f160c1
Merge branch 'dev' into feat/add-daily-statistics
brancoder Mar 13, 2024
eb877f5
fix: remove charts that are not added in the influx
brancoder Mar 14, 2024
442c834
feat: Remove "Daily Active addresses" chart (doesn't work)
msarcev Mar 14, 2024
f0f9e93
chore: Re-add graph data ending at "start of current day"
msarcev Mar 14, 2024
065fe01
feat: Add cron job to collect graphs data every hour
msarcev Mar 14, 2024
1456068
Merge branch 'dev' into feat/add-daily-statistics
msarcev Mar 14, 2024
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
63 changes: 62 additions & 1 deletion api/src/models/influx/nova/IInfluxDbCache.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,55 @@
import { IBlocksDailyInflux, IOutputsDailyInflux, ITransactionsDailyInflux } from "./IInfluxTimedEntries";
import {
IAccountActivityDailyInflux,
IActiveAddressesDailyInflux,
IAddressesWithBalanceDailyInflux,
IAnchorActivityDailyInflux,
IBlockIssuerDailyInflux,
IBlocksDailyInflux,
IDelegationActivityDailyInflux,
IDelegationsActivityDailyInflux,
IDelegatorsActivityDailyInflux,
IFoundryActivityDailyInflux,
ILedgerSizeDailyInflux,
IManaBurnedDailyInflux,
INftActivityDailyInflux,
IOutputsDailyInflux,
IStakingActivityDailyInflux,
IStorageDepositDailyInflux,
ITokensHeldPerOutputDailyInflux,
ITokensHeldWithUnlockConditionDailyInflux,
ITokensTransferredDailyInflux,
ITransactionsDailyInflux,
IUnlockConditionsPerTypeDailyInflux,
IValidatorsActivityDailyInflux,
} from "./IInfluxTimedEntries";
import { DayKey } from "../types";

/**
* The cache for influx graphs (daily).
*/
export interface IInfluxDailyCache {
blocksDaily: Map<DayKey, IBlocksDailyInflux>;
blockIssuersDaily: Map<DayKey, IBlockIssuerDailyInflux>;
transactionsDaily: Map<DayKey, ITransactionsDailyInflux>;
outputsDaily: Map<DayKey, IOutputsDailyInflux>;
tokensHeldDaily: Map<DayKey, ITokensHeldPerOutputDailyInflux>;
addressesWithBalanceDaily: Map<DayKey, IAddressesWithBalanceDailyInflux>;
activeAddressesDaily: Map<DayKey, IActiveAddressesDailyInflux>;
tokensTransferredDaily: Map<DayKey, ITokensTransferredDailyInflux>;
anchorActivityDaily: Map<DayKey, IAnchorActivityDailyInflux>;
nftActivityDaily: Map<DayKey, INftActivityDailyInflux>;
accountActivityDaily: Map<DayKey, IAccountActivityDailyInflux>;
foundryActivityDaily: Map<DayKey, IFoundryActivityDailyInflux>;
delegationActivityDaily: Map<DayKey, IDelegationActivityDailyInflux>;
validatorsActivityDaily: Map<DayKey, IValidatorsActivityDailyInflux>;
delegatorsActivityDaily: Map<DayKey, IDelegatorsActivityDailyInflux>;
delegationsActivityDaily: Map<DayKey, IDelegationsActivityDailyInflux>;
stakingActivityDaily: Map<DayKey, IStakingActivityDailyInflux>;
unlockConditionsPerTypeDaily: Map<DayKey, IUnlockConditionsPerTypeDailyInflux>;
tokensHeldWithUnlockConditionDaily: Map<DayKey, ITokensHeldWithUnlockConditionDailyInflux>;
ledgerSizeDaily: Map<DayKey, ILedgerSizeDailyInflux>;
storageDepositDaily: Map<DayKey, IStorageDepositDailyInflux>;
manaBurnedDaily: Map<DayKey, IManaBurnedDailyInflux>;
}

/**
Expand All @@ -16,6 +58,25 @@ export interface IInfluxDailyCache {
*/
export const initializeEmptyDailyCache = () => ({
blocksDaily: new Map(),
blockIssuersDaily: new Map(),
transactionsDaily: new Map(),
outputsDaily: new Map(),
tokensHeldDaily: new Map(),
addressesWithBalanceDaily: new Map(),
activeAddressesDaily: new Map(),
tokensTransferredDaily: new Map(),
anchorActivityDaily: new Map(),
nftActivityDaily: new Map(),
accountActivityDaily: new Map(),
foundryActivityDaily: new Map(),
delegationActivityDaily: new Map(),
validatorsActivityDaily: new Map(),
delegatorsActivityDaily: new Map(),
delegationsActivityDaily: new Map(),
stakingActivityDaily: new Map(),
unlockConditionsPerTypeDaily: new Map(),
tokensHeldWithUnlockConditionDaily: new Map(),
ledgerSizeDaily: new Map(),
storageDepositDaily: new Map(),
manaBurnedDaily: new Map(),
});
108 changes: 108 additions & 0 deletions api/src/models/influx/nova/IInfluxTimedEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export type IBlocksDailyInflux = ITimedEntry & {
candidacy: number | null;
};

export type IBlockIssuerDailyInflux = ITimedEntry & {
active: number | null;
registered: number | null;
};

export type ITransactionsDailyInflux = ITimedEntry & {
finalized: number | null;
failed: number | null;
Expand All @@ -20,3 +25,106 @@ export type IOutputsDailyInflux = ITimedEntry & {
anchor: number | null;
delegation: number | null;
};

export type ITokensHeldPerOutputDailyInflux = ITimedEntry & {
basic: number | null;
account: number | null;
foundry: number | null;
nft: number | null;
anchor: number | null;
delegation: number | null;
};

export type IAddressesWithBalanceDailyInflux = ITimedEntry & {
ed25519: number | null;
account: number | null;
implicit: number | null;
nft: number | null;
anchor: number | null;
};

export type IActiveAddressesDailyInflux = ITimedEntry & {
ed25519: number | null;
account: number | null;
implicit: number | null;
nft: number | null;
anchor: number | null;
};

export type ITokensTransferredDailyInflux = ITimedEntry & {
tokens: number | null;
};

export type IAnchorActivityDailyInflux = ITimedEntry & {
created: number | null;
governorChanged: number | null;
stateChanged: number | null;
destroyed: number | null;
};

export type INftActivityDailyInflux = ITimedEntry & {
created: number | null;
transferred: number | null;
destroyed: number | null;
};

export type IAccountActivityDailyInflux = ITimedEntry & {
created: number | null;
transferred: number | null;
destroyed: number | null;
};

export type IFoundryActivityDailyInflux = ITimedEntry & {
created: number | null;
transferred: number | null;
destroyed: number | null;
};

export type IDelegationActivityDailyInflux = ITimedEntry & {
created: number | null;
transferred: number | null;
destroyed: number | null;
};

export type IValidatorsActivityDailyInflux = ITimedEntry & {
candidates: number | null;
total: number | null;
};

export type IDelegatorsActivityDailyInflux = ITimedEntry & {
total: number | null;
};

export type IDelegationsActivityDailyInflux = ITimedEntry & {
total: number | null;
};

export type IStakingActivityDailyInflux = ITimedEntry & {
total: number | null;
};

export type IUnlockConditionsPerTypeDailyInflux = ITimedEntry & {
timelock: number | null;
storageDepositReturn: number | null;
expiration: number | null;
};

export type ITokensHeldWithUnlockConditionDailyInflux = ITimedEntry & {
timelock: number | null;
storageDepositReturn: number | null;
expiration: number | null;
};

export type ILedgerSizeDailyInflux = ITimedEntry & {
keyBytes: number | null;
dataBytes: number | null;
};

export type IStorageDepositDailyInflux = ITimedEntry & {
storageDeposit: number | null;
};

export type IManaBurnedDailyInflux = ITimedEntry & {
manaBurned: number | null;
bicBurned: number | null;
};
63 changes: 62 additions & 1 deletion api/src/routes/nova/analytics/influx/daily/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@ import { ServiceFactory } from "../../../../../factories/serviceFactory";
import { INetworkBoundGetRequest } from "../../../../../models/api/INetworkBoundGetRequest";
import { IConfiguration } from "../../../../../models/configuration/IConfiguration";
import { NOVA } from "../../../../../models/db/protocolVersion";
import { IBlocksDailyInflux, IOutputsDailyInflux, ITransactionsDailyInflux } from "../../../../../models/influx/nova/IInfluxTimedEntries";
import {
IAccountActivityDailyInflux,
IActiveAddressesDailyInflux,
IAddressesWithBalanceDailyInflux,
IAnchorActivityDailyInflux,
IBlockIssuerDailyInflux,
IBlocksDailyInflux,
IDelegationActivityDailyInflux,
IDelegationsActivityDailyInflux,
IDelegatorsActivityDailyInflux,
IFoundryActivityDailyInflux,
ILedgerSizeDailyInflux,
IManaBurnedDailyInflux,
INftActivityDailyInflux,
IOutputsDailyInflux,
IStakingActivityDailyInflux,
IStorageDepositDailyInflux,
ITokensHeldPerOutputDailyInflux,
ITokensHeldWithUnlockConditionDailyInflux,
ITokensTransferredDailyInflux,
ITransactionsDailyInflux,
IUnlockConditionsPerTypeDailyInflux,
IValidatorsActivityDailyInflux,
} from "../../../../../models/influx/nova/IInfluxTimedEntries";
import { NetworkService } from "../../../../../services/networkService";
import { InfluxServiceNova } from "../../../../../services/nova/influx/influxServiceNova";
import { ValidationHelper } from "../../../../../utils/validationHelper";
Expand All @@ -13,8 +36,27 @@ import { ValidationHelper } from "../../../../../utils/validationHelper";
export interface IDailyAnalyticsResponse {
error?: string;
blocksDaily?: IBlocksDailyInflux[];
blockIssuersDaily?: IBlockIssuerDailyInflux[];
transactionsDaily?: ITransactionsDailyInflux[];
outputsDaily?: IOutputsDailyInflux[];
tokensHeldDaily?: ITokensHeldPerOutputDailyInflux[];
addressesWithBalanceDaily?: IAddressesWithBalanceDailyInflux[];
activeAddressesDaily?: IActiveAddressesDailyInflux[];
tokensTransferredDaily?: ITokensTransferredDailyInflux[];
anchorActivityDaily?: IAnchorActivityDailyInflux[];
nftActivityDaily?: INftActivityDailyInflux[];
accountActivityDaily?: IAccountActivityDailyInflux[];
foundryActivityDaily?: IFoundryActivityDailyInflux[];
delegationActivityDaily?: IDelegationActivityDailyInflux[];
validatorsActivityDaily?: IValidatorsActivityDailyInflux[];
delegatorsActivityDaily?: IDelegatorsActivityDailyInflux[];
delegationsActivityDaily?: IDelegationsActivityDailyInflux[];
stakingActivityDaily?: IStakingActivityDailyInflux[];
unlockConditionsPerTypeDaily?: IUnlockConditionsPerTypeDailyInflux[];
tokensHeldWithUnlockConditionDaily?: ITokensHeldWithUnlockConditionDailyInflux[];
ledgerSizeDaily?: ILedgerSizeDailyInflux[];
storageDepositDaily?: IStorageDepositDailyInflux[];
manaBurnedDaily?: IManaBurnedDailyInflux[];
}

/**
Expand All @@ -38,8 +80,27 @@ export async function get(_: IConfiguration, request: INetworkBoundGetRequest):
return influxService
? {
blocksDaily: influxService.blocksDaily,
blockIssuersDaily: influxService.blockIssuersDaily,
transactionsDaily: influxService.transactionsDaily,
outputsDaily: influxService.outputsDaily,
tokensHeldDaily: influxService.tokensHeldDaily,
addressesWithBalanceDaily: influxService.addressesWithBalanceDaily,
activeAddressesDaily: influxService.activeAddressesDaily,
tokensTransferredDaily: influxService.tokensTransferredDaily,
anchorActivityDaily: influxService.anchorActivityDaily,
nftActivityDaily: influxService.nftActivityDaily,
accountActivityDaily: influxService.accountActivityDaily,
foundryActivityDaily: influxService.foundryActivityDaily,
delegationActivityDaily: influxService.delegationActivityDaily,
validatorsActivityDaily: influxService.validatorsActivityDaily,
delegatorsActivityDaily: influxService.delegatorsActivityDaily,
delegationsActivityDaily: influxService.delegationsActivityDaily,
stakingActivityDaily: influxService.stakingActivityDaily,
unlockConditionsPerTypeDaily: influxService.unlockConditionsPerTypeDaily,
tokensHeldWithUnlockConditionDaily: influxService.tokensHeldWithUnlockConditionDaily,
ledgerSizeDaily: influxService.ledgerSizeDaily,
storageDepositDaily: influxService.storageDepositDaily,
manaBurnedDaily: influxService.manaBurnedDaily,
}
: {
error: "Influx service not found for this network.",
Expand Down
Loading
Loading