Skip to content

Commit

Permalink
make changes to non-listings of markets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ctri-The-Third committed Feb 28, 2024
1 parent e60dbe0 commit 360baa7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions PostgresSchema.SQL
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion straders_sdk/client_mediator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
10 changes: 6 additions & 4 deletions straders_sdk/client_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions straders_sdk/pg_pieces/upsert_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _upsert_market(market: Market, connection):
(
market.symbol,
trade_good.symbol,
"sell",
"EXPORT",
trade_good.name,
trade_good.description,
),
Expand All @@ -43,7 +43,7 @@ def _upsert_market(market: Market, connection):
(
market.symbol,
trade_good.symbol,
"buy",
"IMPORT",
trade_good.name,
trade_good.description,
),
Expand All @@ -57,7 +57,7 @@ def _upsert_market(market: Market, connection):
(
market.symbol,
trade_good.symbol,
"exchange",
"EXCHANGE",
trade_good.name,
trade_good.description,
),
Expand Down

0 comments on commit 360baa7

Please sign in to comment.