From 9a61903d28dd38bbbce2b66a61224d8f52ff613c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 3 Dec 2013 16:48:44 -0500 Subject: [PATCH] Fix date time parameter on log_action to properly use the current time (for reals) --- data/model.py | 8 ++++---- initdb.py | 18 +++++++++--------- test/data/test.db | Bin 101376 -> 339968 bytes 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/data/model.py b/data/model.py index 50ef5892e..f95fe5a2a 100644 --- a/data/model.py +++ b/data/model.py @@ -1067,12 +1067,12 @@ def list_logs(user_or_organization_name, repository = None): return joined.where(User.username == user_or_organization_name, LogEntry.datetime >= week_ago).order_by(LogEntry.datetime.desc()) def log_action(kind_name, user_or_organization_name, performer=None, repository=None, - access_token=None, ip=None, metadata={}, datetime=None): - if not datetime: - datetime = datetime.today() + access_token=None, ip=None, metadata={}, timestamp=None): + if not timestamp: + timestamp = datetime.today() kind = LogEntryKind.get(LogEntryKind.name == kind_name) account = User.get(User.username == user_or_organization_name) entry = LogEntry.create(kind=kind, account=account, performer=performer, repository=repository, access_token=access_token, ip=ip, - metadata_json=json.dumps(metadata), datetime=datetime) + metadata_json=json.dumps(metadata), datetime=timestamp) diff --git a/initdb.py b/initdb.py index f1c3c5788..5dc75e52f 100644 --- a/initdb.py +++ b/initdb.py @@ -252,31 +252,31 @@ def populate_database(): six_ago = today - timedelta(5) four_ago = today - timedelta(4) - model.log_action('org_create_team', org.username, performer=new_user_1, datetime=week_ago, + model.log_action('org_create_team', org.username, performer=new_user_1, timestamp=week_ago, metadata={'team': 'readers'}) - model.log_action('org_set_team_role', org.username, performer=new_user_1, datetime=week_ago, + model.log_action('org_set_team_role', org.username, performer=new_user_1, timestamp=week_ago, metadata={'team': 'readers', 'role': 'read'}) - model.log_action('create_repo', org.username, performer=new_user_1, repository=org_repo, datetime=week_ago, + model.log_action('create_repo', org.username, performer=new_user_1, repository=org_repo, timestamp=week_ago, metadata={'namespace': org.username, 'repo': 'orgrepo'}) - model.log_action('change_repo_permission', org.username, performer=new_user_2, repository=org_repo, datetime=six_ago, + model.log_action('change_repo_permission', org.username, performer=new_user_2, repository=org_repo, timestamp=six_ago, metadata={'username': new_user_1.username, 'repo': 'orgrepo', 'role': 'admin'}) - model.log_action('change_repo_permission', org.username, performer=new_user_1, repository=org_repo, datetime=six_ago, + model.log_action('change_repo_permission', org.username, performer=new_user_1, repository=org_repo, timestamp=six_ago, metadata={'username': new_user_2.username, 'repo': 'orgrepo', 'role': 'read'}) - model.log_action('add_repo_accesstoken', org.username, performer=new_user_1, repository=org_repo, datetime=four_ago, + model.log_action('add_repo_accesstoken', org.username, performer=new_user_1, repository=org_repo, timestamp=four_ago, metadata={'repo': 'orgrepo', 'token': 'deploytoken'}) - model.log_action('push_repo', org.username, performer=new_user_2, repository=org_repo, datetime=today, + model.log_action('push_repo', org.username, performer=new_user_2, repository=org_repo, timestamp=today, metadata={'username': new_user_2.username, 'repo': 'orgrepo'}) - model.log_action('pull_repo', org.username, performer=new_user_2, repository=org_repo, datetime=today, + model.log_action('pull_repo', org.username, performer=new_user_2, repository=org_repo, timestamp=today, metadata={'username': new_user_2.username, 'repo': 'orgrepo'}) - model.log_action('pull_repo', org.username, repository=org_repo, datetime=today, + model.log_action('pull_repo', org.username, repository=org_repo, timestamp=today, metadata={'token': 'sometoken', 'token_code': 'somecode', 'repo': 'orgrepo'}) if __name__ == '__main__': diff --git a/test/data/test.db b/test/data/test.db index fdb9329a01d83bc1012a996d0e100dbe7a96a2a9..c2ef5d6528ab19aa099da05eaf5e87dfae0471c3 100644 GIT binary patch delta 12965 zcmd5i33yc1x%bSSnLFz}2}u}|5HcAOLm*@_nI#D^kd^Fv$bw?XG6^9oS%84)5Cna7 zc?FJg70W}VJgU{I#WpAqQms-~6hx#{;i-sh1)h7YU*CW3ESY2ywe@Si7s$!I=U>l% z{(H{<|L1JDU%ugNU~ENMVQZgV-`v&HQQxOGGky$0OqyQLFo-Y=Qvtv3pS-QH=4`^u z{~%HZT@w5S1tjBd@E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