blob: fdfdb6d2950082dbe2c31301b5d133a40b5a146b [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COBALT_SRC_LOCAL_AGGREGATION_1_1_BACKFILL_MANAGER_H_
#define COBALT_SRC_LOCAL_AGGREGATION_1_1_BACKFILL_MANAGER_H_
#include "src/local_aggregation_1_1/aggregation_procedures/aggregation_procedure.h"
#include "src/local_aggregation_1_1/local_aggregation.pb.h"
#include "src/registry/metric_definition.pb.h"
namespace cobalt::local_aggregation {
// BackfillManager is responsible for computing the list of aggregation periods for which no
// observations were generated for a particular report.
class BackfillManager {
public:
// |total_backfill_window| The maximum number of days to generate daily/hourly observations for
// (including the day_index in |end_time_info|).
explicit BackfillManager(uint32_t total_backfill_window);
// CalculateBackfill returns a list of TimeInfos corresponding to aggregation periods for which
// observations have not yet been generated.
//
// |start_time| The oldest time to consider, if |start_time| is more than |backstop_days_| before
// |end_time|, then the backstop will be used instead.
// |end_time| The most recent time to consider (inclusive).
// |time_zone| The time zone to use for calculating hour_ids.
// |is_daily| If true, we should generate daily TimeInfos, otherwise generate hourly.
[[nodiscard]] std::vector<util::TimeInfo> CalculateBackfill(
util::TimeInfo start_time, util::TimeInfo end_time,
MetricDefinition::TimeZonePolicy time_zone, bool is_daily) const;
private:
// The number of days in the past for which we should generate observations.
uint32_t backstop_days_;
};
} // namespace cobalt::local_aggregation
#endif // COBALT_SRC_LOCAL_AGGREGATION_1_1_BACKFILL_MANAGER_H_