-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: could not aggregate event-level data in a stats manager, bad…
… wording of stats classes Solution: add tickStats as an event-level aggregator without TimeFrames and integrate with accountTimeSeries.ts; rename timeSeries.ts to timeFrameStats.ts and related classes; also add docs
- Loading branch information
1 parent
552eb71
commit 39419ed
Showing
14 changed files
with
326 additions
and
133 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './statsState.js' | ||
export * from './statsTimeSeries.js' | ||
export * from './timeFrameState.js' | ||
export * from './timeFrameEntity.js' |
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,33 @@ | ||
import { EntityStorage } from '@aleph-indexer/core' | ||
|
||
export type TickEntity<T> = { | ||
account: string | ||
type: string | ||
date: number | ||
data: T | ||
} | ||
|
||
export type TickStatsStorage = EntityStorage<TickEntity<any>> | ||
|
||
const accountKey = { | ||
get: (e: TickEntity<unknown>) => e.account, | ||
length: EntityStorage.AddressLength, | ||
} | ||
|
||
const typeKey = { | ||
get: (e: TickEntity<unknown>) => e.type, | ||
length: EntityStorage.VariableLength, | ||
} | ||
|
||
const dateKey = { | ||
get: (e: TickEntity<unknown>) => e.date, | ||
length: EntityStorage.TimestampLength, | ||
} | ||
|
||
export function createStatsTimeSeriesDAL(path: string): TickStatsStorage { | ||
return new EntityStorage<TickEntity<any>>({ | ||
name: 'stats_time_series', | ||
path, | ||
key: [accountKey, typeKey, dateKey], | ||
}) | ||
} |
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
28 changes: 14 additions & 14 deletions
28
...amework/src/utils/stats/dal/statsState.ts → ...ork/src/utils/stats/dal/timeFrameState.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
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,4 +1,4 @@ | ||
export * from './accountTimeSeries.js' | ||
export * from './timeSeries.js' | ||
export * from './timeFrameStats.js' | ||
export * from './dal/index.js' | ||
export * from './types.js' |
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,26 @@ | ||
import { TimeSeries, TimeSeriesStatsConfig, TimeSeriesStatsFilters } from './types.js' | ||
import { DateRange } from '../time.js' | ||
import { EventBase } from '../../types.js' | ||
|
||
/** | ||
* Provides outward-facing methods of the stats aggregator. | ||
*/ | ||
export interface StatsI<I extends EventBase<any>, O> { | ||
config: TimeSeriesStatsConfig<I, O>; | ||
|
||
/** | ||
* Get the stats for a given interval, possibly time frame size and account. | ||
* @param args The interval, time frame size, limits and whether to reverse the order of the time series. | ||
* @param account The account to get the stats for. | ||
*/ | ||
getStats(account: string, args: TimeSeriesStatsFilters): Promise<TimeSeries<O>>; | ||
|
||
/** | ||
* Process the events for a given account into time frames. | ||
* @param account The account to process the events for. | ||
* @param now The current unix timestamp. | ||
* @param pendingDateRanges The requested time frames to process. | ||
* @param minDate | ||
*/ | ||
process(account: string, now: number, pendingDateRanges: DateRange[], minDate: number | undefined): Promise<void>; | ||
} |
Oops, something went wrong.