refactor: cleanup unused code
This commit is contained in:
parent
85fdd41c6b
commit
6a70345b88
@ -1,27 +1,17 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT * FROM registration WHERE token = $1 AND expires > NOW();",
|
||||
"query": "SELECT token, userId FROM registration WHERE token = $1 AND expires > NOW();",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"ordinal": 1,
|
||||
"name": "userid",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "expires",
|
||||
"type_info": "Timestamp"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@ -30,11 +20,9 @@
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "0b0974fa0c51fe0011990fc3d9b0c4863a313f6cb7f86fe4ea02f6e8c594b4a4"
|
||||
"hash": "1452258f916025c6367477e11a442360d2f6211d3f47b465c0024994006e0c08"
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT EXISTS(SELECT * FROM location WHERE id= $1);",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "exists",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "2d516ada804b4e3306e2a444602b303cf579a1c2d9c445d68f7b17319dc43007"
|
||||
}
|
@ -1,27 +1,17 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO registration (token, userId, expires) VALUES ($1, $2, $3) RETURNING *;",
|
||||
"query": "INSERT INTO registration (token, userId, expires) VALUES ($1, $2, $3) RETURNING token, userId;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"ordinal": 1,
|
||||
"name": "userid",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "expires",
|
||||
"type_info": "Timestamp"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@ -32,11 +22,9 @@
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "b68b7d99cbf993a1cfa4bef1d0eb16caeba5715fced557c2ed017ed9130830e5"
|
||||
"hash": "413a3b2bdb7c23ab0f44bcc3ece79de6106c087ff85ca075fd9ca65a42cfa8cc"
|
||||
}
|
@ -1,27 +1,17 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT * FROM passwordReset WHERE token = $1 AND expires > NOW();",
|
||||
"query": "SELECT token, userId FROM passwordReset WHERE token = $1 AND expires > NOW();",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"ordinal": 1,
|
||||
"name": "userid",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "expires",
|
||||
"type_info": "Timestamp"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@ -30,11 +20,9 @@
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "39e46937dc06fb71beffbe990027946ce741335fefad69f5d92a2adb434b118e"
|
||||
"hash": "b1e4b7c5d9a08923ab0512b2f2d402865f5d63cb828507c856293be62102aeef"
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT count(*) FROM assignment WHERE assignment.eventId = $1 AND assignment.function = $2;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "count",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
{
|
||||
"Custom": {
|
||||
"name": "function",
|
||||
"kind": {
|
||||
"Enum": [
|
||||
"posten",
|
||||
"fuehrungsassistent",
|
||||
"wachhabender"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "de0201654f21edf4852a456006fb7c1c87ff4eb34a3ab141058f31e103746e9c"
|
||||
}
|
@ -1,27 +1,17 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "INSERT INTO passwordReset (token, userId, expires) VALUES ($1, $2, $3) RETURNING *;",
|
||||
"query": "INSERT INTO passwordReset (token, userId, expires) VALUES ($1, $2, $3) RETURNING token, userid;",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "token",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"ordinal": 1,
|
||||
"name": "userid",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "expires",
|
||||
"type_info": "Timestamp"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@ -32,11 +22,9 @@
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "149c662f824b02f0b530c84ea291a3bef0f7d6698ad6b916851060270bb9e67e"
|
||||
"hash": "effd0882ab00e5f91a97fa7ee4275775f369e2f8683a6b1aaa87c35984357804"
|
||||
}
|
@ -100,21 +100,6 @@ impl Assignment {
|
||||
Ok(assignemnets)
|
||||
}
|
||||
|
||||
pub async fn count_by_event_and_function(
|
||||
pool: &PgPool,
|
||||
event_id: i32,
|
||||
function: Function,
|
||||
) -> Result<i64> {
|
||||
let result = query!("SELECT count(*) FROM assignment WHERE assignment.eventId = $1 AND assignment.function = $2;",
|
||||
event_id,
|
||||
function as Function
|
||||
)
|
||||
.fetch_one(pool)
|
||||
.await?;
|
||||
|
||||
Ok(result.count.unwrap_or(0))
|
||||
}
|
||||
|
||||
pub async fn read(
|
||||
pool: &PgPool,
|
||||
event_id: i32,
|
||||
|
@ -138,12 +138,4 @@ impl Location {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn exists(pool: &PgPool, id: i32) -> Result<bool> {
|
||||
let b = query!("SELECT EXISTS(SELECT * FROM location WHERE id= $1);", id)
|
||||
.fetch_one(pool)
|
||||
.await?;
|
||||
|
||||
Ok(b.exists.is_some_and(|e| e))
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use chrono::{NaiveDateTime, TimeDelta};
|
||||
use chrono::TimeDelta;
|
||||
use sqlx::{query_as, PgPool};
|
||||
|
||||
use super::Result;
|
||||
@ -17,10 +17,8 @@ impl Token for NoneToken {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PasswordReset {
|
||||
pub id: i32,
|
||||
pub token: String,
|
||||
pub userid: i32,
|
||||
pub expires: NaiveDateTime,
|
||||
}
|
||||
|
||||
impl PasswordReset {
|
||||
@ -29,7 +27,7 @@ impl PasswordReset {
|
||||
|
||||
let inserted = query_as!(
|
||||
PasswordReset,
|
||||
"INSERT INTO passwordReset (token, userId, expires) VALUES ($1, $2, $3) RETURNING *;",
|
||||
"INSERT INTO passwordReset (token, userId, expires) VALUES ($1, $2, $3) RETURNING token, userid;",
|
||||
token,
|
||||
user_id,
|
||||
expires
|
||||
@ -43,7 +41,7 @@ impl PasswordReset {
|
||||
pub async fn does_token_exist(pool: &PgPool, token: &str) -> Result<Option<PasswordReset>> {
|
||||
let result = query_as!(
|
||||
PasswordReset,
|
||||
"SELECT * FROM passwordReset WHERE token = $1 AND expires > NOW();",
|
||||
"SELECT token, userId FROM passwordReset WHERE token = $1 AND expires > NOW();",
|
||||
token
|
||||
)
|
||||
.fetch_optional(pool)
|
||||
|
@ -1,14 +1,12 @@
|
||||
use chrono::{NaiveDateTime, TimeDelta};
|
||||
use chrono::TimeDelta;
|
||||
use sqlx::{query_as, PgPool};
|
||||
|
||||
use crate::utils::token_generation::generate_token_and_expiration;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Registration {
|
||||
pub id: i32,
|
||||
pub token: String,
|
||||
pub userid: i32,
|
||||
pub expires: NaiveDateTime,
|
||||
}
|
||||
|
||||
use super::{password_reset::Token, Result};
|
||||
@ -19,7 +17,7 @@ impl Registration {
|
||||
|
||||
let inserted = query_as!(
|
||||
Registration,
|
||||
"INSERT INTO registration (token, userId, expires) VALUES ($1, $2, $3) RETURNING *;",
|
||||
"INSERT INTO registration (token, userId, expires) VALUES ($1, $2, $3) RETURNING token, userId;",
|
||||
token,
|
||||
user_id,
|
||||
expires
|
||||
@ -33,7 +31,7 @@ impl Registration {
|
||||
pub async fn does_token_exist(pool: &PgPool, token: &str) -> Result<Option<Registration>> {
|
||||
query_as!(
|
||||
Registration,
|
||||
"SELECT * FROM registration WHERE token = $1 AND expires > NOW();",
|
||||
"SELECT token, userId FROM registration WHERE token = $1 AND expires > NOW();",
|
||||
token
|
||||
)
|
||||
.fetch_optional(pool)
|
||||
|
Loading…
x
Reference in New Issue
Block a user