{"action":"created","comment":{"url":"https://api.github.com/repos/fsr/buerostatus/pulls/comments/44650574","id":44650574,"diff_hunk":"@@ -1,12 +1,26 @@\n <?php\n-\n+$sampleSize = 5;\n+$threshold = 250;\n $db = new SQLite3(\"buerostatus.db\");\n-$result = $db->query(\"SELECT val FROM buerostatus ORDER BY id DESC LIMIT 1;\");\n-$val = $result->fetchArray()[\"val\"];\n-if ($val > 250) {\n-\techo 1;\n-} else {\n-\techo 0;\n+$result = $db->query(\"SELECT val FROM buerostatus ORDER BY id DESC LIMIT $sampleSize;\");\n+$row = $result->fetchArray();\n+\n+$vals = [];\n+while ($row != FALSE && count($row)>0) {\n+        $vals[] = $row['val'];\n+        $row = $result->fetchArray();\n }\n \n+$medianElement = floor($sampleSize/2);\n+sort($vals, SORT_NUMERIC);\n+$val = $vals[$medianElement];\n+if(isset($_GET[\"raw\"])) {\n+        echo $val;","path":"output.php","position":25,"original_position":25,"commit_id":"0d7b18133a071dc9e55f042212d49d5eced61790","original_commit_id":"0d7b18133a071dc9e55f042212d49d5eced61790","user":{"login":"kiliankoe","id":2625584,"avatar_url":"https://avatars.githubusercontent.com/u/2625584?v=3","gravatar_id":"","url":"https://api.github.com/users/kiliankoe","html_url":"https://github.com/kiliankoe","followers_url":"https://api.github.com/users/kiliankoe/followers","following_url":"https://api.github.com/users/kiliankoe/following{/other_user}","gists_url":"https://api.github.com/users/kiliankoe/gists{/gist_id}","starred_url":"https://api.github.com/users/kiliankoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiliankoe/subscriptions","organizations_url":"https://api.github.com/users/kiliankoe/orgs","repos_url":"https://api.github.com/users/kiliankoe/repos","events_url":"https://api.github.com/users/kiliankoe/events{/privacy}","received_events_url":"https://api.github.com/users/kiliankoe/received_events","type":"User","site_admin":false},"body":"Oh, hast Recht. Hatte da ja auch vom Median gesprochen. Für raw bietet sich das wahrscheinlich doch aber besser direkt als letzter Wert an. Oder wie du meinst^^","created_at":"2015-11-12T12:19:58Z","updated_at":"2015-11-12T12:19:58Z","html_url":"https://github.com/fsr/buerostatus/pull/4#discussion_r44650574","pull_request_url":"https://api.github.com/repos/fsr/buerostatus/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/fsr/buerostatus/pulls/comments/44650574"},"html":{"href":"https://github.com/fsr/buerostatus/pull/4#discussion_r44650574"},"pull_request":{"href":"https://api.github.com/repos/fsr/buerostatus/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/fsr/buerostatus/pulls/4","id":50441717,"html_url":"https://github.com/fsr/buerostatus/pull/4","diff_url":"https://github.com/fsr/buerostatus/pull/4.diff","patch_url":"https://github.com/fsr/buerostatus/pull/4.patch","issue_url":"https://api.github.com/repos/fsr/buerostatus/issues/4","number":4,"state":"closed","locked":false,"title":"Median output, fixes #1, optionally raw, fixes #2","user":{"login":"dirkonet","id":6503137,"avatar_url":"https://avatars.githubusercontent.com/u/6503137?v=3","gravatar_id":"","url":"https://api.github.com/users/dirkonet","html_url":"https://github.com/dirkonet","followers_url":"https://api.github.com/users/dirkonet/followers","following_url":"https://api.github.com/users/dirkonet/following{/other_user}","gists_url":"https://api.github.com/users/dirkonet/gists{/gist_id}","starred_url":"https://api.github.com/users/dirkonet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dirkonet/subscriptions","organizations_url":"https://api.github.com/users/dirkonet/orgs","repos_url":"https://api.github.com/users/dirkonet/repos","events_url":"https://api.github.com/users/dirkonet/events{/privacy}","received_events_url":"https://api.github.com/users/dirkonet/received_events","type":"User","site_admin":false},"body":"lazy median implementation: assumes sample size to be odd, array size to be larger than half of the sample size","created_at":"2015-11-11T21:53:17Z","updated_at":"2015-11-12T12:19:58Z","closed_at":"2015-11-12T09:40:02Z","merged_at":"2015-11-12T09:40:02Z","merge_commit_sha":"c15c005036b7de92401beb2ebb4594536c1a39db","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fsr/buerostatus/pulls/4/commits","review_comments_url":"https://api.github.com/repos/fsr/buerostatus/pulls/4/comments","review_comment_url":"https://api.github.com/repos/fsr/buerostatus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fsr/buerostatus/issues/4/comments","statuses_url":"https://api.github.com/repos/fsr/buerostatus/statuses/0d7b18133a071dc9e55f042212d49d5eced61790","head":{"label":"fsr:dirkonet-patch-1","ref":"dirkonet-patch-1","sha":"0d7b18133a071dc9e55f042212d49d5eced61790","user":{"login":"fsr","id":5859733,"avatar_url":"https://avatars.githubusercontent.com/u/5859733?v=3","gravatar_id":"","url":"https://api.github.com/users/fsr","html_url":"https://github.com/fsr","followers_url":"https://api.github.com/users/fsr/followers","following_url":"https://api.github.com/users/fsr/following{/other_user}","gists_url":"https://api.github.com/users/fsr/gists{/gist_id}","starred_url":"https://api.github.com/users/fsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsr/subscriptions","organizations_url":"https://api.github.com/users/fsr/orgs","repos_url":"https://api.github.com/users/fsr/repos","events_url":"https://api.github.com/users/fsr/events{/privacy}","received_events_url":"https://api.github.com/users/fsr/received_events","type":"Organization","site_admin":false},"repo":{"id":41034217,"name":"buerostatus","full_name":"fsr/buerostatus","owner":{"login":"fsr","id":5859733,"avatar_url":"https://avatars.githubusercontent.com/u/5859733?v=3","gravatar_id":"","url":"https://api.github.com/users/fsr","html_url":"https://github.com/fsr","followers_url":"https://api.github.com/users/fsr/followers","following_url":"https://api.github.com/users/fsr/following{/other_user}","gists_url":"https://api.github.com/users/fsr/gists{/gist_id}","starred_url":"https://api.github.com/users/fsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsr/subscriptions","organizations_url":"https://api.github.com/users/fsr/orgs","repos_url":"https://api.github.com/users/fsr/repos","events_url":"https://api.github.com/users/fsr/events{/privacy}","received_events_url":"https://api.github.com/users/fsr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsr/buerostatus","description":":bulb:Helloooo, anybody home?","fork":false,"url":"https://api.github.com/repos/fsr/buerostatus","forks_url":"https://api.github.com/repos/fsr/buerostatus/forks","keys_url":"https://api.github.com/repos/fsr/buerostatus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsr/buerostatus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsr/buerostatus/teams","hooks_url":"https://api.github.com/repos/fsr/buerostatus/hooks","issue_events_url":"https://api.github.com/repos/fsr/buerostatus/issues/events{/number}","events_url":"https://api.github.com/repos/fsr/buerostatus/events","assignees_url":"https://api.github.com/repos/fsr/buerostatus/assignees{/user}","branches_url":"https://api.github.com/repos/fsr/buerostatus/branches{/branch}","tags_url":"https://api.github.com/repos/fsr/buerostatus/tags","blobs_url":"https://api.github.com/repos/fsr/buerostatus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsr/buerostatus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsr/buerostatus/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsr/buerostatus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsr/buerostatus/statuses/{sha}","languages_url":"https://api.github.com/repos/fsr/buerostatus/languages","stargazers_url":"https://api.github.com/repos/fsr/buerostatus/stargazers","contributors_url":"https://api.github.com/repos/fsr/buerostatus/contributors","subscribers_url":"https://api.github.com/repos/fsr/buerostatus/subscribers","subscription_url":"https://api.github.com/repos/fsr/buerostatus/subscription","commits_url":"https://api.github.com/repos/fsr/buerostatus/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsr/buerostatus/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsr/buerostatus/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsr/buerostatus/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsr/buerostatus/contents/{+path}","compare_url":"https://api.github.com/repos/fsr/buerostatus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsr/buerostatus/merges","archive_url":"https://api.github.com/repos/fsr/buerostatus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsr/buerostatus/downloads","issues_url":"https://api.github.com/repos/fsr/buerostatus/issues{/number}","pulls_url":"https://api.github.com/repos/fsr/buerostatus/pulls{/number}","milestones_url":"https://api.github.com/repos/fsr/buerostatus/milestones{/number}","notifications_url":"https://api.github.com/repos/fsr/buerostatus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsr/buerostatus/labels{/name}","releases_url":"https://api.github.com/repos/fsr/buerostatus/releases{/id}","created_at":"2015-08-19T13:06:04Z","updated_at":"2015-11-10T19:30:25Z","pushed_at":"2015-11-12T09:40:02Z","git_url":"git://github.com/fsr/buerostatus.git","ssh_url":"git@github.com:fsr/buerostatus.git","clone_url":"https://github.com/fsr/buerostatus.git","svn_url":"https://github.com/fsr/buerostatus","homepage":"","size":580,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"base":{"label":"fsr:master","ref":"master","sha":"685228897c114b61a842f41651439941f4805047","user":{"login":"fsr","id":5859733,"avatar_url":"https://avatars.githubusercontent.com/u/5859733?v=3","gravatar_id":"","url":"https://api.github.com/users/fsr","html_url":"https://github.com/fsr","followers_url":"https://api.github.com/users/fsr/followers","following_url":"https://api.github.com/users/fsr/following{/other_user}","gists_url":"https://api.github.com/users/fsr/gists{/gist_id}","starred_url":"https://api.github.com/users/fsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsr/subscriptions","organizations_url":"https://api.github.com/users/fsr/orgs","repos_url":"https://api.github.com/users/fsr/repos","events_url":"https://api.github.com/users/fsr/events{/privacy}","received_events_url":"https://api.github.com/users/fsr/received_events","type":"Organization","site_admin":false},"repo":{"id":41034217,"name":"buerostatus","full_name":"fsr/buerostatus","owner":{"login":"fsr","id":5859733,"avatar_url":"https://avatars.githubusercontent.com/u/5859733?v=3","gravatar_id":"","url":"https://api.github.com/users/fsr","html_url":"https://github.com/fsr","followers_url":"https://api.github.com/users/fsr/followers","following_url":"https://api.github.com/users/fsr/following{/other_user}","gists_url":"https://api.github.com/users/fsr/gists{/gist_id}","starred_url":"https://api.github.com/users/fsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsr/subscriptions","organizations_url":"https://api.github.com/users/fsr/orgs","repos_url":"https://api.github.com/users/fsr/repos","events_url":"https://api.github.com/users/fsr/events{/privacy}","received_events_url":"https://api.github.com/users/fsr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsr/buerostatus","description":":bulb:Helloooo, anybody home?","fork":false,"url":"https://api.github.com/repos/fsr/buerostatus","forks_url":"https://api.github.com/repos/fsr/buerostatus/forks","keys_url":"https://api.github.com/repos/fsr/buerostatus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsr/buerostatus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsr/buerostatus/teams","hooks_url":"https://api.github.com/repos/fsr/buerostatus/hooks","issue_events_url":"https://api.github.com/repos/fsr/buerostatus/issues/events{/number}","events_url":"https://api.github.com/repos/fsr/buerostatus/events","assignees_url":"https://api.github.com/repos/fsr/buerostatus/assignees{/user}","branches_url":"https://api.github.com/repos/fsr/buerostatus/branches{/branch}","tags_url":"https://api.github.com/repos/fsr/buerostatus/tags","blobs_url":"https://api.github.com/repos/fsr/buerostatus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsr/buerostatus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsr/buerostatus/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsr/buerostatus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsr/buerostatus/statuses/{sha}","languages_url":"https://api.github.com/repos/fsr/buerostatus/languages","stargazers_url":"https://api.github.com/repos/fsr/buerostatus/stargazers","contributors_url":"https://api.github.com/repos/fsr/buerostatus/contributors","subscribers_url":"https://api.github.com/repos/fsr/buerostatus/subscribers","subscription_url":"https://api.github.com/repos/fsr/buerostatus/subscription","commits_url":"https://api.github.com/repos/fsr/buerostatus/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsr/buerostatus/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsr/buerostatus/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsr/buerostatus/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsr/buerostatus/contents/{+path}","compare_url":"https://api.github.com/repos/fsr/buerostatus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsr/buerostatus/merges","archive_url":"https://api.github.com/repos/fsr/buerostatus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsr/buerostatus/downloads","issues_url":"https://api.github.com/repos/fsr/buerostatus/issues{/number}","pulls_url":"https://api.github.com/repos/fsr/buerostatus/pulls{/number}","milestones_url":"https://api.github.com/repos/fsr/buerostatus/milestones{/number}","notifications_url":"https://api.github.com/repos/fsr/buerostatus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsr/buerostatus/labels{/name}","releases_url":"https://api.github.com/repos/fsr/buerostatus/releases{/id}","created_at":"2015-08-19T13:06:04Z","updated_at":"2015-11-10T19:30:25Z","pushed_at":"2015-11-12T09:40:02Z","git_url":"git://github.com/fsr/buerostatus.git","ssh_url":"git@github.com:fsr/buerostatus.git","clone_url":"https://github.com/fsr/buerostatus.git","svn_url":"https://github.com/fsr/buerostatus","homepage":"","size":580,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fsr/buerostatus/pulls/4"},"html":{"href":"https://github.com/fsr/buerostatus/pull/4"},"issue":{"href":"https://api.github.com/repos/fsr/buerostatus/issues/4"},"comments":{"href":"https://api.github.com/repos/fsr/buerostatus/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/fsr/buerostatus/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/fsr/buerostatus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fsr/buerostatus/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/fsr/buerostatus/statuses/0d7b18133a071dc9e55f042212d49d5eced61790"}}}}