v1.0: First production version

This first version allows login of pre-existing users, creation and update of truths
by admins, vote on the truths by users, their display as well as a simple graph
for the vote results.
Everything persisting in a SQLite database.
This commit is contained in:
trotFunky 2024-07-23 21:51:42 +01:00
commit 9911895b5b
22 changed files with 4790 additions and 0 deletions

60
src/database_records.rs Normal file
View file

@ -0,0 +1,60 @@
use rocket::serde::{Deserialize, Serialize};
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct Player {
id: u16,
name: String,
}
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct PlayerLoginInfo {
pub id: u16,
pub is_admin: bool,
pub name: String,
pub pwd_hash: String,
}
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct Truth {
id: u32,
week: u8,
number: u8,
author_id: u16,
rendered_text: String,
raw_text: String,
}
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct DisplayTruth {
id: u32,
number: u8,
author_id: u16,
rendered_text: String,
}
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct Vote {
pub id: u32,
pub truth_id: u32,
pub voter_id: u16,
pub voted_id: u16
}
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct VotingData {
pub votes_for: String,
pub truth_number: u8,
pub votes: u8
}
#[derive(sqlx::FromRow, Deserialize, Serialize)]
#[serde(crate = "rocket::serde")]
pub struct AuthTokens {
pub token: String,
}