use crate::domain::{Measurement, Region, TimeRange};
use crate::ports::IntensityRepository;
use super::ApplicationError;
pub struct GetIntensityHistory<R: IntensityRepository> {
repository: R,
methodology_id: String,
}
impl<R: IntensityRepository> GetIntensityHistory<R> {
pub fn new(repository: R, methodology_id: impl Into<String>) -> Self {
Self {
repository,
methodology_id: methodology_id.into(),
}
}
pub async fn execute(
&self,
region: Region,
range: TimeRange,
) -> Result<Vec<Measurement>, ApplicationError> {
Ok(self
.repository
.range(region, &self.methodology_id, range)
.await?)
}
}