Skip to content

Commit

Permalink
Add support for only importing updated logs
Browse files Browse the repository at this point in the history
This lets me go back and fix all our prematurely-downloaded logs.

Signed-off-by: Sean Anderson <[email protected]>
  • Loading branch information
Forty-Bot committed Aug 27, 2021
1 parent 8fb8c59 commit 0dc612c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions import.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from steamid import SteamID
from sql import db_connect, db_init, table_columns

def filter_logids(c, logids):
def filter_logids(c, logids, update_only=False):
"""Filter log ids to exclude those already present in the database.
:param sqlite3.Connection c: The database connection
Expand Down Expand Up @@ -42,7 +42,8 @@ def filter_logids(c, logids):
if row[0]:
yield logid
else:
yield logid
if not update_only:
yield logid

def import_log(cctx, c, logid, log):
"""Import a log into the database.
Expand Down Expand Up @@ -601,6 +602,8 @@ def __call__(self, parse, namespace, values, option_string=None):
"times for increased verbosity."))

parser.add_argument("database", default="logs.db", help="SQLite database to store logs in")
parser.add_argument("-u", "--update-only", action='store_true',
help="Only update logs already in the database")

return parser.parse_args(*args, **kwargs)

Expand Down Expand Up @@ -700,7 +703,7 @@ def commit():

count = 0
start = datetime.now()
for logid in filter_logids(c, fetcher.get_logids()):
for logid in filter_logids(c, fetcher.get_logids(), update_only=args.update_only):
log = fetcher.get_log(logid)
if log is None:
continue
Expand Down

0 comments on commit 0dc612c

Please sign in to comment.