Skip to content

Commit

Permalink
Minor tweaks to Gazelle's change, also added it to the README.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Smith committed Oct 18, 2014
1 parent de7b4d4 commit ece1a10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ v4.3.0 Oct 17/2014
value for demand/stock levels "0" instead of "-1". (-1 means 'unknown'.
Use this option if you are editing timestamps and stock levels and all
those '-'s get in your way)
. (gazelle) Moved Star, System, etc data out of ".sql" file and into
per-table ".csv" files. This should make it much easier for people to
share and synchronize data and make it less daunting for people to
maintain their data files. Great work, Gazelle!

v4.2.3 Oct 17/2014
. (ShadowGar, Smacker65) Imported Harbinger and RedWizzard system data,
Expand Down
26 changes: 10 additions & 16 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,16 @@ def getMostRecentTimestamp(altPath):
sqlTimestamp, pricesTimestamp = getMostRecentTimestamp(self.sqlPath), getMostRecentTimestamp(self.pricesPath)

# rebuild if the sql or prices file is more recent than the db file
rebuild = ( max(sqlTimestamp, pricesTimestamp) >= dbFileCreatedTimestamp )
if not rebuild:
# check if any table files have changed
for (fileName, tableName) in self.importTables:
if getMostRecentTimestamp(Path(fileName)) > dbFileCreatedTimestamp:
if self.debug: print("* file '{}' updated".format(fileName))
rebuild = True
break

if not rebuild:
if self.debug > 1:
print("- SQLite is up to date")
return

if self.debug:
print("* Rebuilding DB Cache [db:{}, sql:{}, prices:{}]".format(dbFileCreatedTimestamp, sqlTimestamp, pricesTimestamp))
if max(sqlTimestamp, pricesTimestamp) < dbFileCreatedTimestamp:
# sql and prices file are older than the db, db may be upto date,
# check if any of the table files have changed.
changedFiles = [ fileName for (fileName, _) in self.importTables if getMostRecentTimestamp(Path(fileName)) > dbFileCreatedTimestamp ]
if not changedFiles:
if self.debug > 1: print("- DB Cache is up to date.")
return
if self.debug: print("* Rebuilding DB Cache because of modified {}".format(', '.join(changedFiles)))
else:
if self.debug: print("* Rebuilding DB Cache [db:{}, sql:{}, prices:{}]".format(dbFileCreatedTimestamp, sqlTimestamp, pricesTimestamp))
else:
if self.debug:
print("* Building DB cache")
Expand Down

0 comments on commit ece1a10

Please sign in to comment.