Skip to content

Commit f266068

Browse files
committed
Cache time registration on 'set'
1 parent 18250d6 commit f266068

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/infrastructure/repositories/maconomy_http_client.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl MaconomyHttpClient<'_> {
195195
days: &HashSet<u8>,
196196
row: u8,
197197
container_instance: &ContainerInstance,
198-
) -> Result<ConcurrencyControl> {
198+
) -> Result<(TimeRegistration, ConcurrencyControl)> {
199199
let concurrency_control = &container_instance.concurrency_control.0;
200200
let instance_url = self.get_container_instance_url(&container_instance.id.0);
201201
let url = format!("{instance_url}/data/panes/table/{row}");
@@ -218,7 +218,12 @@ impl MaconomyHttpClient<'_> {
218218
bail!("Server responded with {status}");
219219
}
220220

221-
Ok(concurrency_control.into())
221+
let time_registration = response
222+
.json()
223+
.await
224+
.context("Failed to parse response to time registration")?;
225+
226+
Ok((time_registration, concurrency_control.into()))
222227
}
223228

224229
pub async fn get_job_number_from_name(&self, job_name: &str) -> Result<Option<String>> {

src/infrastructure/repositories/time_sheet_repository.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ impl TimeSheetRepository<'_> {
158158
let days: HashSet<_> = days.iter().map(|&d| d as u8).collect();
159159

160160
info!("Setting time");
161-
let concurrency_control = self
161+
let (time_registration, concurrency_control) = self
162162
.client
163163
.set_time(hours, &days, line_number, &container_instance)
164164
.await
165165
.with_context(|| format!("Failed to set {hours} hours on row {line_number}"))?;
166166

167-
// TODO: also update self.time_registration
167+
self.time_registration = Some(time_registration);
168168
self.update_concurrency_control(concurrency_control);
169169
Ok(())
170170
}

0 commit comments

Comments
 (0)