formatting

This commit is contained in:
Robin Appelman 2020-06-18 14:51:06 +02:00
commit 491a0daae4
2 changed files with 20 additions and 18 deletions

View file

@ -211,24 +211,25 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
.id; .id;
for class in &player.class_stats { for class in &player.class_stats {
let class_stat_id: i32 = sqlx::query!( if class.class != Class::Unknown {
"INSERT INTO class_stats(player_id, type, time, kills, deaths, assists, dmg)\ let class_stat_id: i32 = sqlx::query!(
"INSERT INTO class_stats(player_id, type, time, kills, deaths, assists, dmg)\
VALUES($1, $2, $3, $4, $5, $6, $7)\ VALUES($1, $2, $3, $4, $5, $6, $7)\
RETURNING id", RETURNING id",
player_id, player_id,
class.class as Class, class.class as Class,
class.total_time as i32, class.total_time as i32,
class.kills as i32, class.kills as i32,
class.deaths as i32, class.deaths as i32,
class.assists as i32, class.assists as i32,
class.dmg as i32, class.dmg as i32,
) )
.fetch_one(&mut tx) .fetch_one(&mut tx)
.await? .await?
.id; .id;
for (weapon, stats) in &class.weapon { for (weapon, stats) in &class.weapon {
sqlx::query!( sqlx::query!(
"INSERT INTO player_weapon_stats(class_stat_id, weapon, kills, shots, hits, dmg)\ "INSERT INTO player_weapon_stats(class_stat_id, weapon, kills, shots, hits, dmg)\
VALUES($1, $2, $3, $4, $5, $6)", VALUES($1, $2, $3, $4, $5, $6)",
class_stat_id as i32, class_stat_id as i32,
@ -238,8 +239,9 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
stats.hits as i32, stats.hits as i32,
stats.dmg as i32, stats.dmg as i32,
) )
.execute(&mut tx) .execute(&mut tx)
.await?; .await?;
}
} }
} }
} }

View file

@ -23,7 +23,7 @@ async fn main() -> Result<(), MainError> {
let from = get_max_stored_log(&pool).await?; let from = get_max_stored_log(&pool).await?;
for id in (from + 1)..=max { for id in (from + 1)..=max {
println!("{}", id); print!("{} ", id);
if let Some(log) = get_log(&raw_pool, id).await? { if let Some(log) = get_log(&raw_pool, id).await? {
println!("{}", log.info.map); println!("{}", log.info.map);
store_log(&pool, id, &log).await?; store_log(&pool, id, &log).await?;