Support converting statistics to another unit (#79117)
This commit is contained in:
parent
772581dd28
commit
c52d0f7495
5 changed files with 448 additions and 6 deletions
|
@ -31,6 +31,24 @@ class RecorderTask(abc.ABC):
|
|||
"""Handle the task."""
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChangeStatisticsUnitTask(RecorderTask):
|
||||
"""Object to store statistics_id and unit to convert unit of statistics."""
|
||||
|
||||
statistic_id: str
|
||||
new_unit_of_measurement: str
|
||||
old_unit_of_measurement: str
|
||||
|
||||
def run(self, instance: Recorder) -> None:
|
||||
"""Handle the task."""
|
||||
statistics.change_statistics_unit(
|
||||
instance,
|
||||
self.statistic_id,
|
||||
self.new_unit_of_measurement,
|
||||
self.old_unit_of_measurement,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ClearStatisticsTask(RecorderTask):
|
||||
"""Object to store statistics_ids which for which to remove statistics."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue