Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LeaderboardAggregation Abstract

description

The abstract implementation for the score aggregation scheduler. Contains source code for the execution logic of a command with name: statistics:LeaderboardAggregation/(D|M|W).

since

v0.3.2

Hierarchy

Index

Constructors

Properties

TYPE: string = "leaderboard"

The type of statistics to be saved to the database. Should be defaulted to "leaderboard".

access

private

readonly
var

{string}

activityModel: ActivityModel
argv: string[] = []

The arguments passed to the command. Typically, this holds required parameters of commands.

access

protected

var

{string[]}

assetModel: AssetModel
configService: ConfigService<Record<string, unknown>, false>
dappConfig: DappConfig

The internal dApp configuration object. This object is used to configure key functionalities such as the name of a dApp and the enabled scopes of the backend runtime.

access

protected

var

{DappConfig}

lastExecutedAt: number

Memory store for the last time of execution. This is used in getStateData to update the latest execution state.

access

private

var

{number}

logService: LogService
logger: LogService
networkConfig: NetworkConfig

The internal dApp network configuration object. This object is used to configure the access to the underlying blockchain network.

access

protected

var

{NetworkConfig}

networkService: NetworkService
periodFormat: string

The period format i.e. "D", "W" or "M". This field will be overriden by sub-classes during initialization.

access

protected

var

{string}

schedulerRegistry: SchedulerRegistry
scope: string = "statistics"

The command scope. This is the scope that must be enabled through the configuration files for this command to be available.

This property is required through the extension of BaseCommand.

access

protected

var

{Scope}

Requires state information of the module. This object is typically populated upon first execution and updated any time later.

see

StateService

access

protected

var

{StateDocument}

stateService: StateService

Accessors

  • get command(): string
  • get signature(): string
  • get stateIdentifier(): string
  • Getter for the discovery state identifier, e.g. "discovery.accounts", "discovery.transactions", "payout.outputs" etc.

    This method is an implementation necessary because of the extensions of StatefulModule.

    see

    StatefulModule

    access

    public

    var

    {string}

    Returns string

Methods

  • This method implements the statistics logic for this command that will aggregate relevant subjects. Subjects in this command are provided in config as collection and ** fields** that are included in transfer transactions on dHealth Network.

    As of the time of writing, this scheduler currently supports the following collections:

    • assets: The asset that an account has received as rewards.

      As of the time of writing, this scheduler currently supports the following fields:
    • amount: The amount of an asset that an account received as rewards,

    access

    public

    async

    Parameters

    Returns Promise<void>

  • createAggregationQuery(startDate: Date, endDate: Date): PipelineStage[]
  • createQueryDates(dateNow: Date): { endDate: Date; startDate: Date }
  • debugLog(message: string): void
  • errorLog(message: string, stack?: string): void
  • getNextPeriod(date: Date): string
  • getPrevPeriod(date: Date): string
  • infoLog(message: string): void
  • parseCollection(collectionOption: string): string
  • This helper method serves as a parser for the -c or --collection option of this command.

    The statistics collection can contain a mongo collection name that must exist in the database.

    Parameters

    • collectionOption: string

      The --collection argument as passed in the terminal.

    Returns string

    A validated mongo database collection name.

  • This method is the entry point of any command line executed command. nest-commander implements a flow where this method is called with parameters that are respectively the raw arguments and the parsed arguments to this command call.

    This method uses the stateService to fetch the current execution and also uses it to update the state.

    Note that the runWithOptions method is called inside a try-catch block to force the error handling process.

    access

    public

    Parameters

    Returns Promise<void>

  • runAsScheduler(): void
  • This method is the entry point of this scheduler. Due to the usage of the Cron decorator, and the implementation the nest backend runtime is able to discover this when the statistics scope is enabled.

    This method is necessary to make sure this command is run with the correct --collection option.

    This method must be implemented in sub-classes with a proper cron expression value.

    see

    BaseCommand

    access

    public

    async

    Returns void

  • runScheduler(): Promise<void>
  • This method is the second entry point of this scheduler. Due to the usage of the Cron decorator, and the implementation the nest backend runtime is able to discover this when the statistics scope is enabled.

    This method is necessary to make sure this command is run with the correct --collection option.

    see

    BaseCommand

    access

    public

    async

    Returns Promise<void>

  • usage(): string
  • This method prints usage information to the command line and is used by nest-commander to print a correctly formatted help message.

    Note that usage methods can be overwritten but must always print a standard command line signature.

    access

    public

    Returns string

Generated using TypeDoc