bumb dependencies

This commit is contained in:
Robin Appelman 2022-06-04 23:48:24 +02:00
commit 87ff3a084b
6 changed files with 973 additions and 482 deletions

View file

@ -1,7 +1,7 @@
use serde::Deserialize;
#[derive(Debug, Clone, Copy, sqlx::Type, Deserialize, Eq, PartialEq)]
#[sqlx(rename = "team")]
#[sqlx(type_name = "team")]
#[sqlx(rename_all = "lowercase")]
pub enum TeamId {
Blue,
@ -19,7 +19,7 @@ impl Default for TeamId {
#[derive(Debug, Clone, Copy, sqlx::Type, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
#[sqlx(rename_all = "lowercase")]
#[sqlx(rename = "class_type")]
#[sqlx(type_name = "class_type")]
pub enum Class {
Scout,
Soldier,
@ -35,7 +35,7 @@ pub enum Class {
}
#[derive(Debug, Clone, Copy, sqlx::Type, Eq, PartialEq)]
#[sqlx(rename = "game_mode")]
#[sqlx(type_name = "game_mode")]
pub enum GameMode {
#[sqlx(rename = "ultiduo")]
UltiDuo,
@ -80,7 +80,7 @@ impl Default for Medigun {
#[derive(Debug, Clone, Copy, sqlx::Type, Eq, PartialEq)]
#[sqlx(rename_all = "lowercase")]
#[sqlx(rename = "map_type")]
#[sqlx(type_name = "map_type")]
pub enum MapType {
Stopwatch,
Cp,

View file

@ -6,8 +6,9 @@ mod raw;
use crate::database::{store_log, upgrade};
use crate::normalized::NormalizedLog;
use main_error::MainError;
use sqlx::{postgres::PgQueryAs, PgPool};
use tokio::time::{delay_for, Duration};
use sqlx::pool::PoolOptions;
use sqlx::PgPool;
use tokio::time::{sleep, Duration};
use tracing::{error, info, instrument};
const OLD_VERSION: i16 = 1;
@ -21,15 +22,18 @@ async fn main() -> Result<(), MainError> {
loop {
normalize(&database_url, &raw_database_url).await?;
delay_for(Duration::from_secs(15 * 60)).await;
sleep(Duration::from_secs(15 * 60)).await;
}
}
async fn normalize(database_url: &str, raw_database_url: &str) -> Result<(), MainError> {
let pool = PgPool::builder().max_size(2).build(database_url).await?;
let raw_pool = PgPool::builder()
.max_size(2)
.build(raw_database_url)
let pool = PoolOptions::new()
.max_connections(2)
.connect(database_url)
.await?;
let raw_pool = PoolOptions::new()
.max_connections(2)
.connect(raw_database_url)
.await?;
let max = get_max_log(&raw_pool).await?;

View file

@ -1,7 +1,7 @@
use crate::data::{Class, Medigun, TeamId};
use serde::Deserialize;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::convert::{TryFrom, TryInto};
use steamid_ng::SteamID;
#[derive(Debug, Clone, Deserialize)]
@ -284,13 +284,13 @@ pub enum ChatFrom {
}
impl TryFrom<String> for ChatFrom {
type Error = steamid_ng::SteamIDParseError;
type Error = steamid_ng::SteamIDError;
fn try_from(value: String) -> Result<Self, Self::Error> {
if value == "Console" {
Ok(ChatFrom::Console)
} else {
value.parse().map(ChatFrom::Player)
value.as_str().try_into().map(ChatFrom::Player)
}
}
}