Skip to content

Commit

Permalink
Merge pull request #10 from ZakisM/chore/fix-clippy-lints
Browse files Browse the repository at this point in the history
chore: fix clippy lints
  • Loading branch information
ZakisM authored Feb 24, 2024
2 parents d3f3df7 + 42a63d7 commit 1b3bd69
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=rust:1.63
ARG BASE_IMAGE=rust:latest

FROM $BASE_IMAGE as builder
WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions src/conduit/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub async fn delete(pool: &SqlitePool, discord_id: i64, alert_id: &str) -> Resul

if rows_affected == 0 {
bail!("Could not find this alert to delete")
} else {
Ok(())
}

Ok(())
}
36 changes: 22 additions & 14 deletions src/discord/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::convert::TryInto;
use std::env;
use std::fmt::Write;
use std::iter::FromIterator;
use std::sync::Arc;

Expand Down Expand Up @@ -170,20 +171,27 @@ async fn list(ctx: &Context, msg: &Message) -> CommandResult {
let mut response = MessageBuilder::new();

if !alerts.is_empty() {
let results: String = alerts
.into_iter()
.enumerate()
.map(|(i, a)| {
format!(
"{}.\n Id: {}\n Url: {}\n Matching Text: {}\n Non Matching: {}\n",
i + 1,
a.alert_id,
a.url,
a.matching_text,
if a.non_matching == 1 { "True" } else { "False" },
)
})
.collect();
let results: String =
alerts
.iter()
.enumerate()
.fold(String::new(), |mut output, (i, a)| {
let _ = write!(
output,
r#"{}.
Id: {}
Url: {}
Matching Text: {}
Non Matching: {}
"#,
i + 1,
a.alert_id,
a.url,
a.matching_text,
if a.non_matching == 1 { "True" } else { "False" },
);
output
});

// If message is too large then send it in chunks;
if results.len() > 1900 {
Expand Down
2 changes: 1 addition & 1 deletion src/models/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Alert {
.context("Failed to convert discord_id into i64")?;

Ok(Self::new(
&url,
url,
matching_text.replace("'''", "\"").replace('~', ""),
non_matching,
discord_id,
Expand Down

0 comments on commit 1b3bd69

Please sign in to comment.