feat: lint ++ add find_by_status in concour

This commit is contained in:
Max batleforc 2024-06-24 11:59:04 +02:00
parent 4082a1677d
commit 81c3114e0d
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7
9 changed files with 54 additions and 13 deletions

28
cog.toml Normal file
View File

@ -0,0 +1,28 @@
pre_bump_hooks = [
"echo {{version}}",
"cargo audit && cargo bump {{version}} && git add Cargo.toml && git commit -m \"chore(version): set cargo version to {{version}}\"",
]
post_bump_hooks = ["git push", "git push origin {{version}}"]
[changelog]
path = "CHANGELOG.md"
template = "remote"
remote = "git.weebo.fr"
repository = "BotDiscord"
owner = "sandbox"
authors = [
{ username = "batleforc", signature = "Max" },
{ username = "max", signature = "Max" },
]
[bump_profiles]
[packages]
[git_hooks.commit-msg]
script = """#!/bin/sh
set -e
cargo fmt -v --all --check
cargo clippy
gitleaks protect --verbose --redact --staged
"""

View File

@ -1,3 +1,3 @@
pub mod list;
pub mod answer;
pub mod enable;
pub mod answer;
pub mod list;

View File

@ -1,11 +1,8 @@
use crate::botv2::init::{Context,Error};
use crate::botv2::init::{Context, Error};
/// Ping command
#[poise::command(
slash_command,
prefix_command,
)]
#[poise::command(slash_command, prefix_command)]
pub async fn ping(ctx: Context<'_>) -> Result<(), Error> {
ctx.say("Pong from framework!").await?;
Ok(())
}
}

View File

@ -1,2 +1,2 @@
pub mod answer;
pub mod change_auto_meme;
pub mod answer;

View File

@ -136,4 +136,19 @@ impl Concour {
}
Ok(concours)
}
pub async fn find_by_status(status: &ConcourStatus) -> Result<Vec<Concour>, surrealdb::Error> {
let sql = format!("SELECT * FROM {} WHERE status = '{}'", CONCOUR, status);
let mut results = match DB.query(&sql).await {
Ok(results) => results,
Err(e) => {
return Err(e);
}
};
let mut concours = Vec::new();
while let Ok(Some(concour)) = results.take(0) {
concours.push(concour);
}
Ok(concours)
}
}

View File

@ -0,0 +1 @@

View File

@ -48,7 +48,7 @@ impl Debug for VerboseLevel {
}
}
impl Display for VerboseLevel{
impl Display for VerboseLevel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::ERROR => write!(f, "ERROR"),
@ -58,4 +58,4 @@ impl Display for VerboseLevel{
Self::TRACE => write!(f, "TRACE"),
}
}
}
}

View File

@ -1,3 +1,3 @@
pub mod init;
pub mod level;
pub mod tracing_kind;
pub mod init;

View File

@ -16,5 +16,5 @@ pub struct Tracing {
pub kind: TracingKind,
pub name: String,
pub level: VerboseLevel,
pub additional: HashMap<String,String>
pub additional: HashMap<String, String>,
}