Skip to content

Commit

Permalink
feat(bin): script for increasing artifacts of users (#83)
Browse files Browse the repository at this point in the history
* feat(bin): script increasing artifacts

* fix: change bonus artifact count

* fix: add log after threads

---------

Co-authored-by: DonWIck32 <[email protected]>
  • Loading branch information
itsKhadeer and DonWick32 authored Feb 23, 2024
1 parent a8baf59 commit c49b4f2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/attack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,13 @@ async fn socket_handler(
}
});

log::info!(
"End of Game:{}, Attacker:{} and Defender:{}",
game_id,
attacker_id,
defender_id,
);

Ok(response)
}

Expand Down
42 changes: 42 additions & 0 deletions src/bin/add_500_artifacts_to_users.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use anyhow::Ok;
use aot_backend::constants::BANK_BUILDING_NAME;
use aot_backend::models::BlockCategory;
use aot_backend::schema::{artifact, block_type, building_type, map_spaces, user};
use aot_backend::util;
use diesel::prelude::*;
use diesel::QueryDsl;

fn main() {
let artifacts_to_increase_for_all_players = 750;

let pool = util::get_pg_conn_pool();
let mut conn = pool.get().expect("Could not retrieve connection from pool");

// list of all bank's (level 1, 2, 3) space ids
let map_space_ids: Vec<i32> = map_spaces::table
.inner_join(block_type::table.inner_join(building_type::table))
.filter(block_type::category.eq(BlockCategory::Building))
.filter(building_type::name.like(BANK_BUILDING_NAME))
.select(map_spaces::id)
.load::<i32>(&mut conn)
.expect("Could not get map space ids");

let _ = Ok(conn.transaction(|conn| {
for map_space_id in map_space_ids {
diesel::update(artifact::table.filter(artifact::map_space_id.eq(map_space_id)))
.set(artifact::count.eq(artifact::count + artifacts_to_increase_for_all_players))
.execute(conn)?;
}

diesel::update(user::table)
.set(user::artifacts.eq(user::artifacts + artifacts_to_increase_for_all_players))
.execute(conn)?;

Ok(())
}));

println!(
"Added {} artifacts to all users",
artifacts_to_increase_for_all_players
);
}

0 comments on commit c49b4f2

Please sign in to comment.