|
@ -34,7 +34,7 @@ impl PostgresGateway { |
|
|
// the postgres dep can be removed once refinery supports sqlx
|
|
|
// 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();
|
|
|
let mut conn = Client::connect(&format!("host='{}' dbname='{}' user='{}' password='{}'", host, dbname, username, password), NoTls).unwrap();
|
|
|
embedded::migrations::runner().run(&mut conn).unwrap();
|
|
|
embedded::migrations::runner().run(&mut conn).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pool = async_std::task::block_on(async move {
|
|
|
let pool = async_std::task::block_on(async move {
|
|
|
let pool = PgPoolOptions::new()
|
|
|
let pool = PgPoolOptions::new()
|
|
|
.max_connections(5)
|
|
|
.max_connections(5)
|
|
@ -42,7 +42,7 @@ impl PostgresGateway { |
|
|
|
|
|
|
|
|
pool
|
|
|
pool
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PostgresGateway {
|
|
|
PostgresGateway {
|
|
|
pool: pool,
|
|
|
pool: pool,
|
|
|
}
|
|
|
}
|
|
@ -50,11 +50,11 @@ impl PostgresGateway { |
|
|
|
|
|
|
|
|
async fn apply_item_modifications(&self, item: ItemEntity) -> ItemEntity {
|
|
|
async fn apply_item_modifications(&self, item: ItemEntity) -> ItemEntity {
|
|
|
let ItemEntity {id, item, location} = item;
|
|
|
let ItemEntity {id, item, location} = item;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let item = match item {
|
|
|
let item = match item {
|
|
|
ItemDetail::Mag(mut mag) => {
|
|
|
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 on item.id = cast (modifier ->> 'FeedMag' as integer)
|
|
|
left join item as item2 on item2.id = cast (modifier ->> 'MagCell' as integer)
|
|
|
left join item as item2 on item2.id = cast (modifier ->> 'MagCell' as integer)
|
|
|
where mag = $1 order by created_at"#;
|
|
|
where mag = $1 order by created_at"#;
|
|
@ -80,7 +80,7 @@ impl PostgresGateway { |
|
|
},
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
}).await;
|
|
|
}).await;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemDetail::Mag(mag)
|
|
|
ItemDetail::Mag(mag)
|
|
|
},
|
|
|
},
|
|
|
item @ _ => item
|
|
|
item @ _ => item
|
|
@ -166,7 +166,7 @@ impl EntityGateway for PostgresGateway { |
|
|
|
|
|
|
|
|
async fn create_character(&mut self, char: NewCharacterEntity) -> Option<CharacterEntity> {
|
|
|
async fn create_character(&mut self, char: NewCharacterEntity) -> Option<CharacterEntity> {
|
|
|
let q = r#"insert into player_character
|
|
|
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)
|
|
|
config, infoboard, guildcard, power, mind, def, evade, luck, hp, tp, tech_menu, meseta, bank_meseta)
|
|
|
values
|
|
|
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)
|
|
|
($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;
|
|
|
let index = character.slot as usize;
|
|
|
result[index] = Some(character.into())
|
|
|
result[index] = Some(character.into())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result
|
|
|
result
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -417,4 +417,3 @@ impl EntityGateway for PostgresGateway { |
|
|
).await
|
|
|
).await
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|