Commit b611da36 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Fixes for google_archive_data

* Add midnight end time to OAuth logging
* Fix lookback mechanism for login reporting
* Correct midnight-to-midnight issue with login reporting; add dynamic
* hour.
parent 19cd915b
......@@ -175,6 +175,11 @@ class Archiver():
datetime.today() - timedelta(1),
'%Y-%m-%dT00:00:00Z'
),
'end',
datetime.strftime(
datetime.today(),
'%Y-%m-%dT00:00:00Z'
),
'event',
'authorize'
]).decode('utf-8')
......@@ -231,8 +236,8 @@ class Archiver():
self.upload_to_drive('oauth')
def log_logins(self):
lookback_start = datetime.now() - timedelta(hours=(self.lookback + 5))
lookback_end = datetime.now() - timedelta(hours=(self.lookback + 4))
lookback_start = datetime.now() - timedelta(hours=(self.lookback + 1))
lookback_end = datetime.now() - timedelta(hours=self.lookback)
hour = datetime.now().hour - self.lookback
for i in range(5):
......@@ -242,9 +247,9 @@ class Archiver():
'report',
'login',
'start',
datetime.strftime(lookback_start, '%Y-%m-%dT00:00:00Z'),
datetime.strftime(lookback_start, '%Y-%m-%dT%H:00:00Z'),
'end',
datetime.strftime(lookback_end, '%Y-%m-%dT00:00:00Z')
datetime.strftime(lookback_end, '%Y-%m-%dT%H:00:00Z')
]).decode('utf-8')
break
except CalledProcessError as e:
......@@ -289,13 +294,6 @@ class Archiver():
extra={'entity': line['parameters.0.value']}
)
# Upload logfile to Google
log = '{}-{}'.format(
'logins',
hour
)
self.upload_to_drive(log)
def upload_to_drive(self, log_type):
logfile = '{}/{}.csv'.format(self.data_dir, log_type)
if stat(logfile).st_size == 0:
......@@ -437,7 +435,7 @@ def main():
help='''
The number of hours back in time to look for data for.
Used with login reporting to account for inherant delay.''',
default=2
default=4
)
parser.add_argument(
'-d',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment