# HG changeset patch # User Ludovic Chabant # Date 1692555271 25200 # Node ID 1db1890edcf568308b325a0d98be9fb70646df4b # Parent c5f73ebb43a54d4df25096b74cd5da7144a6aef8 Change populate command's 'until' argument to be exclusive and support time The argument can now specify a time within the day, but this forces the argument to now be exclusive. So if only a date is provided (no time), you need to enter the next day, i.e. the first day to *not* be included. This makes the argument effectively exclusive. diff -r c5f73ebb43a5 -r 1db1890edcf5 silorider/commands/utils.py --- a/silorider/commands/utils.py Sun May 21 09:42:11 2023 -0700 +++ b/silorider/commands/utils.py Sun Aug 20 11:14:31 2023 -0700 @@ -1,4 +1,5 @@ import logging +import datetime from ..parse import parse_url @@ -39,8 +40,9 @@ until_dt = None if ctx.args.until: - until_dt = dateutil.parser.parse(ctx.args.until).date() + until_dt = dateutil.parser.parse(ctx.args.until) logger.debug("Populating cache until: %s" % until_dt) + until_dt = until_dt.timestamp() for url in urls: logger.info("Caching entries from %s" % url) @@ -71,7 +73,10 @@ if isinstance(entry_published, list): entry_published = entry_published[0] - if entry_published and entry_published.date() > until_dt: + if entry_published and entry_published.timestamp() > until_dt: + logger.debug( + "Skipping entry because it's later than the 'until' date: %s" % + entry_published) continue for silo in silos: diff -r c5f73ebb43a5 -r 1db1890edcf5 silorider/main.py --- a/silorider/main.py Sun May 21 09:42:11 2023 -0700 +++ b/silorider/main.py Sun Aug 20 11:14:31 2023 -0700 @@ -85,7 +85,7 @@ help="Only populate the given silo(s).") parser.add_argument( '--until', - help="The date until which to populate the cache (included).") + help="The date until which to populate the cache (excluded).") parser.add_argument( '--dry-run', action='store_true', diff -r c5f73ebb43a5 -r 1db1890edcf5 tests/test_commands_populate.py --- a/tests/test_commands_populate.py Sun May 21 09:42:11 2023 -0700 +++ b/tests/test_commands_populate.py Sun Aug 20 11:14:31 2023 -0700 @@ -44,7 +44,7 @@ feed = cli.createTempFeed(feed2) cli.appendSiloConfig('test', 'print', items='name') cli.setFeedConfig('feed', feed) - ctx, _ = cli.run('populate', '-s', 'test', '--until', '2018-01-08') + ctx, _ = cli.run('populate', '-s', 'test', '--until', '2018-01-08 9AM') assert ctx.cache.wasPosted('test', 'https://example.org/first-article') assert ctx.cache.wasPosted('test', 'https://example.org/second-article') assert not ctx.cache.wasPosted('test', 'https://example.org/third-article')