MediaWiki master
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
37 public function __construct(
38 WRStatsReader $reader,
39 string $name,
40 EntityKey $entity,
41 MetricSpec $metricSpec,
42 SequenceSpec $seqSpec,
43 TimeRange $range
44 ) {
45 $this->reader = $reader;
46 $this->name = $name;
47 $this->entity = $entity;
48 $this->metricSpec = $metricSpec;
49 $this->seqSpec = $seqSpec;
50 $this->range = $range;
51 }
52
58 public function total() {
59 if ( $this->total === null ) {
60 $this->total = $this->reader->internalGetCount(
61 $this->name,
62 $this->entity,
63 $this->metricSpec,
64 $this->seqSpec,
65 $this->range
66 );
67 }
68 return $this->total;
69 }
70
76 public function perSecond() {
77 return $this->total() / $this->range->getDuration();
78 }
79
85 public function perMinute() {
86 return $this->perSecond() * 60;
87 }
88
94 public function perHour() {
95 return $this->perSecond() * 3600;
96 }
97
103 public function perDay() {
104 return $this->perSecond() * 86400;
105 }
106}
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.