Repository: gitbutlerapp/gitbutler
File: crates/but-db/src/cache/table/update.rs (Rust)

Code before:
    pub fn save(self, result: &CachedCheckResult) -> rusqlite::Result<()> {
        let sp = self.sp;

        sp.execute(
            "INSERT OR REPLACE INTO `update-check`
             (id, checked_at, up_to_date, latest_version, release_notes, url, signature,
              suppressed_at, suppress_duration_hours)
             VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
            rusqlite::params![
                SINGLETON_RECORD_ID,
                result.checked_at.naive_utc(),
                result.status.up_to_date,
                result.status.latest_version,
                result.status.release_notes,
                result.status.url,
                result.status.signature,
                result.suppressed_at.map(|dt| dt.naive_utc()),
                result.suppress_duration_hours,
            ],
        )?;

        sp.commit()?;
        Ok(())
    }

    /// Deletes the update check (lazy way to implement cache invalidation).
    pub fn delete(self) -> rusqlite::Result<()> {
        let sp = self.sp;

        sp.execute(
            "DELETE FROM `update-check` WHERE id = ?1;",
            rusqlite::params![SINGLETON_RECORD_ID],
        )?;
        sp.commit()?;

        Ok(())
    }

    /// Suppresses update notifications for a specified duration in `hours`.
    ///
    /// Updates the existing cache record with suppression settings.
    ///
    /// If no update check record exists yet, the function returns an errors.
    pub fn suppress(self, hours: u32) -> rusqlite::Result<()> {
        let sp = self.sp;

        // Check if a record exists
        let exists: bool = sp.query_row(
            "SELECT EXISTS(SELECT 1 FROM `update-check` WHERE id = 1)",
            [],
            |row| row.get(0),

Review comment (performance):
Method documentation isn't snappy ;).

```suggestion
    /// Deletes the update check, which also acts as cache invalidation.
```

Code after:
    pub fn save(self, result: &CachedCheckResult) -> rusqlite::Result<()> {
        let sp = self.sp;

        sp.execute(
            "INSERT OR REPLACE INTO `update-check`
             (id, checked_at, up_to_date, latest_version, release_notes, url, signature,
              suppressed_at, suppress_duration_hours)
             VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
            rusqlite::params![
                SINGLETON_RECORD_ID,
                result.checked_at.naive_utc(),
                result.status.up_to_date,
                result.status.latest_version,
                result.status.release_notes,
                result.status.url,
                result.status.signature,
                result.suppressed_at.map(|dt| dt.naive_utc()),
                result.suppress_duration_hours,
            ],
        )?;

        sp.commit()?;
        Ok(())
    }

    /// Deletes the update check, which is equivalent to cache invalidation.
    ///
    /// This operation is idempotent and is safe to perform regardless of if an update check record
    /// exists or not.
    pub fn delete(self) -> rusqlite::Result<()> {
        let sp = self.sp;

        sp.execute(
            "DELETE FROM `update-check` WHERE id = ?1;",
            rusqlite::params![SINGLETON_RECORD_ID],
        )?;
        sp.commit()?;

        Ok(())
    }

    /// Suppresses update notifications for a specified duration in `hours`.
    ///
    /// Updates the existing cache record with suppression settings.
    ///
    /// If no update check record exists yet, the function returns an errors.
    pub fn suppress(self, hours: u32) -> rusqlite::Result<()> {
        let sp = self.sp;

        // Check if a record exists
        let exists: bool = sp.query_row(