MemOpt #18
+1
-1
File diff suppressed because one or more lines are too long
+13
-1
@@ -37,7 +37,7 @@ def pullPolicyExechistories(url, policiesnames, days, outputjson: bool):
|
||||
|
||||
headers = {"X-APIKey": os.getenv('APIKEY')}
|
||||
|
||||
checkpoint = '000000000000000000000000'
|
||||
checkpoint = str(skipback(days))
|
||||
json_output = {'error': 'Success', 'response': {'exechistories': []}}
|
||||
|
||||
while True:
|
||||
@@ -158,4 +158,16 @@ def listAllowlists(url):
|
||||
#Need else and catch for upper bound
|
||||
|
||||
|
||||
def skipback(days):
|
||||
"""
|
||||
Generate a MongoDB ObjectId for a given number of days ago from today.
|
||||
Adds 1 extra day to the input to look further back.
|
||||
"""
|
||||
adjusted_days = days + 1
|
||||
date_days_ago = datetime.datetime.now(datetime.UTC) - datetime.timedelta(days=adjusted_days)
|
||||
timestamp = int(date_days_ago.timestamp())
|
||||
hex_timestamp = format(timestamp, '08x')
|
||||
objectid_hex = hex_timestamp + '0000000000000000'
|
||||
return ObjectId(objectid_hex)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user