{"action":"created","comment":{"url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/comments/225720769","pull_request_review_id":165370236,"id":225720769,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNTcyMDc2OQ==","diff_hunk":"@@ -0,0 +1,92 @@\n+\"use strict\"\r\n+const fs = require(\"fs\");\r\n+const constants = require(\"../app/constant\");\r\n+require(\"../app/helper\");\r\n+\r\n+const getEventsFile = (callback) => {\r\n+    fs.readFile(\"./data/events.json\", \"utf8\", callback);\r\n+};\r\n+\r\n+const isEmpty = (val) => {\r\n+    return !(typeof (val) !== \"undefined\" && val !== null);\r\n+};\r\n+\r\n+const validateValueOfProperty = (key, values) => {\r\n+    if (!isEmpty(constants[key])) {\r\n+        for (let index = 0; index < values.length; index++) {\r\n+            if (constants[key].indexOf(values[index]) === -1) {\r\n+                return false;\r\n+            }\r\n+        }\r\n+        return true;\r\n+    }\r\n+    return true;\r\n+};\r\n+\r\n+module.exports = {\r\n+    timeUpStatus: (request, response) => {\r\n+        const time = process.uptime();\r\n+        const uptime = `${time}`.toHHMMSS();\r\n+        return response.status(200).send(uptime);\r\n+    },\r\n+\r\n+    eventsHandling: (request, response) => {\r\n+        let queryParam;\r\n+        switch (request.method) {\r\n+            case \"POST\":\r\n+                queryParam = request.body;\r\n+                break;\r\n+            case \"GET\":\r\n+                queryParam = request.query;\r\n+                break;\r\n+        }\r\n+        let pageNumb = queryParam.pageNumb;\r\n+        let maxEntities = queryParam.maxEntities;\r\n+\r\n+        //clear the request object of unnecessary properties, for filtering by the correct properties\r\n+        if (!isEmpty(pageNumb) || !isEmpty(maxEntities)) {\r\n+            delete queryParam.pageNumb;\r\n+            delete queryParam.maxEntities;\r\n+        }\r\n+\r\n+        if (Object.keys(queryParam).length &&\r\n+            !validateValueOfProperty(Object.keys(queryParam)[0], queryParam[Object.keys(queryParam)[0]].split(\":\"))) {\r\n+            return response.status(400).send(`incorrect${Object.keys(queryParam)[0]}`);\r\n+        }\r\n+\r\n+        const callback = (err, data) => {\r\n+            if (err) {\r\n+                throw err;\r\n+            }\r\n+            const eventsArr = JSON.parse(data).events;\r\n+\r\n+            //if no parameters are specified for the filter, assign the original array\r\n+            let filteredEvents = Object.keys(queryParam).length ? Object.eventsFilter(eventsArr, queryParam) : eventsArr;\r\n+\r\n+            //  if there are no such events, return 400\r\n+            if (filteredEvents.length < 1) {\r\n+                return response.status(400).send(`no items with [${Object.keys(queryParam)[0]}] filter`);\r\n+            }\r\n+\r\n+            //if paggination is enabled\r\n+            if (!isEmpty(pageNumb) && !isEmpty(maxEntities)) {\r\n+                if (isNaN(pageNumb) || isNaN(maxEntities)) {\r\n+                    return response.status(400).send(`incorrect [${isNaN(pageNumb) ? `{pageNumb: ${pageNumb}}` : \"\"}${isNaN(maxEntities) ? `{maxEntities: ${maxEntities}}` : \"\"}] values`);\r","path":"Task4/app/api.js","position":74,"original_position":74,"commit_id":"b886a5ba785d1615e01185a6bae75d022105aabb","original_commit_id":"b886a5ba785d1615e01185a6bae75d022105aabb","user":{"login":"HDevel","id":7996391,"node_id":"MDQ6VXNlcjc5OTYzOTE=","avatar_url":"https://avatars3.githubusercontent.com/u/7996391?v=4","gravatar_id":"","url":"https://api.github.com/users/HDevel","html_url":"https://github.com/HDevel","followers_url":"https://api.github.com/users/HDevel/followers","following_url":"https://api.github.com/users/HDevel/following{/other_user}","gists_url":"https://api.github.com/users/HDevel/gists{/gist_id}","starred_url":"https://api.github.com/users/HDevel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HDevel/subscriptions","organizations_url":"https://api.github.com/users/HDevel/orgs","repos_url":"https://api.github.com/users/HDevel/repos","events_url":"https://api.github.com/users/HDevel/events{/privacy}","received_events_url":"https://api.github.com/users/HDevel/received_events","type":"User","site_admin":false},"body":"Не используй вложенные тернарники, лучше заменить на простой if","created_at":"2018-10-16T21:52:28Z","updated_at":"2018-10-16T21:57:08Z","html_url":"https://github.com/kingolegator/SHRI-task1-2/pull/1#discussion_r225720769","pull_request_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/comments/225720769"},"html":{"href":"https://github.com/kingolegator/SHRI-task1-2/pull/1#discussion_r225720769"},"pull_request":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1","id":222742380,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNzQyMzgw","html_url":"https://github.com/kingolegator/SHRI-task1-2/pull/1","diff_url":"https://github.com/kingolegator/SHRI-task1-2/pull/1.diff","patch_url":"https://github.com/kingolegator/SHRI-task1-2/pull/1.patch","issue_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/1","number":1,"state":"open","locked":false,"title":"Task4","user":{"login":"kingolegator","id":25420206,"node_id":"MDQ6VXNlcjI1NDIwMjA2","avatar_url":"https://avatars0.githubusercontent.com/u/25420206?v=4","gravatar_id":"","url":"https://api.github.com/users/kingolegator","html_url":"https://github.com/kingolegator","followers_url":"https://api.github.com/users/kingolegator/followers","following_url":"https://api.github.com/users/kingolegator/following{/other_user}","gists_url":"https://api.github.com/users/kingolegator/gists{/gist_id}","starred_url":"https://api.github.com/users/kingolegator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingolegator/subscriptions","organizations_url":"https://api.github.com/users/kingolegator/orgs","repos_url":"https://api.github.com/users/kingolegator/repos","events_url":"https://api.github.com/users/kingolegator/events{/privacy}","received_events_url":"https://api.github.com/users/kingolegator/received_events","type":"User","site_admin":false},"body":"home work on node.js","created_at":"2018-10-14T20:54:12Z","updated_at":"2018-10-16T21:57:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b662e548885ed901c26b87b3ce8cebbd3b409305","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1/commits","review_comments_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1/comments","review_comment_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/1/comments","statuses_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/statuses/b886a5ba785d1615e01185a6bae75d022105aabb","head":{"label":"kingolegator:task4","ref":"task4","sha":"b886a5ba785d1615e01185a6bae75d022105aabb","user":{"login":"kingolegator","id":25420206,"node_id":"MDQ6VXNlcjI1NDIwMjA2","avatar_url":"https://avatars0.githubusercontent.com/u/25420206?v=4","gravatar_id":"","url":"https://api.github.com/users/kingolegator","html_url":"https://github.com/kingolegator","followers_url":"https://api.github.com/users/kingolegator/followers","following_url":"https://api.github.com/users/kingolegator/following{/other_user}","gists_url":"https://api.github.com/users/kingolegator/gists{/gist_id}","starred_url":"https://api.github.com/users/kingolegator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingolegator/subscriptions","organizations_url":"https://api.github.com/users/kingolegator/orgs","repos_url":"https://api.github.com/users/kingolegator/repos","events_url":"https://api.github.com/users/kingolegator/events{/privacy}","received_events_url":"https://api.github.com/users/kingolegator/received_events","type":"User","site_admin":false},"repo":{"id":151945348,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE5NDUzNDg=","name":"SHRI-task1-2","full_name":"kingolegator/SHRI-task1-2","private":false,"owner":{"login":"kingolegator","id":25420206,"node_id":"MDQ6VXNlcjI1NDIwMjA2","avatar_url":"https://avatars0.githubusercontent.com/u/25420206?v=4","gravatar_id":"","url":"https://api.github.com/users/kingolegator","html_url":"https://github.com/kingolegator","followers_url":"https://api.github.com/users/kingolegator/followers","following_url":"https://api.github.com/users/kingolegator/following{/other_user}","gists_url":"https://api.github.com/users/kingolegator/gists{/gist_id}","starred_url":"https://api.github.com/users/kingolegator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingolegator/subscriptions","organizations_url":"https://api.github.com/users/kingolegator/orgs","repos_url":"https://api.github.com/users/kingolegator/repos","events_url":"https://api.github.com/users/kingolegator/events{/privacy}","received_events_url":"https://api.github.com/users/kingolegator/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kingolegator/SHRI-task1-2","description":"completed first and second homework for SHRI 2018","fork":false,"url":"https://api.github.com/repos/kingolegator/SHRI-task1-2","forks_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/forks","keys_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/teams","hooks_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/hooks","issue_events_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/events{/number}","events_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/events","assignees_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/assignees{/user}","branches_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/branches{/branch}","tags_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/tags","blobs_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/statuses/{sha}","languages_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/languages","stargazers_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/stargazers","contributors_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/contributors","subscribers_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/subscribers","subscription_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/subscription","commits_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/contents/{+path}","compare_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/merges","archive_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/downloads","issues_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues{/number}","pulls_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls{/number}","milestones_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/milestones{/number}","notifications_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/labels{/name}","releases_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/releases{/id}","deployments_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/deployments","created_at":"2018-10-07T13:40:03Z","updated_at":"2018-10-14T16:00:42Z","pushed_at":"2018-10-16T12:27:04Z","git_url":"git://github.com/kingolegator/SHRI-task1-2.git","ssh_url":"git@github.com:kingolegator/SHRI-task1-2.git","clone_url":"https://github.com/kingolegator/SHRI-task1-2.git","svn_url":"https://github.com/kingolegator/SHRI-task1-2","homepage":"https://kingolegator.github.io/SHRI-task1-2/","size":3078,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"kingolegator:master","ref":"master","sha":"fc6abee569402d655a9efa0f3138909c41793545","user":{"login":"kingolegator","id":25420206,"node_id":"MDQ6VXNlcjI1NDIwMjA2","avatar_url":"https://avatars0.githubusercontent.com/u/25420206?v=4","gravatar_id":"","url":"https://api.github.com/users/kingolegator","html_url":"https://github.com/kingolegator","followers_url":"https://api.github.com/users/kingolegator/followers","following_url":"https://api.github.com/users/kingolegator/following{/other_user}","gists_url":"https://api.github.com/users/kingolegator/gists{/gist_id}","starred_url":"https://api.github.com/users/kingolegator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingolegator/subscriptions","organizations_url":"https://api.github.com/users/kingolegator/orgs","repos_url":"https://api.github.com/users/kingolegator/repos","events_url":"https://api.github.com/users/kingolegator/events{/privacy}","received_events_url":"https://api.github.com/users/kingolegator/received_events","type":"User","site_admin":false},"repo":{"id":151945348,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE5NDUzNDg=","name":"SHRI-task1-2","full_name":"kingolegator/SHRI-task1-2","private":false,"owner":{"login":"kingolegator","id":25420206,"node_id":"MDQ6VXNlcjI1NDIwMjA2","avatar_url":"https://avatars0.githubusercontent.com/u/25420206?v=4","gravatar_id":"","url":"https://api.github.com/users/kingolegator","html_url":"https://github.com/kingolegator","followers_url":"https://api.github.com/users/kingolegator/followers","following_url":"https://api.github.com/users/kingolegator/following{/other_user}","gists_url":"https://api.github.com/users/kingolegator/gists{/gist_id}","starred_url":"https://api.github.com/users/kingolegator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingolegator/subscriptions","organizations_url":"https://api.github.com/users/kingolegator/orgs","repos_url":"https://api.github.com/users/kingolegator/repos","events_url":"https://api.github.com/users/kingolegator/events{/privacy}","received_events_url":"https://api.github.com/users/kingolegator/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kingolegator/SHRI-task1-2","description":"completed first and second homework for SHRI 2018","fork":false,"url":"https://api.github.com/repos/kingolegator/SHRI-task1-2","forks_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/forks","keys_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/teams","hooks_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/hooks","issue_events_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/events{/number}","events_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/events","assignees_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/assignees{/user}","branches_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/branches{/branch}","tags_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/tags","blobs_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/refs{/sha}","trees_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/statuses/{sha}","languages_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/languages","stargazers_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/stargazers","contributors_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/contributors","subscribers_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/subscribers","subscription_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/subscription","commits_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/commits{/sha}","git_commits_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/git/commits{/sha}","comments_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/comments{/number}","issue_comment_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/comments{/number}","contents_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/contents/{+path}","compare_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/merges","archive_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/downloads","issues_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues{/number}","pulls_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls{/number}","milestones_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/milestones{/number}","notifications_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/labels{/name}","releases_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/releases{/id}","deployments_url":"https://api.github.com/repos/kingolegator/SHRI-task1-2/deployments","created_at":"2018-10-07T13:40:03Z","updated_at":"2018-10-14T16:00:42Z","pushed_at":"2018-10-16T12:27:04Z","git_url":"git://github.com/kingolegator/SHRI-task1-2.git","ssh_url":"git@github.com:kingolegator/SHRI-task1-2.git","clone_url":"https://github.com/kingolegator/SHRI-task1-2.git","svn_url":"https://github.com/kingolegator/SHRI-task1-2","homepage":"https://kingolegator.github.io/SHRI-task1-2/","size":3078,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1"},"html":{"href":"https://github.com/kingolegator/SHRI-task1-2/pull/1"},"issue":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/1"},"comments":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/kingolegator/SHRI-task1-2/statuses/b886a5ba785d1615e01185a6bae75d022105aabb"}},"author_association":"OWNER"}}
{"actor":{"display_login":"HDevel"}}