|
|
@ -34,7 +34,7 @@ impl PostgresGateway { |
|
|
|
// the postgres dep can be removed once refinery supports sqlx
|
|
|
|
let mut conn = Client::connect(&format!("host='{}' dbname='{}' user='{}' password='{}'", host, dbname, username, password), NoTls).unwrap();
|
|
|
|
embedded::migrations::runner().run(&mut conn).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let pool = async_std::task::block_on(async move {
|
|
|
|
let pool = PgPoolOptions::new()
|
|
|
|
.max_connections(5)
|
|
|
@ -42,7 +42,7 @@ impl PostgresGateway { |
|
|
|
|
|
|
|
pool
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
PostgresGateway {
|
|
|
|
pool: pool,
|
|
|
|
}
|
|
|
@ -50,11 +50,11 @@ impl PostgresGateway { |
|
|
|
|
|
|
|
async fn apply_item_modifications(&self, item: ItemEntity) -> ItemEntity {
|
|
|
|
let ItemEntity {id, item, location} = item;
|
|
|
|
|
|
|
|
|
|
|
|
let item = match item {
|
|
|
|
ItemDetail::Mag(mut mag) => {
|
|
|
|
let q = r#"select mag, modifier, item.item -> 'Tool' as feed, item2.item -> 'Tool' as cell
|
|
|
|
from mag_modifier
|
|
|
|
let q = r#"select mag, modifier, item.item -> 'Tool' as feed, item2.item -> 'Tool' as cell
|
|
|
|
from mag_modifier
|
|
|
|
left join item on item.id = cast (modifier ->> 'FeedMag' as integer)
|
|
|
|
left join item as item2 on item2.id = cast (modifier ->> 'MagCell' as integer)
|
|
|
|
where mag = $1 order by created_at"#;
|
|
|
@ -80,7 +80,7 @@ impl PostgresGateway { |
|
|
|
},
|
|
|
|
}
|
|
|
|
}).await;
|
|
|
|
|
|
|
|
|
|
|
|
ItemDetail::Mag(mag)
|
|
|
|
},
|
|
|
|
item @ _ => item
|
|
|
@ -166,7 +166,7 @@ impl EntityGateway for PostgresGateway { |
|
|
|
|
|
|
|
async fn create_character(&mut self, char: NewCharacterEntity) -> Option<CharacterEntity> {
|
|
|
|
let q = r#"insert into player_character
|
|
|
|
(user_account, slot, name, exp, class, section_id, costume, skin, face, head, hair, hair_r, hair_g, hair_b, prop_x, prop_y, techs,
|
|
|
|
(user_account, slot, name, exp, class, section_id, costume, skin, face, head, hair, hair_r, hair_g, hair_b, prop_x, prop_y, techs,
|
|
|
|
config, infoboard, guildcard, power, mind, def, evade, luck, hp, tp, tech_menu, meseta, bank_meseta)
|
|
|
|
values
|
|
|
|
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30)
|
|
|
@ -220,7 +220,7 @@ impl EntityGateway for PostgresGateway { |
|
|
|
let index = character.slot as usize;
|
|
|
|
result[index] = Some(character.into())
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
@ -417,4 +417,3 @@ impl EntityGateway for PostgresGateway { |
|
|
|
).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|