-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patharchive_id_batcher.py
More file actions
23 lines (19 loc) · 1 KB
/
archive_id_batcher.py
File metadata and controls
23 lines (19 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Module to make batches of unfetched archive IDs and store them in the DB."""
import sys
import db_functions
import config_utils
DEFAULT_BATCH_SIZE = 1000
DEFAULT_MIN_AD_CREATION_DATE = '2019-01-01'
def main(config):
country_code = config.get('SEARCH', 'COUNTRY_CODE', fallback=None)
min_ad_creation_date = config.get('SEARCH', 'MIN_AD_CREATION_DATE',
fallback=DEFAULT_MIN_AD_CREATION_DATE)
with config_utils.get_database_connection_from_config(config) as database_connection:
database_interface = db_functions.DBInterface(database_connection)
database_interface.make_snapshot_fetch_batches(batch_size=DEFAULT_BATCH_SIZE,
country_code=country_code,
min_ad_creation_date=min_ad_creation_date)
if __name__ == '__main__':
config_utils.configure_logger('archive_id_batcher.log')
config = config_utils.get_config(sys.argv[1])
main(config)