-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: Switch to anyhow::Result (fixes #50)
- Loading branch information
Showing
14 changed files
with
48 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 Dmitry Marakasov <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use anyhow::Error; | ||
use anyhow::Result; | ||
use chrono::{DateTime, NaiveDateTime, Utc}; | ||
|
||
pub fn parse_utc_datetime(date: &str) -> Result<DateTime<Utc>, Error> { | ||
pub fn parse_utc_datetime(date: &str) -> Result<DateTime<Utc>> { | ||
Ok(NaiveDateTime::parse_from_str(date, "%Y-%m-%dT%H:%M:%S%.3f")?.and_utc()) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 Dmitry Marakasov <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use anyhow::Error; | ||
use anyhow::Result; | ||
use chrono::{DateTime, Utc}; | ||
use indoc::indoc; | ||
use sqlx::{FromRow, PgPool}; | ||
|
@@ -23,7 +23,7 @@ impl<'a> SourceUpdateStatusTracker<'a> { | |
Self { pool } | ||
} | ||
|
||
pub async fn get(&self, name: &str) -> Result<SourceUpdateStatus, Error> { | ||
pub async fn get(&self, name: &str) -> Result<SourceUpdateStatus> { | ||
Ok(sqlx::query_as(indoc! {" | ||
SELECT current_full_update_offset, last_full_update_time, last_update_time | ||
FROM update_status | ||
|
@@ -35,11 +35,7 @@ impl<'a> SourceUpdateStatusTracker<'a> { | |
.unwrap_or_default()) | ||
} | ||
|
||
pub async fn register_update_attempt( | ||
&self, | ||
name: &str, | ||
time: DateTime<Utc>, | ||
) -> Result<(), Error> { | ||
pub async fn register_update_attempt(&self, name: &str, time: DateTime<Utc>) -> Result<()> { | ||
sqlx::query(indoc! {" | ||
INSERT INTO update_status(name, last_update_attempt_time) | ||
VALUES ($1, $2) | ||
|
@@ -52,7 +48,7 @@ impl<'a> SourceUpdateStatusTracker<'a> { | |
Ok(()) | ||
} | ||
|
||
pub async fn register_successful_update(&self, name: &str, is_full: bool) -> Result<(), Error> { | ||
pub async fn register_successful_update(&self, name: &str, is_full: bool) -> Result<()> { | ||
sqlx::query(indoc! {" | ||
UPDATE update_status | ||
SET | ||
|
@@ -72,7 +68,7 @@ impl<'a> SourceUpdateStatusTracker<'a> { | |
&self, | ||
name: &str, | ||
current_offset: u64, | ||
) -> Result<(), Error> { | ||
) -> Result<()> { | ||
sqlx::query(indoc! {" | ||
UPDATE update_status | ||
SET current_full_update_offset = $2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// SPDX-FileCopyrightText: Copyright 2024 Dmitry Marakasov <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
use anyhow::Error; | ||
use anyhow::Result; | ||
|
||
use repology_common::PackageStatus; | ||
|
||
|
@@ -106,7 +106,7 @@ pub fn render_generic_badge( | |
header: Option<&str>, | ||
min_width: usize, | ||
font_measurer: &FontMeasurer, | ||
) -> Result<String, Error> { | ||
) -> Result<String> { | ||
let num_rows = cells.len(); | ||
let num_columns = if num_rows > 0 { cells[0].len() } else { 0 }; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.