Skip to content

Commit

Permalink
Eliminated StationLink and minor cleanup
Browse files Browse the repository at this point in the history
"-v" now shows station count for "nav" command instead of "--stations"
  • Loading branch information
kfsone committed Dec 18, 2014
1 parent e0d7b71 commit 9819356
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.2.3 [wip]
. (kfsone) Changed "nav" to show station count with "-v" instead of "--stations"
. (kfsone) Removed the StationLink table - cache builds should be MUCH faster

v6.2.2 Dec 17 2014
. (kfsone) Removed Alloys, Combat Stabilisers, Cotton and Plastics
[there was no entry for them anywhere in the price database]
Expand Down
27 changes: 0 additions & 27 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,31 +775,6 @@ def processImportFile(tdenv, db, importPath, tableName):
table=tableName)


def generateStationLink(tdenv, db):
tdenv.DEBUG0("Generating StationLink table")
db.create_function("sqrt", 1, math.sqrt)
db.execute("""
INSERT INTO StationLink
SELECT lhs.system_id AS lhs_system_id,
lhs.station_id AS lhs_station_id,
rhs.system_id AS rhs_system_id,
rhs.station_id AS rhs_station_id,
sqrt(
((lSys.pos_x - rSys.pos_x) * (lSys.pos_x - rSys.pos_x)) +
((lSys.pos_y - rSys.pos_y) * (lSys.pos_y - rSys.pos_y)) +
((lSys.pos_z - rSys.pos_z) * (lSys.pos_z - rSys.pos_z))
) AS dist
FROM Station AS lhs
INNER JOIN System AS lSys
ON (lhs.system_id = lSys.system_id),
Station AS rhs
INNER JOIN System AS rSys
ON (rhs.system_id = rSys.system_id)
WHERE
lhs.station_id != rhs.station_id
""")
db.commit()


######################################################################

Expand Down Expand Up @@ -858,8 +833,6 @@ def buildCache(tdb, tdenv):
str(pricesPath)
), file=sys.stderr)

generateStationLink(tdenv, tempDB)

tempDB.close()

tdenv.DEBUG0("Swapping out db files")
Expand Down
2 changes: 1 addition & 1 deletion commands/export_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
]

# some tables are ignored
ignoreList = [ 'StationLink',
ignoreList = [
]

######################################################################
Expand Down
8 changes: 1 addition & 7 deletions commands/nav_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
'the system that station is in will be avoided instead.',
action='append',
),
ParseArgument('--stations',
help='Show system\'s stations',
dest='showstations',
action='store_true',
default=False
),
]

######################################################################
Expand Down Expand Up @@ -188,7 +182,7 @@ def render(results, cmdenv, tdb):
key=lambda row: row.system.name())
rowFmt.addColumn("JumpLy", '>', '7', '.2f',
key=lambda row: row.jumpLy)
if cmdenv.showstations:
if cmdenv.detail:
rowFmt.addColumn("Stations", '>', 2,
key=lambda row: len(row.system.stations))
if cmdenv.detail:
Expand Down
29 changes: 0 additions & 29 deletions data/TradeDangerous.sql
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,6 @@ CREATE TABLE StationBuying
/* We're often going to be asking "using (item_id) where buying.price > selling.cost" */
CREATE INDEX idx_buying_price ON StationBuying (item_id, price);

CREATE TABLE StationLink
(
lhs_system_id INTEGER NOT NULL,
lhs_station_id INTEGER NOT NULL,
rhs_system_id INTEGER NOT NULL,
rhs_station_id INTEGER NOT NULL,
dist DOUBLE NOT NULL CHECK (dist > 0.0 or lhs_system_id == rhs_system_id),
PRIMARY KEY (lhs_station_id, rhs_station_id)
) WITHOUT ROWID
;
CREATE INDEX idx_stn_dist ON StationLink (lhs_station_id, dist);
CREATE INDEX idx_sys_dist ON StationLink (lhs_system_id, dist, rhs_system_id);

CREATE VIEW vPrice AS
SELECT si.station_id AS station_id,
si.item_id AS item_id,
Expand Down Expand Up @@ -307,21 +294,5 @@ CREATE VIEW vProfits AS
;


CREATE VIEW vProfitableTrades AS
SELECT src.station_id AS src_station_id,
src.item_id AS item_id,
dst.station_id AS dst_station_id,
src.price AS cost,
dst.price - src.price AS profit,
link.dist AS dist
FROM StationSelling AS src
INNER JOIN StationBuying AS dst
ON (src.item_id = dst.item_id AND dst.price > src.price)
INNER JOIN StationLink AS link
ON (src.station_id = link.lhs_station_id
AND dst.station_id = link.rhs_station_id)
;


COMMIT;

0 comments on commit 9819356

Please sign in to comment.