{"action":"created","comment":{"url":"https://api.github.com/repos/project-hatohol/hatohol/pulls/comments/33325754","id":33325754,"diff_hunk":"@@ -0,0 +1,113 @@\n+#!/usr/bin/env python\n+import sys\n+import os\n+import argparse\n+import MySQLdb\n+import time\n+\n+\n+def finish_if_require_option_is_fault(args):\n+    if args.date and args.number:\n+        print 'You can not set -d (--date) and -n (--number) option together.'\n+        sys.exit(os.EX_USAGE)\n+    if not args.date and not args.number and not args.stat:\n+        print 'You need to set -d (--date) or -n (--number) or --stat option.'\n+        sys.exit(os.EX_USAGE)\n+    if (args.date or args.number) and not args.table:\n+        print 'You need to set table name using --table option.'\n+\n+\n+def show_number_of(table_name, cursor):\n+    query = 'SELECT count(*) FROM %s' % table_name\n+    cursor.execute(query)\n+    row = cursor.fetchone()\n+\n+    print '%s: %d' % (table_name, row[0])\n+\n+\n+def show_status(cursor):\n+    show_number_of('events', cursor)\n+    show_number_of('action_logs', cursor)\n+    sys.exit(os.EX_OK)\n+\n+\n+def return_unix_time(date):\n+    format = '%Y-%m-%d %H:%M:%S'\n+    date += ' 00:00:00'\n+    return int(time.mktime(time.strptime(date, format)))\n+\n+\n+def run_sql_query(db, cursor, query):\n+    try:\n+        cursor.execute(query)\n+        db.commit()\n+    except:\n+        db.rollback()\n+\n+\n+def delete_unnecessary_records_by_date(table_name, date, db, cursor):\n+    if 'events' in table_name:\n+        time_sec = return_unix_time(date)\n+        query = 'DELETE FROM events WHERE time_sec < %d' % time_sec\n+    elif 'action_logs' in table_name:\n+        query = 'DELETE FROM action_logs WHERE queuing_time < %s' % date","path":"server/tools/hatohol-house-keeper","position":53,"original_position":53,"commit_id":"1e7b6364197941b4b580b2a4293295975bd83463","original_commit_id":"1e7b6364197941b4b580b2a4293295975bd83463","user":{"login":"bynnchapu","id":1008151,"avatar_url":"https://avatars.githubusercontent.com/u/1008151?v=3","gravatar_id":"","url":"https://api.github.com/users/bynnchapu","html_url":"https://github.com/bynnchapu","followers_url":"https://api.github.com/users/bynnchapu/followers","following_url":"https://api.github.com/users/bynnchapu/following{/other_user}","gists_url":"https://api.github.com/users/bynnchapu/gists{/gist_id}","starred_url":"https://api.github.com/users/bynnchapu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bynnchapu/subscriptions","organizations_url":"https://api.github.com/users/bynnchapu/orgs","repos_url":"https://api.github.com/users/bynnchapu/repos","events_url":"https://api.github.com/users/bynnchapu/events{/privacy}","received_events_url":"https://api.github.com/users/bynnchapu/received_events","type":"User","site_admin":false},"body":"I checked the table of ```action_logs``` table.\r\nIt seems all action log records have valid ```queuing_time```.\r\n\r\nI want to check the source code, but I can not find correspond source code.\r\n(I'm bussy now, so I don't have time to show correspond source code. Somehow I have time to fix above comment...)","created_at":"2015-06-26T03:08:44Z","updated_at":"2015-06-26T03:08:44Z","html_url":"https://github.com/project-hatohol/hatohol/pull/1287#discussion_r33325754","pull_request_url":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287","_links":{"self":{"href":"https://api.github.com/repos/project-hatohol/hatohol/pulls/comments/33325754"},"html":{"href":"https://github.com/project-hatohol/hatohol/pull/1287#discussion_r33325754"},"pull_request":{"href":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287"}}},"pull_request":{"url":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287","id":38423047,"html_url":"https://github.com/project-hatohol/hatohol/pull/1287","diff_url":"https://github.com/project-hatohol/hatohol/pull/1287.diff","patch_url":"https://github.com/project-hatohol/hatohol/pull/1287.patch","issue_url":"https://api.github.com/repos/project-hatohol/hatohol/issues/1287","number":1287,"state":"open","locked":false,"title":"Hatohol house keeper","user":{"login":"bynnchapu","id":1008151,"avatar_url":"https://avatars.githubusercontent.com/u/1008151?v=3","gravatar_id":"","url":"https://api.github.com/users/bynnchapu","html_url":"https://github.com/bynnchapu","followers_url":"https://api.github.com/users/bynnchapu/followers","following_url":"https://api.github.com/users/bynnchapu/following{/other_user}","gists_url":"https://api.github.com/users/bynnchapu/gists{/gist_id}","starred_url":"https://api.github.com/users/bynnchapu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bynnchapu/subscriptions","organizations_url":"https://api.github.com/users/bynnchapu/orgs","repos_url":"https://api.github.com/users/bynnchapu/repos","events_url":"https://api.github.com/users/bynnchapu/events{/privacy}","received_events_url":"https://api.github.com/users/bynnchapu/received_events","type":"User","site_admin":false},"body":"I have created Hatohol house keeper tool. (#779)\r\nBut, this tool is not perfect, I think this tool has following TODO items.\r\nI hope @t-miyazawa san fixes following TODO items.\r\n\r\nTODO:\r\n- Use ```hatohol.conf``` file\r\n  - This House keeper tool doesn't use it\r\n- Show message about \"It takes long time\"\r\n  - Cause of long time is storage engine of MySQL (MariaDB).\r\n  - Otherwise, will we add index into ```events``` and ```action_logs``` tables ?","created_at":"2015-06-24T09:28:53Z","updated_at":"2015-06-26T03:08:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5dd394b6e4ed32dc78a3ce620c3aacdc22c975ed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287/commits","review_comments_url":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287/comments","review_comment_url":"https://api.github.com/repos/project-hatohol/hatohol/pulls/comments{/number}","comments_url":"https://api.github.com/repos/project-hatohol/hatohol/issues/1287/comments","statuses_url":"https://api.github.com/repos/project-hatohol/hatohol/statuses/1e7b6364197941b4b580b2a4293295975bd83463","head":{"label":"project-hatohol:hatohol-house-keeper-20150624","ref":"hatohol-house-keeper-20150624","sha":"1e7b6364197941b4b580b2a4293295975bd83463","user":{"login":"project-hatohol","id":4715745,"avatar_url":"https://avatars.githubusercontent.com/u/4715745?v=3","gravatar_id":"","url":"https://api.github.com/users/project-hatohol","html_url":"https://github.com/project-hatohol","followers_url":"https://api.github.com/users/project-hatohol/followers","following_url":"https://api.github.com/users/project-hatohol/following{/other_user}","gists_url":"https://api.github.com/users/project-hatohol/gists{/gist_id}","starred_url":"https://api.github.com/users/project-hatohol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-hatohol/subscriptions","organizations_url":"https://api.github.com/users/project-hatohol/orgs","repos_url":"https://api.github.com/users/project-hatohol/repos","events_url":"https://api.github.com/users/project-hatohol/events{/privacy}","received_events_url":"https://api.github.com/users/project-hatohol/received_events","type":"Organization","site_admin":false},"repo":{"id":10903163,"name":"hatohol","full_name":"project-hatohol/hatohol","owner":{"login":"project-hatohol","id":4715745,"avatar_url":"https://avatars.githubusercontent.com/u/4715745?v=3","gravatar_id":"","url":"https://api.github.com/users/project-hatohol","html_url":"https://github.com/project-hatohol","followers_url":"https://api.github.com/users/project-hatohol/followers","following_url":"https://api.github.com/users/project-hatohol/following{/other_user}","gists_url":"https://api.github.com/users/project-hatohol/gists{/gist_id}","starred_url":"https://api.github.com/users/project-hatohol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-hatohol/subscriptions","organizations_url":"https://api.github.com/users/project-hatohol/orgs","repos_url":"https://api.github.com/users/project-hatohol/repos","events_url":"https://api.github.com/users/project-hatohol/events{/privacy}","received_events_url":"https://api.github.com/users/project-hatohol/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/project-hatohol/hatohol","description":"A unified manager of monitoring software","fork":false,"url":"https://api.github.com/repos/project-hatohol/hatohol","forks_url":"https://api.github.com/repos/project-hatohol/hatohol/forks","keys_url":"https://api.github.com/repos/project-hatohol/hatohol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-hatohol/hatohol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-hatohol/hatohol/teams","hooks_url":"https://api.github.com/repos/project-hatohol/hatohol/hooks","issue_events_url":"https://api.github.com/repos/project-hatohol/hatohol/issues/events{/number}","events_url":"https://api.github.com/repos/project-hatohol/hatohol/events","assignees_url":"https://api.github.com/repos/project-hatohol/hatohol/assignees{/user}","branches_url":"https://api.github.com/repos/project-hatohol/hatohol/branches{/branch}","tags_url":"https://api.github.com/repos/project-hatohol/hatohol/tags","blobs_url":"https://api.github.com/repos/project-hatohol/hatohol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-hatohol/hatohol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-hatohol/hatohol/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-hatohol/hatohol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-hatohol/hatohol/statuses/{sha}","languages_url":"https://api.github.com/repos/project-hatohol/hatohol/languages","stargazers_url":"https://api.github.com/repos/project-hatohol/hatohol/stargazers","contributors_url":"https://api.github.com/repos/project-hatohol/hatohol/contributors","subscribers_url":"https://api.github.com/repos/project-hatohol/hatohol/subscribers","subscription_url":"https://api.github.com/repos/project-hatohol/hatohol/subscription","commits_url":"https://api.github.com/repos/project-hatohol/hatohol/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-hatohol/hatohol/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-hatohol/hatohol/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-hatohol/hatohol/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-hatohol/hatohol/contents/{+path}","compare_url":"https://api.github.com/repos/project-hatohol/hatohol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-hatohol/hatohol/merges","archive_url":"https://api.github.com/repos/project-hatohol/hatohol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-hatohol/hatohol/downloads","issues_url":"https://api.github.com/repos/project-hatohol/hatohol/issues{/number}","pulls_url":"https://api.github.com/repos/project-hatohol/hatohol/pulls{/number}","milestones_url":"https://api.github.com/repos/project-hatohol/hatohol/milestones{/number}","notifications_url":"https://api.github.com/repos/project-hatohol/hatohol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-hatohol/hatohol/labels{/name}","releases_url":"https://api.github.com/repos/project-hatohol/hatohol/releases{/id}","created_at":"2013-06-24T08:45:56Z","updated_at":"2015-06-10T04:23:31Z","pushed_at":"2015-06-26T03:05:42Z","git_url":"git://github.com/project-hatohol/hatohol.git","ssh_url":"git@github.com:project-hatohol/hatohol.git","clone_url":"https://github.com/project-hatohol/hatohol.git","svn_url":"https://github.com/project-hatohol/hatohol","homepage":"http://www.hatohol.org/","size":56563,"stargazers_count":67,"watchers_count":67,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":94,"forks":20,"open_issues":94,"watchers":67,"default_branch":"master"}},"base":{"label":"project-hatohol:master","ref":"master","sha":"983b8be297aad00827508491fb5f0038fcb92243","user":{"login":"project-hatohol","id":4715745,"avatar_url":"https://avatars.githubusercontent.com/u/4715745?v=3","gravatar_id":"","url":"https://api.github.com/users/project-hatohol","html_url":"https://github.com/project-hatohol","followers_url":"https://api.github.com/users/project-hatohol/followers","following_url":"https://api.github.com/users/project-hatohol/following{/other_user}","gists_url":"https://api.github.com/users/project-hatohol/gists{/gist_id}","starred_url":"https://api.github.com/users/project-hatohol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-hatohol/subscriptions","organizations_url":"https://api.github.com/users/project-hatohol/orgs","repos_url":"https://api.github.com/users/project-hatohol/repos","events_url":"https://api.github.com/users/project-hatohol/events{/privacy}","received_events_url":"https://api.github.com/users/project-hatohol/received_events","type":"Organization","site_admin":false},"repo":{"id":10903163,"name":"hatohol","full_name":"project-hatohol/hatohol","owner":{"login":"project-hatohol","id":4715745,"avatar_url":"https://avatars.githubusercontent.com/u/4715745?v=3","gravatar_id":"","url":"https://api.github.com/users/project-hatohol","html_url":"https://github.com/project-hatohol","followers_url":"https://api.github.com/users/project-hatohol/followers","following_url":"https://api.github.com/users/project-hatohol/following{/other_user}","gists_url":"https://api.github.com/users/project-hatohol/gists{/gist_id}","starred_url":"https://api.github.com/users/project-hatohol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-hatohol/subscriptions","organizations_url":"https://api.github.com/users/project-hatohol/orgs","repos_url":"https://api.github.com/users/project-hatohol/repos","events_url":"https://api.github.com/users/project-hatohol/events{/privacy}","received_events_url":"https://api.github.com/users/project-hatohol/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/project-hatohol/hatohol","description":"A unified manager of monitoring software","fork":false,"url":"https://api.github.com/repos/project-hatohol/hatohol","forks_url":"https://api.github.com/repos/project-hatohol/hatohol/forks","keys_url":"https://api.github.com/repos/project-hatohol/hatohol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-hatohol/hatohol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-hatohol/hatohol/teams","hooks_url":"https://api.github.com/repos/project-hatohol/hatohol/hooks","issue_events_url":"https://api.github.com/repos/project-hatohol/hatohol/issues/events{/number}","events_url":"https://api.github.com/repos/project-hatohol/hatohol/events","assignees_url":"https://api.github.com/repos/project-hatohol/hatohol/assignees{/user}","branches_url":"https://api.github.com/repos/project-hatohol/hatohol/branches{/branch}","tags_url":"https://api.github.com/repos/project-hatohol/hatohol/tags","blobs_url":"https://api.github.com/repos/project-hatohol/hatohol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-hatohol/hatohol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-hatohol/hatohol/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-hatohol/hatohol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-hatohol/hatohol/statuses/{sha}","languages_url":"https://api.github.com/repos/project-hatohol/hatohol/languages","stargazers_url":"https://api.github.com/repos/project-hatohol/hatohol/stargazers","contributors_url":"https://api.github.com/repos/project-hatohol/hatohol/contributors","subscribers_url":"https://api.github.com/repos/project-hatohol/hatohol/subscribers","subscription_url":"https://api.github.com/repos/project-hatohol/hatohol/subscription","commits_url":"https://api.github.com/repos/project-hatohol/hatohol/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-hatohol/hatohol/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-hatohol/hatohol/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-hatohol/hatohol/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-hatohol/hatohol/contents/{+path}","compare_url":"https://api.github.com/repos/project-hatohol/hatohol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-hatohol/hatohol/merges","archive_url":"https://api.github.com/repos/project-hatohol/hatohol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-hatohol/hatohol/downloads","issues_url":"https://api.github.com/repos/project-hatohol/hatohol/issues{/number}","pulls_url":"https://api.github.com/repos/project-hatohol/hatohol/pulls{/number}","milestones_url":"https://api.github.com/repos/project-hatohol/hatohol/milestones{/number}","notifications_url":"https://api.github.com/repos/project-hatohol/hatohol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-hatohol/hatohol/labels{/name}","releases_url":"https://api.github.com/repos/project-hatohol/hatohol/releases{/id}","created_at":"2013-06-24T08:45:56Z","updated_at":"2015-06-10T04:23:31Z","pushed_at":"2015-06-26T03:05:42Z","git_url":"git://github.com/project-hatohol/hatohol.git","ssh_url":"git@github.com:project-hatohol/hatohol.git","clone_url":"https://github.com/project-hatohol/hatohol.git","svn_url":"https://github.com/project-hatohol/hatohol","homepage":"http://www.hatohol.org/","size":56563,"stargazers_count":67,"watchers_count":67,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":94,"forks":20,"open_issues":94,"watchers":67,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287"},"html":{"href":"https://github.com/project-hatohol/hatohol/pull/1287"},"issue":{"href":"https://api.github.com/repos/project-hatohol/hatohol/issues/1287"},"comments":{"href":"https://api.github.com/repos/project-hatohol/hatohol/issues/1287/comments"},"review_comments":{"href":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287/comments"},"review_comment":{"href":"https://api.github.com/repos/project-hatohol/hatohol/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/project-hatohol/hatohol/pulls/1287/commits"},"statuses":{"href":"https://api.github.com/repos/project-hatohol/hatohol/statuses/1e7b6364197941b4b580b2a4293295975bd83463"}}}}