From 360baa72c154c36f144e77b12b54d1cfdfce93b8 Mon Sep 17 00:00:00 2001 From: C'tri Goudie Date: Wed, 28 Feb 2024 16:50:21 +0000 Subject: [PATCH] make changes to non-listings of markets --- PostgresSchema.SQL | 8 ++++---- straders_sdk/client_mediator.py | 2 +- straders_sdk/client_postgres.py | 10 ++++++---- straders_sdk/pg_pieces/upsert_market.py | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/PostgresSchema.SQL b/PostgresSchema.SQL index fae03c6..d82932b 100644 --- a/PostgresSchema.SQL +++ b/PostgresSchema.SQL @@ -911,10 +911,10 @@ ALTER VIEW public.market_supply_changes_and_market_movements OWNER TO spacetrade -- Name: market_tradegood; Type: TABLE; Schema: public; Owner: spacetraders -- -CREATE TABLE public.market_tradegood ( - market_waypoint text NOT NULL, - symbol text NOT NULL, - buy_or_sell text, +CREATE TABLE public.market_tradegoods ( + market_symbol text NOT NULL, + trade_symbol text NOT NULL, + type text, name text, description text, market_symbol text, diff --git a/straders_sdk/client_mediator.py b/straders_sdk/client_mediator.py index 6b0e35f..ab18a9a 100644 --- a/straders_sdk/client_mediator.py +++ b/straders_sdk/client_mediator.py @@ -879,7 +879,7 @@ def ship_orbit(self, ship: "Ship"): if resp: ship.update(resp.data) self.db_client.update(ship) - return + return resp def ship_patch_nav(self, ship: "Ship", flight_mode: str): """my/ships/:shipSymbol/course""" diff --git a/straders_sdk/client_postgres.py b/straders_sdk/client_postgres.py index 091e84f..994cf98 100644 --- a/straders_sdk/client_postgres.py +++ b/straders_sdk/client_postgres.py @@ -595,15 +595,17 @@ def construction_supply(self, wp, ship, trade_symbol, quantity): def system_market(self, wp: Waypoint) -> Market or SpaceTradersResponse: """/game/systems/{symbol}/marketplace""" try: - sql = """SELECT mt.symbol, mt.name, mt.description FROM market_tradegood mt where mt.market_waypoint = %s""" + sql = """SELECT mt.trade_symbol, mt.name, mt.description, mt.type, FROM market_tradegoods mt where mt.market_symbol = %s""" rows = try_execute_select(sql, (wp.symbol,), self.connection) if not rows: return LocalSpaceTradersRespose( f"Could not find market data for that waypoint", 0, 0, sql ) - imports = [MarketTradeGood(*row) for row in rows if row[2] == "buy"] - exports = [MarketTradeGood(*row) for row in rows if row[2] == "sell"] - exchanges = [MarketTradeGood(*row) for row in rows if row[2] == "exchange"] + imports = [MarketTradeGood(*row[0:3]) for row in rows if row[3] == "IMPORT"] + exports = [MarketTradeGood(*row[0:3]) for row in rows if row[3] == "EXPORT"] + exchanges = [ + MarketTradeGood(*row[0:3]) for row in rows if row[3] == "EXCHANGE" + ] listings_sql = """select trade_symbol, market_depth , type, supply, purchase_price, sell_price, last_updated, activity from market_tradegood_listings mtl diff --git a/straders_sdk/pg_pieces/upsert_market.py b/straders_sdk/pg_pieces/upsert_market.py index fcddfa4..25cce7c 100644 --- a/straders_sdk/pg_pieces/upsert_market.py +++ b/straders_sdk/pg_pieces/upsert_market.py @@ -29,7 +29,7 @@ def _upsert_market(market: Market, connection): ( market.symbol, trade_good.symbol, - "sell", + "EXPORT", trade_good.name, trade_good.description, ), @@ -43,7 +43,7 @@ def _upsert_market(market: Market, connection): ( market.symbol, trade_good.symbol, - "buy", + "IMPORT", trade_good.name, trade_good.description, ), @@ -57,7 +57,7 @@ def _upsert_market(market: Market, connection): ( market.symbol, trade_good.symbol, - "exchange", + "EXCHANGE", trade_good.name, trade_good.description, ),