From 4c310393d02d2c45b2788fecf5133acd52a45fbc Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 22 2016 10:52:08 +0000 Subject: Move logging the commits in the DB outside the default hook --- diff --git a/pagure/hooks/files/default_hook.py b/pagure/hooks/files/default_hook.py index f0bb3ae..33f3c8b 100755 --- a/pagure/hooks/files/default_hook.py +++ b/pagure/hooks/files/default_hook.py @@ -5,6 +5,7 @@ """ from __future__ import print_function +import json import os import sys @@ -21,6 +22,8 @@ import pagure import pagure.exceptions import pagure.lib.link +from pagure.lib import REDIS + abspath = os.path.abspath(os.environ['GIT_DIR']) @@ -69,8 +72,16 @@ def run_as_post_receive_hook(): commits = pagure.lib.git.get_revs_between( oldrev, newrev, abspath, refname) - pagure.lib.git.log_commits_to_db( - pagure.SESSION, project, commits, abspath) + + if REDIS: + print('Sending to redis to log activity') + REDIS.publish('pagure.logcom', + json.dumps({ + 'project': project.to_json(public=True), + 'abspath': abspath, + 'commits': commits, + } + )) try: # Reset the merge_status of all opened PR to refresh their cache