From: Peter Amstutz Date: Wed, 16 Jun 2021 21:22:04 +0000 (-0400) Subject: 17464: Activity report lists upload/download events X-Git-Tag: 2.3.0~167^2~12 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/154ba68b8f66e50d9ddb53f3a5f19890588f42f4 17464: Activity report lists upload/download events Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- diff --git a/tools/user-activity/arvados_user_activity/main.py b/tools/user-activity/arvados_user_activity/main.py index 959f16d898..997da57e05 100755 --- a/tools/user-activity/arvados_user_activity/main.py +++ b/tools/user-activity/arvados_user_activity/main.py @@ -41,6 +41,13 @@ def getuserinfo(arv, uuid): arv.config()["Services"]["Workbench1"]["ExternalURL"], uuid, prof) +collectionNameCache = {} +def getCollectionName(arv, uuid): + if uuid not in collectionNameCache: + u = arv.collections().get(uuid=uuid).execute() + collectionNameCache[uuid] = u["name"] + return collectionNameCache[uuid] + def getname(u): return "\"%s\" (%s)" % (u["name"], u["uuid"]) @@ -137,6 +144,19 @@ def main(arguments=None): else: users[owner].append("%s Deleted collection %s %s" % (event_at, getname(e["properties"]["old_attributes"]), loguuid)) + elif e["event_type"] == "file_download": + users[e["object_uuid"]].append("%s Downloaded file \"%s\" from \"%s\" (%s) (%s)" % (event_at, + e["properties"].get("collection_file_path") or e["properties"].get("reqPath"), + getCollectionName(arv, e["properties"].get("collection_uuid")), + e["properties"].get("collection_uuid"), + e["properties"].get("portable_data_hash"))) + + elif e["event_type"] == "file_upload": + users[e["object_uuid"]].append("%s Uploaded file \"%s\" to \"%s\" (%s)" % (event_at, + e["properties"].get("collection_file_path") or e["properties"].get("reqPath"), + getCollectionName(arv, e["properties"].get("collection_uuid")), + e["properties"].get("collection_uuid"))) + else: users[owner].append("%s %s %s %s" % (e["event_type"], e["object_kind"], e["object_uuid"], loguuid))