From ecb55fa4fe36630c3267b85878e82aaf9cfe6735 Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 7 Jun 2021 22:38:39 -0700 Subject: [PATCH] * /badge/update/perms {perms} param is now {badge_perms} This makes the parameter follow the naming convention of badge_* * badges.id field now uses BIGINT's as intended * Typo in sql where 'badges' was incorrectly set to 'perms' -_- --- json-api/db/src/badges.rs | 2 +- json-api/migrations/2021-05-17-221928_badges/up.sql | 4 ++-- json-api/src/badges.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/json-api/db/src/badges.rs b/json-api/db/src/badges.rs index 777a169..799f5af 100644 --- a/json-api/db/src/badges.rs +++ b/json-api/db/src/badges.rs @@ -63,7 +63,7 @@ async fn badge_update(pool: &Pool, id: u64, query: &'static str, values: mysql_a pub async fn update_perms(pool: &Pool, id: u64, perms: u64) -> SqlResult { // Ok(None) if that badge was not registered anywhere // Ok(Some(Badge)) if that badge was registered - let q = "UPDATE perms SET permissions = :perms WHERE id = :id"; + let q = "UPDATE badges SET permissions = :perms WHERE id = :id"; let p = params!{"id" => id, "perms" => perms}; return badge_update(pool, id, q, p).await; } diff --git a/json-api/migrations/2021-05-17-221928_badges/up.sql b/json-api/migrations/2021-05-17-221928_badges/up.sql index 571151b..ad1090c 100644 --- a/json-api/migrations/2021-05-17-221928_badges/up.sql +++ b/json-api/migrations/2021-05-17-221928_badges/up.sql @@ -1,7 +1,7 @@ CREATE TABLE IF NOT EXISTS `badges`( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(256) NOT NULL, `color` INTEGER UNSIGNED NOT NULL DEFAULT 0xFFFFFFFF, `permissions` INTEGER UNSIGNED, -- nullable because this isn't logically applicable to every badge PRIMARY KEY(`id`) -); \ No newline at end of file +); diff --git a/json-api/src/badges.rs b/json-api/src/badges.rs index e93f335..7ab8a89 100644 --- a/json-api/src/badges.rs +++ b/json-api/src/badges.rs @@ -34,7 +34,7 @@ pub async fn new(p: &Pool, response: &mut Response, params: HashMap, params: HashMap) { let id = qs_param!(params, "badge_id", u64); - let perms = qs_param!(params, "perms", u64); + let perms = qs_param!(params, "badge_perms", u64); if let (Some(id), Some(perms)) = (id, perms) { match db::badges::update_perms(p, id, perms).await { // TODO: add rtc update here