MCPcopy Create free account
hub / github.com/Botloader/botloader / update_last_run

Method update_last_run

components/scheduler/src/interval_timer_manager.rs:145–173  ·  view source on GitHub ↗
(&mut self, t: DateTime<Utc>, triggered_timer: IntervalTimer)

Source from the content-addressed store, hash-verified

143 }
144
145 async fn update_last_run(&mut self, t: DateTime<Utc>, triggered_timer: IntervalTimer) {
146 let mut triggered_inner_clone = triggered_timer.clone();
147 triggered_inner_clone.last_run = t;
148
149 if let Err(err) = self
150 .storage
151 .update_interval_timer(self.guild_id, triggered_inner_clone)
152 .await
153 {
154 tracing::error!(%err, "failed updating timer")
155 };
156
157 // update next time if the timer is loaded
158 let Some(loaded_timer) = self.loaded_intervals.get_mut(&TimerId(
159 triggered_timer.plugin_id,
160 triggered_timer.name.clone(),
161 )) else {
162 // timer is not loaded, we have already updated the last run time so we don't need to do more
163 return;
164 };
165
166 loaded_timer.inner.last_run = t;
167 if let Some(next) = loaded_timer.parsed_type.next_run_time(t) {
168 loaded_timer.next_run = next;
169 } else {
170 // TODO: proper handling of unknown next time, this could happen with invalid cron times for example
171 loaded_timer.next_run = t.add(Duration::days(100 * 365));
172 }
173 }
174
175 async fn init_timer(
176 &mut self,

Callers 1

timer_ackMethod · 0.80

Calls 4

TimerIdClass · 0.85
update_interval_timerMethod · 0.80
next_run_timeMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected