44
55namespace SOFe \Capital \Analytics \Top ;
66
7+ use pocketmine \utils \Binary ;
78use SOFe \Capital \AccountLabels ;
89use SOFe \Capital \AccountQueryMetric ;
910use SOFe \Capital \Config \Parser ;
@@ -31,7 +32,7 @@ final class QueryArgs {
3132 private ?string $ hash = null ;
3233
3334 /**
34- * @param LabelSelector $labelSelector The labels that filter the cacounts /transactions.
35+ * @param LabelSelector $labelSelector The labels that filter the accounts /transactions.
3536 * @param string $groupingLabel The label to group by.
3637 * @param array<string, string> $displayLabels The labels to display in the top list. Keys are InfoAPI info names and values are the labels to display.
3738 * @param self::ORDERING_* $ordering Whether to sort ascendingly or descendingly.
@@ -43,6 +44,7 @@ public function __construct(
4344 public string $ groupingLabel ,
4445 public array $ displayLabels ,
4546 public string $ ordering ,
47+ public ?int $ interval ,
4648 public QueryMetric $ metric ,
4749 ) {
4850 }
@@ -64,6 +66,12 @@ public function hash() : string {
6466 $ bytes .= $ this ->groupingLabel ;
6567 $ bytes .= "\0" ;
6668
69+ if ($ this ->interval !== null ) {
70+ $ bytes .= "\1" . Binary::writeLong ($ this ->interval );
71+ } else {
72+ $ bytes .= "\0" ;
73+ }
74+
6775 $ bytes .= get_class ($ this ->metric );
6876 $ bytes .= "\0" ;
6977
@@ -89,13 +97,19 @@ public static function parse(Parser $config, Schema $schema) : self {
8997 self ::ORDERING_DESC => self ::ORDERING_DESC ,
9098 default => $ config ->setValue ("ordering " , self ::ORDERING_DESC , "Invalid ordering " ),
9199 };
100+ $ interval = $ config ->expectNullableNumber ("interval " , 24 , <<<'EOT'
101+ Number of hours of data to consider.
102+ Only accounts used in this interval or transactions that took place in this interval are considered.
103+ EOT);
104+ $ interval = $ interval !== null ? (int ) ($ interval * 3600 ) : null ;
92105 $ metric = AccountQueryMetric::parseConfig ($ config , "metric " );
93106
94107 return new self (
95108 labelSelector: $ schema ->getSelector (),
96109 groupingLabel: $ groupingLabel ,
97110 displayLabels: $ displayLabels ,
98111 ordering: $ ordering ,
112+ interval: $ interval ,
99113 metric: $ metric ,
100114 );
101115 }
0 commit comments