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

Method update_interval_timer

components/stores/src/timers.rs:56–92  ·  view source on GitHub ↗
(
        &self,
        guild_id: Id<GuildMarker>,
        timer: IntervalTimer,
    )

Source from the content-addressed store, hash-verified

54 }
55
56 pub async fn update_interval_timer(
57 &self,
58 guild_id: Id<GuildMarker>,
59 timer: IntervalTimer,
60 ) -> TimerStoreResult<IntervalTimer> {
61 let (interval_minutes, interval_cron) = match timer.interval {
62 IntervalType::Minutes(m) => (Some(m as i32), None),
63 IntervalType::Cron(c) => (None, Some(c)),
64 };
65
66 let res = sqlx::query_as!(
67 DbIntervalTimer,
68 "
69 INSERT INTO interval_timers (guild_id, plugin_id, timer_name, interval_minutes, \
70 interval_cron, last_run_at, created_at, updated_at)
71 VALUES ($1, $2, $3, $4, $5, $6, now(), now())
72 ON CONFLICT (guild_id, plugin_id, timer_name)
73 DO UPDATE SET
74 interval_minutes = $4,
75 interval_cron = $5,
76 last_run_at = $6,
77 updated_at = now()
78 RETURNING guild_id, plugin_id, timer_name, interval_minutes, interval_cron, \
79 last_run_at, created_at, updated_at;
80 ",
81 guild_id.get() as i64,
82 timer.plugin_id.unwrap_or(0) as i64,
83 timer.name,
84 interval_minutes,
85 interval_cron,
86 timer.last_run,
87 )
88 .fetch_one(&self.pool)
89 .await?;
90
91 Ok(IntervalTimer::try_from(res)?)
92 }
93
94 // async fn del_interval_timer(
95 // &self,

Callers 2

update_last_runMethod · 0.80
init_timerMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected