diff --git a/src/entity/gateway/postgres/postgres.rs b/src/entity/gateway/postgres/postgres.rs index c400da4..3ae3f2c 100644 --- a/src/entity/gateway/postgres/postgres.rs +++ b/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);