feat: fixed up the changes

This commit is contained in:
silver 2025-02-18 13:36:08 +00:00
parent c79113921d
commit cab04a068f
Signed by: silver
GPG key ID: 36F93D61BAD3FD7D
11 changed files with 62 additions and 47 deletions

View file

@ -176,7 +176,8 @@ pub mod committees {
#[derive(Debug, Clone, sqlx::FromRow)]
pub struct Committees {
pub id: i64,
pub name: String,
pub name_full: String,
pub name_profile: String,
pub link: String,
#[sqlx(json)]
pub committee: Vec<i64>,
@ -185,10 +186,11 @@ pub mod committees {
impl From<wolves_oxidised::WolvesCNS> for Committees {
fn from(value: wolves_oxidised::WolvesCNS) -> Self {
Self {
id: value.id.parse().unwrap_or(0),
name: value.name,
id: value.id,
name_full: value.name_full,
name_profile: value.name_profile,
link: value.link,
committee: value.committee.iter().map(|x| x.parse::<i64>().unwrap_or(0)).collect(),
committee: value.committee,
}
}
}
@ -217,13 +219,14 @@ pub mod committees {
async fn add_committee(db: &Pool<Sqlite>, committee: &Committees) {
match sqlx::query_as::<_, Committees>(
"
INSERT INTO committees (id, name, link, committee)
VALUES ($1, $2, $3, $4)
INSERT INTO committees (id, name_profile, name_full, link, committee)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT(id) DO UPDATE SET committee = $4
",
)
.bind(committee.id)
.bind(&committee.name)
.bind(&committee.name_profile)
.bind(&committee.name_full)
.bind(&committee.link)
.bind(serde_json::to_string(&committee.committee).unwrap_or_default())
.fetch_optional(db)