Browse Source

properly select character items based on the latest location

pbs
jake 4 years ago
parent
commit
c067ab444a
  1. 7
      src/entity/gateway/postgres/postgres.rs

7
src/entity/gateway/postgres/postgres.rs

@ -322,6 +322,13 @@ impl EntityGateway for PostgresGateway {
join item on item.id = item_location.item
where cast (location -> 'Inventory' ->> 'character_id' as integer) = $1
or cast (location -> 'Bank' ->> 'character_id' as integer) = $1"#;
let q = r#"select * from (
select distinct on (item_location.item) item.id, item_location.location, item.item
from item_location join item on item.id = item_location.item
order by item_location.item, item_location.created_at desc
) as i
where cast (location -> 'Inventory' ->> 'character_id' as integer) = 2
or cast (location -> 'Bank' ->> 'character_id' as integer) = 2"#;
let items = sqlx::query_as::<_, PgItemWithLocation>(q)
.bind(char.id.0)
.fetch(&self.pool);

Loading…
Cancel
Save