MediaWiki REL1_39
RatePromise.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\WRStats;
4
14 private $reader;
16 private $name;
18 private $entity;
20 private $metricSpec;
22 private $seqSpec;
24 private $range;
26 private $total;
27
38 public function __construct(
39 WRStatsReader $reader,
40 string $name,
41 EntityKey $entity,
42 MetricSpec $metricSpec,
43 SequenceSpec $seqSpec,
44 TimeRange $range
45 ) {
46 $this->reader = $reader;
47 $this->name = $name;
48 $this->entity = $entity;
49 $this->metricSpec = $metricSpec;
50 $this->seqSpec = $seqSpec;
51 $this->range = $range;
52 }
53
59 public function total() {
60 if ( $this->total === null ) {
61 $this->total = $this->reader->internalGetCount(
62 $this->name,
63 $this->entity,
64 $this->metricSpec,
65 $this->seqSpec,
66 $this->range
67 );
68 }
69 return $this->total;
70 }
71
77 public function perSecond() {
78 return $this->total() / $this->range->getDuration();
79 }
80
86 public function perMinute() {
87 return $this->perSecond() * 60;
88 }
89
95 public function perHour() {
96 return $this->perSecond() * 3600;
97 }
98
104 public function perDay() {
105 return $this->perSecond() * 86400;
106 }
107}
Base class for entity keys.
Definition EntityKey.php:13
Class representation of normalized metric specifications.
A WRStats query result promise.
perMinute()
Get the counter value as a rate per minute.
total()
Get the total counter value summed over the specified time range.
__construct(WRStatsReader $reader, string $name, EntityKey $entity, MetricSpec $metricSpec, SequenceSpec $seqSpec, TimeRange $range)
perDay()
Get the counter value as a rate per day.
perSecond()
Get the counter value as a rate per second.
perHour()
Get the counter value as a rate per hour.
Class representation of normalized sequence specifications.
Readers gather a batch of read operations, returning promises.