fix: update sqlx and fix container build
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

closes: #14
This commit is contained in:
Aravinth Manivannan 2023-02-14 17:25:27 +05:30
parent 4f224d782a
commit 9e153b22ca
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
12 changed files with 424 additions and 394 deletions

531
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -36,7 +36,7 @@ actix-web-codegen-const-routes = { version = "0.1.0", tag = "0.1.0", git = "http
futures = "0.3.15"
sqlx = { version = "0.5.9", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
sqlx = { version = "0.6.2", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
@ -78,7 +78,7 @@ version = "0.2"
[build-dependencies]
sqlx = { version = "0.5.9", features = [ "runtime-actix-rustls", "uuid", "postgres", "time", "offline" ] }
sqlx = { version = "0.6.2", features = [ "runtime-actix-rustls", "uuid", "postgres", "time", "offline" ] }
#serde_yaml = "0.8.17"
serde_json = "1"
#yaml-rust = "0.4.5"

View file

@ -1,18 +1,5 @@
{
"db": "PostgreSQL",
"03c9789e83a398bed96354924a0e63ccaa97bec667fda1b8277bb9afda9a6fcd": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Text",
"Uuid"
]
}
},
"query": "DELETE \n FROM survey_campaigns \n WHERE \n user_id = (\n SELECT \n ID \n FROM \n survey_admins \n WHERE \n name = $1\n )\n AND\n id = ($2)"
},
"0d22134cc5076304b7895827f006ee8269cc500f400114a7472b83f0f1c568b5": {
"describe": {
"columns": [],
@ -27,6 +14,32 @@
},
"query": "INSERT INTO survey_admins \n (name , password, secret) VALUES ($1, $2, $3)"
},
"117f1ae18f6a3936f27446b75b555951fe217d3a3cefe40a006fdd3cb31f0ac4": {
"describe": {
"columns": [
{
"name": "id",
"ordinal": 0,
"type_info": "Int4"
}
],
"nullable": [
false
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Varchar",
"Varchar",
"Int4",
"Timestamptz",
"Text"
]
}
},
"query": "INSERT INTO survey_responses (\n user_id,\n campaign_id,\n device_user_provided,\n device_software_recognised,\n threads,\n submitted_at,\n submission_bench_type_id\n ) VALUES (\n $1, $2, $3, $4, $5, $6,\n (SELECT ID FROM survey_bench_type WHERE name = $7)\n )\n RETURNING ID;"
},
"1373df097fa0e58b23a374753318ae53a44559aa0e7eb64680185baf1c481723": {
"describe": {
"columns": [
@ -73,6 +86,19 @@
},
"query": "SELECT name, password FROM survey_admins WHERE email = ($1)"
},
"1972be28a6bda2c3a3764a836e95c8cb0c5db277fc4c8a9b19951a03166c6492": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Text",
"Uuid"
]
}
},
"query": "DELETE \n FROM survey_campaigns \n WHERE \n user_id = (\n SELECT \n ID \n FROM \n survey_admins \n WHERE \n name = $1\n )\n AND\n id = ($2)"
},
"1b7e17bfc949fa97e8dec1f95e35a02bcf3aa1aa72a1f6f6c8884e885fc3b953": {
"describe": {
"columns": [],
@ -146,6 +172,65 @@
},
"query": "UPDATE survey_admins set password = $1\n WHERE name = $2"
},
"57c673ad8529371d77aa305917cf680dd2273ead74c3583ef0322f472b1d33fd": {
"describe": {
"columns": [
{
"name": "id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "device_software_recognised",
"ordinal": 1,
"type_info": "Varchar"
},
{
"name": "threads",
"ordinal": 2,
"type_info": "Int4"
},
{
"name": "user_id",
"ordinal": 3,
"type_info": "Uuid"
},
{
"name": "submitted_at",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "device_user_provided",
"ordinal": 5,
"type_info": "Varchar"
},
{
"name": "name",
"ordinal": 6,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
true,
false,
false,
false,
false
],
"parameters": {
"Left": [
"Uuid",
"Text",
"Int8",
"Int8"
]
}
},
"query": "SELECT\n survey_responses.ID,\n survey_responses.device_software_recognised,\n survey_responses.threads,\n survey_responses.user_id,\n survey_responses.submitted_at,\n survey_responses.device_user_provided,\n survey_bench_type.name\n FROM\n survey_responses\n INNER JOIN survey_bench_type ON\n survey_responses.submission_bench_type_id = survey_bench_type.ID\n WHERE\n survey_responses.campaign_id = (\n SELECT ID FROM survey_campaigns\n WHERE\n ID = $1\n AND\n user_id = (SELECT ID FROM survey_admins WHERE name = $2)\n )\n LIMIT $3 OFFSET $4"
},
"58ec3b8f98c27e13ec2732f8ee23f6eb9845ac5d9fd97b1e5c9f2eed4b1f5693": {
"describe": {
"columns": [
@ -226,6 +311,66 @@
},
"query": "SELECT \n name, id\n FROM \n survey_campaigns \n WHERE\n user_id = (\n SELECT \n ID\n FROM \n survey_admins\n WHERE\n name = $1\n )"
},
"74c41e33f91cf31ea13582c8b3ca464544374842450d580517ca2bd01d67402e": {
"describe": {
"columns": [
{
"name": "id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "device_software_recognised",
"ordinal": 1,
"type_info": "Varchar"
},
{
"name": "threads",
"ordinal": 2,
"type_info": "Int4"
},
{
"name": "user_id",
"ordinal": 3,
"type_info": "Uuid"
},
{
"name": "submitted_at",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "device_user_provided",
"ordinal": 5,
"type_info": "Varchar"
},
{
"name": "name",
"ordinal": 6,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
true,
false,
false,
false,
false
],
"parameters": {
"Left": [
"Uuid",
"Text",
"Text",
"Int8",
"Int8"
]
}
},
"query": "SELECT\n survey_responses.ID,\n survey_responses.device_software_recognised,\n survey_responses.threads,\n survey_responses.user_id,\n survey_responses.submitted_at,\n survey_responses.device_user_provided,\n survey_bench_type.name\n FROM\n survey_responses\n INNER JOIN survey_bench_type ON\n survey_responses.submission_bench_type_id = survey_bench_type.ID\n WHERE\n survey_bench_type.name = $3\n AND\n survey_responses.campaign_id = (\n SELECT ID FROM survey_campaigns\n WHERE\n ID = $1\n AND\n user_id = (SELECT ID FROM survey_admins WHERE name = $2)\n )\n LIMIT $4 OFFSET $5"
},
"82feafc36533144e49ba374c8c47ca4aa0d6558a9803778ad28cfa7b62382c3e": {
"describe": {
"columns": [],
@ -242,26 +387,31 @@
},
"query": "\n INSERT INTO survey_campaigns (\n user_id, ID, name, difficulties, created_at\n ) VALUES(\n (SELECT id FROM survey_admins WHERE name = $1),\n $2, $3, $4, $5\n );"
},
"8320dda2b3e107d1451fdfb35eb2a4b8e97364e7b1b74ffe4d6913faf132fb61": {
"858a4c06a5c1ba7adb79bcac7d42d106d09d0cbff10c197f2242dcb5c437a1df": {
"describe": {
"columns": [
{
"name": "id",
"name": "created_at",
"ordinal": 0,
"type_info": "Int4"
"type_info": "Timestamptz"
},
{
"name": "id",
"ordinal": 1,
"type_info": "Uuid"
}
],
"nullable": [
false,
false
],
"parameters": {
"Left": [
"Uuid",
"Text"
"Uuid"
]
}
},
"query": "SELECT ID \n FROM survey_responses \n WHERE \n user_id = $1 \n AND \n device_software_recognised = $2;"
"query": "SELECT\n created_at,\n ID\n FROM\n survey_users\n WHERE\n ID = $1\n "
},
"9cdade613ce724631cc3f187510758ee0929e93ff3f8ce81fe35594756644246": {
"describe": {
@ -310,21 +460,31 @@
},
"query": "UPDATE survey_admins set secret = $1\n WHERE name = $2"
},
"b4cd1e5240de1968c8b6d56672cec639b22f41ebf2754dadbf00efe0948c7e68": {
"b2619292aa6bd1ac38dca152cbe607b795a151ddc212361a3c6d8c70ea1c93eb": {
"describe": {
"columns": [],
"nullable": [],
"columns": [
{
"name": "duration",
"ordinal": 0,
"type_info": "Float4"
},
{
"name": "difficulty",
"ordinal": 1,
"type_info": "Int4"
}
],
"nullable": [
false,
false
],
"parameters": {
"Left": [
"Uuid",
"Uuid",
"Varchar",
"Varchar",
"Int4"
]
}
},
"query": "INSERT INTO survey_responses (\n user_id, \n campaign_id,\n device_user_provided,\n device_software_recognised,\n threads\n ) VALUES ($1, $2, $3, $4, $5);"
"query": "SELECT\n duration,\n difficulty\n FROM\n survey_benches\n WHERE\n resp_id = $1\n "
},
"c757589ef26a005e3285e7ab20d8a44c4f2e1cb125f8db061dd198cc380bf807": {
"describe": {

View file

@ -20,7 +20,7 @@ use actix_identity::Identity;
use actix_web::{web, HttpResponse, Responder};
use serde::{Deserialize, Serialize};
use sqlx::types::time::OffsetDateTime;
use uuid::Uuid;
use sqlx::types::Uuid;
use super::{get_admin_check_login, get_uuid};
use crate::api::v1::bench::Bench;
@ -102,7 +102,7 @@ pub mod runners {
username: &str,
payload: &mut AddCapmaign,
data: &AppData,
) -> ServiceResult<uuid::Uuid> {
) -> ServiceResult<sqlx::types::Uuid> {
let mut uuid;
let now = OffsetDateTime::now_utc();
@ -203,7 +203,7 @@ pub mod runners {
impl From<InnerU> for SurveyUser {
fn from(u: InnerU) -> Self {
Self {
id: u.id,
id: uuid::Uuid::parse_str(&u.id.to_string()).unwrap(),
created_at: u.created_at.unix_timestamp(),
}
}
@ -254,13 +254,13 @@ pub mod runners {
} else {
#[derive(Debug)]
struct I {
id: Option<i32>,
submitted_at: Option<OffsetDateTime>,
user_id: Option<Uuid>,
id: i32,
submitted_at: OffsetDateTime,
user_id: Uuid,
threads: Option<i32>,
device_user_provided: Option<String>,
device_software_recognised: Option<String>,
name: Option<String>,
device_user_provided: String,
device_software_recognised: String,
name: String,
}
let mut i = sqlx::query_as!(
I,
@ -296,13 +296,13 @@ pub mod runners {
let mut res = Vec::with_capacity(i.len());
i.drain(0..).for_each(|x| {
res.push(InternalSurveyResp {
id: x.id.unwrap(),
submitted_at: x.submitted_at.unwrap(),
user_id: x.user_id.unwrap(),
id: x.id,
submitted_at: x.submitted_at,
user_id: x.user_id,
threads: x.threads,
device_user_provided: x.device_user_provided.unwrap(),
device_software_recognised: x.device_software_recognised.unwrap(),
name: x.name.unwrap(),
device_user_provided: x.device_user_provided,
device_software_recognised: x.device_software_recognised,
name: x.name,
})
});
res
@ -413,7 +413,7 @@ pub struct SurveyResponse {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SurveyUser {
pub created_at: i64, // OffsetDateTime,
pub id: Uuid,
pub id: uuid::Uuid,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@ -477,12 +477,13 @@ impl ResultsPage {
pub async fn get_campaign_resutls(
id: Identity,
query: web::Query<ResultsPage>,
path: web::Path<Uuid>,
path: web::Path<uuid::Uuid>,
data: AppData,
) -> ServiceResult<impl Responder> {
let username = id.identity().unwrap();
let query = query.into_inner();
let page = query.page();
let path = Uuid::parse_str(&path.to_string()).unwrap();
let results =
runners::get_results(&username, &path, &data, page, 50, query.bench_type)
@ -592,7 +593,7 @@ mod tests {
let responses = super::runners::get_results(
NAME,
&uuid::Uuid::parse_str(&campaign.campaign_id).unwrap(),
&sqlx::types::Uuid::parse_str(&campaign.campaign_id).unwrap(),
&AppData::new(data.clone()),
0,
50,
@ -610,7 +611,7 @@ mod tests {
assert_eq!(
super::runners::get_results(
NAME,
&uuid::Uuid::parse_str(&campaign.campaign_id).unwrap(),
&sqlx::types::Uuid::parse_str(&campaign.campaign_id).unwrap(),
&AppData::new(data.clone()),
0,
50,
@ -624,7 +625,7 @@ mod tests {
assert_eq!(
super::runners::get_results(
NAME,
&uuid::Uuid::parse_str(&campaign.campaign_id).unwrap(),
&sqlx::types::Uuid::parse_str(&campaign.campaign_id).unwrap(),
&AppData::new(data.clone()),
0,
50,

View file

@ -24,7 +24,7 @@ use actix_web::{http, web, HttpResponse, Responder};
use futures::future::try_join_all;
use serde::{Deserialize, Serialize};
use sqlx::types::time::OffsetDateTime;
use uuid::Uuid;
use sqlx::types::Uuid;
use super::{get_uuid, RedirectQuery};
use crate::errors::*;
@ -95,7 +95,7 @@ pub fn services(cfg: &mut web::ServiceConfig) {
pub mod runners {
use super::*;
pub async fn register_runner(data: &AppData) -> ServiceResult<uuid::Uuid> {
pub async fn register_runner(data: &AppData) -> ServiceResult<sqlx::types::Uuid> {
let mut uuid;
let now = OffsetDateTime::now_utc();

View file

@ -16,7 +16,7 @@
*/
use actix_web::web::ServiceConfig;
use serde::Deserialize;
use uuid::Uuid;
use sqlx::types::Uuid;
pub mod admin;
pub mod bench;
@ -44,7 +44,7 @@ pub fn get_random(len: usize) -> String {
}
pub fn get_uuid() -> Uuid {
Uuid::new_v4()
Uuid::parse_str(&uuid::Uuid::new_v4().to_string()).unwrap()
}
#[derive(Deserialize)]

View file

@ -19,8 +19,8 @@ use std::str::FromStr;
use actix_web::http::header::ContentType;
use actix_web::{web, HttpResponse, Responder};
use sqlx::types::Uuid;
use tera::Context;
use uuid::Uuid;
use crate::errors::ServiceError;
use crate::settings::Settings;

View file

@ -19,7 +19,6 @@ use std::cell::RefCell;
use actix_web::http::header::ContentType;
use actix_web::{web, HttpResponse, Responder};
use tera::Context;
use uuid::Uuid;
use crate::AppData;
use crate::PAGES;
@ -56,7 +55,7 @@ impl Bench {
)]
pub async fn bench(
data: AppData,
_path: web::Path<Uuid>,
_path: web::Path<uuid::Uuid>,
) -> PageResult<impl Responder, Bench> {
let bench = Bench::new(&data.settings).render();
let html = ContentType::html();

View file

@ -16,7 +16,7 @@
*/
use actix_identity::Identity;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use sqlx::types::Uuid;
use crate::api::v1::admin::auth::runners::{login_runner, Login, Password};
use crate::api::v1::admin::campaigns::runners;
@ -103,11 +103,11 @@ async fn get_title(
)]
pub async fn delete_campaign(
id: Identity,
path: web::Path<Uuid>,
path: web::Path<uuid::Uuid>,
data: AppData,
) -> PageResult<impl Responder, SudoDelete> {
let username = id.identity().unwrap();
let uuid = path.into_inner();
let uuid = Uuid::parse_str(&path.to_string()).unwrap();
let title = get_title(&username, &uuid, &data)
.await
@ -130,12 +130,13 @@ pub async fn delete_campaign(
)]
pub async fn delete_campaign_submit(
id: Identity,
uuid: web::Path<Uuid>,
uuid: web::Path<uuid::Uuid>,
payload: web::Form<Password>,
data: AppData,
) -> PageResult<impl Responder, SudoDelete> {
let username = id.identity().unwrap();
let payload = payload.into_inner();
let uuid = Uuid::parse_str(&uuid.to_string()).unwrap();
let creds = Login {
login: username,

View file

@ -20,8 +20,8 @@ use std::str::FromStr;
use actix_web::http::header::ContentType;
use actix_web::{web, HttpResponse, Responder};
use serde::{Deserialize, Serialize};
use sqlx::types::Uuid;
use tera::Context;
use uuid::Uuid;
use crate::api::v1::admin::campaigns::{runners, ResultsPage, SurveyResponse};
use crate::errors::ServiceError;

View file

@ -21,8 +21,8 @@ use config::{Config, ConfigError, Environment, File};
use log::{debug, warn};
use serde::Deserialize;
use serde::Serialize;
use sqlx::types::Uuid;
use url::Url;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Server {

View file

@ -28,7 +28,7 @@ use actix_web::{
use lazy_static::lazy_static;
use serde::Serialize;
use uuid::Uuid;
use sqlx::types::Uuid;
use super::*;
use crate::api::v1::admin::{