From 4eeb7f213584478838996190d5190155d448e456 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Tue, 18 Feb 2025 14:00:21 +0000 Subject: [PATCH] fix: grab the committee name since we can use that to match up against teh suers --- db/migrations/8_committee-mk-ii.sql | 1 + src/common/wolves.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/db/migrations/8_committee-mk-ii.sql b/db/migrations/8_committee-mk-ii.sql index d2e1d7c..ef6d185 100644 --- a/db/migrations/8_committee-mk-ii.sql +++ b/db/migrations/8_committee-mk-ii.sql @@ -5,6 +5,7 @@ DROP TABLE committee; CREATE TABLE IF NOT EXISTS committees ( id integer PRIMARY KEY, name_profile text not null, + name_plain text not null, name_full text not null, link text not null, committee text not null diff --git a/src/common/wolves.rs b/src/common/wolves.rs index b2c6af1..ba0ff93 100644 --- a/src/common/wolves.rs +++ b/src/common/wolves.rs @@ -178,6 +178,7 @@ pub mod committees { pub id: i64, pub name_full: String, pub name_profile: String, + pub name_plain: String, pub link: String, #[sqlx(json)] pub committee: Vec, @@ -189,6 +190,7 @@ pub mod committees { id: value.id, name_full: value.name_full, name_profile: value.name_profile, + name_plain: value.name_plain, link: value.link, committee: value.committee, } @@ -219,14 +221,15 @@ pub mod committees { async fn add_committee(db: &Pool, committee: &Committees) { match sqlx::query_as::<_, Committees>( " - INSERT INTO committees (id, name_profile, name_full, link, committee) - VALUES ($1, $2, $3, $4, $5) + INSERT INTO committees (id, name_profile, name_full, name_plain, link, committee) + VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT(id) DO UPDATE SET committee = $4 ", ) .bind(committee.id) .bind(&committee.name_profile) .bind(&committee.name_full) + .bind(&committee.name_plain) .bind(&committee.link) .bind(serde_json::to_string(&committee.committee).unwrap_or_default()) .fetch_optional(db)