{"action":"created","comment":{"url":"https://api.github.com/repos/itkpi/events-parser/pulls/comments/73638422","id":73638422,"diff_hunk":"@@ -0,0 +1,234 @@\n+/**\n+ * These functions work with data input/output or pick part of it.\n+ */\n+\n+'use strict'\n+\n+const fs = require('fs-extra')\n+const request = require('sync-request')\n+const xml2json = require('xml2json')\n+const http = require('http')\n+const _log_ = require('../utils.js')._log_\n+\n+const firstEvent = 0\n+\n+/**\n+ * Get new data from sources.\n+ * @param {string} srcName - name of source, which is currently being processed.\n+ * @param {string} srcType - datatype of current source.\n+ * @param {string} srcLink - link to actual data of source.\n+ * @param {string} newJSON - path to JSON file with data of current iteration.\n+ * @param {string} oldJSON - path to JSON file with data of previous iteration.\n+ * @returns {boolean} 'true' if new events are present. Otherwise return 'false'.\n+ */\n+exports.get = (srcName, srcType, srcLink, newJSON, oldJSON) => {\n+  // Check for the existence files\n+  fs.ensureFileSync(newJSON)\n+  fs.ensureFileSync(oldJSON)\n+\n+  // Save old data\n+  fs.copySync(newJSON, oldJSON)\n+\n+  // Get data from source\n+  let res = request('GET', srcLink)\n+\n+  switch (srcType) {\n+    case 'xml':\n+      res = xml2json.toJson(res.getBody(), {'sanitize': false})\n+      fs.writeFileSync(newJSON, res)\n+      break\n+    case 'json':\n+      fs.writeFileSync(newJSON, res.getBody())\n+      break\n+    default:\n+      _log_(`ERROR: NOT FOUND ${srcName} in get.get`)\n+  }\n+\n+  const old = fs.readFileSync(oldJSON)\n+\n+  if (old == '') { // not rewrite to '==='\n+    _log_(`${srcName}: INIT`)\n+\n+    return false\n+  }\n+\n+  return true\n+}\n+\n+/**\n+ * Read JSON file.\n+ * @param {string} srcName - name of source, which is currently being processed.\n+ * @param {string} file - path to JSON file with data of current iteration.\n+ * @returns {JSON} JSON only with events.\n+ */\n+exports.read = (srcName, file) => {\n+  // FIX ME: Look like bug\n+  fs.readJsonSync(file, {'throws': false})\n+  let data = ''\n+\n+  switch (srcName) {\n+    case 'dou_ua_online':\n+    case 'dou_ua_kyiv':\n+      data = file.rss.channel.item\n+      break\n+    case 'meetup_open_events':\n+      data = file.results\n+      break\n+    default:\n+      _log_(`ERROR: NOT FOUND ${srcName} in get.read`)\n+  }\n+\n+  return data\n+}\n+\n+/**\n+ * Search position of new events.\n+ * @param {string} srcName - name of source, which is currently being processed.\n+ * @param {JSON} newSrc - JSON file with actual state of information.\n+ * @param {JSON} oldSrc - JSON file with previous state of information.\n+ * @returns {Array} with position of new events.\n+ */\n+exports.eventsPosition = (srcName, newSrc, oldSrc) => {","path":"data/dataIO.js","position":91,"original_position":91,"commit_id":"0c6ee804473b15cb29e343b58347858d6affcbaf","original_commit_id":"0c6ee804473b15cb29e343b58347858d6affcbaf","user":{"login":"codacy-bot","id":19940114,"avatar_url":"https://avatars.githubusercontent.com/u/19940114?v=3","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Function 'anonymous' has a complexity of 8. (complexity)](https://www.codacy.com/app/webknjaz-Organization/events-parser/file/3169518139/issues/source?bid=3283923&fileBranchId=3495482#l91)","created_at":"2016-08-05T03:43:47Z","updated_at":"2016-08-05T03:43:47Z","html_url":"https://github.com/itkpi/events-parser/pull/21#discussion_r73638422","pull_request_url":"https://api.github.com/repos/itkpi/events-parser/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/itkpi/events-parser/pulls/comments/73638422"},"html":{"href":"https://github.com/itkpi/events-parser/pull/21#discussion_r73638422"},"pull_request":{"href":"https://api.github.com/repos/itkpi/events-parser/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/itkpi/events-parser/pulls/21","id":79788752,"html_url":"https://github.com/itkpi/events-parser/pull/21","diff_url":"https://github.com/itkpi/events-parser/pull/21.diff","patch_url":"https://github.com/itkpi/events-parser/pull/21.patch","issue_url":"https://api.github.com/repos/itkpi/events-parser/issues/21","number":21,"state":"open","locked":false,"title":"Refactoring:","user":{"login":"MaxymVlasov","id":11096782,"avatar_url":"https://avatars.githubusercontent.com/u/11096782?v=3","gravatar_id":"","url":"https://api.github.com/users/MaxymVlasov","html_url":"https://github.com/MaxymVlasov","followers_url":"https://api.github.com/users/MaxymVlasov/followers","following_url":"https://api.github.com/users/MaxymVlasov/following{/other_user}","gists_url":"https://api.github.com/users/MaxymVlasov/gists{/gist_id}","starred_url":"https://api.github.com/users/MaxymVlasov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaxymVlasov/subscriptions","organizations_url":"https://api.github.com/users/MaxymVlasov/orgs","repos_url":"https://api.github.com/users/MaxymVlasov/repos","events_url":"https://api.github.com/users/MaxymVlasov/events{/privacy}","received_events_url":"https://api.github.com/users/MaxymVlasov/received_events","type":"User","site_admin":false},"body":"* Rename files\r\n* Rename functions\r\n* Change structure of project\r\n* Add comments\r\n* Reduce max symbols of post to 7000","created_at":"2016-08-02T18:54:01Z","updated_at":"2016-08-05T03:43:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7eafff8fd41f2265fd575c03fb47c2c9086b4dbf","assignee":{"login":"webknjaz","id":578543,"avatar_url":"https://avatars.githubusercontent.com/u/578543?v=3","gravatar_id":"","url":"https://api.github.com/users/webknjaz","html_url":"https://github.com/webknjaz","followers_url":"https://api.github.com/users/webknjaz/followers","following_url":"https://api.github.com/users/webknjaz/following{/other_user}","gists_url":"https://api.github.com/users/webknjaz/gists{/gist_id}","starred_url":"https://api.github.com/users/webknjaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webknjaz/subscriptions","organizations_url":"https://api.github.com/users/webknjaz/orgs","repos_url":"https://api.github.com/users/webknjaz/repos","events_url":"https://api.github.com/users/webknjaz/events{/privacy}","received_events_url":"https://api.github.com/users/webknjaz/received_events","type":"User","site_admin":false},"assignees":[{"login":"webknjaz","id":578543,"avatar_url":"https://avatars.githubusercontent.com/u/578543?v=3","gravatar_id":"","url":"https://api.github.com/users/webknjaz","html_url":"https://github.com/webknjaz","followers_url":"https://api.github.com/users/webknjaz/followers","following_url":"https://api.github.com/users/webknjaz/following{/other_user}","gists_url":"https://api.github.com/users/webknjaz/gists{/gist_id}","starred_url":"https://api.github.com/users/webknjaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webknjaz/subscriptions","organizations_url":"https://api.github.com/users/webknjaz/orgs","repos_url":"https://api.github.com/users/webknjaz/repos","events_url":"https://api.github.com/users/webknjaz/events{/privacy}","received_events_url":"https://api.github.com/users/webknjaz/received_events","type":"User","site_admin":false},{"login":"maksim36ua","id":10496082,"avatar_url":"https://avatars.githubusercontent.com/u/10496082?v=3","gravatar_id":"","url":"https://api.github.com/users/maksim36ua","html_url":"https://github.com/maksim36ua","followers_url":"https://api.github.com/users/maksim36ua/followers","following_url":"https://api.github.com/users/maksim36ua/following{/other_user}","gists_url":"https://api.github.com/users/maksim36ua/gists{/gist_id}","starred_url":"https://api.github.com/users/maksim36ua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maksim36ua/subscriptions","organizations_url":"https://api.github.com/users/maksim36ua/orgs","repos_url":"https://api.github.com/users/maksim36ua/repos","events_url":"https://api.github.com/users/maksim36ua/events{/privacy}","received_events_url":"https://api.github.com/users/maksim36ua/received_events","type":"User","site_admin":false},{"login":"MaxymVlasov","id":11096782,"avatar_url":"https://avatars.githubusercontent.com/u/11096782?v=3","gravatar_id":"","url":"https://api.github.com/users/MaxymVlasov","html_url":"https://github.com/MaxymVlasov","followers_url":"https://api.github.com/users/MaxymVlasov/followers","following_url":"https://api.github.com/users/MaxymVlasov/following{/other_user}","gists_url":"https://api.github.com/users/MaxymVlasov/gists{/gist_id}","starred_url":"https://api.github.com/users/MaxymVlasov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaxymVlasov/subscriptions","organizations_url":"https://api.github.com/users/MaxymVlasov/orgs","repos_url":"https://api.github.com/users/MaxymVlasov/repos","events_url":"https://api.github.com/users/MaxymVlasov/events{/privacy}","received_events_url":"https://api.github.com/users/MaxymVlasov/received_events","type":"User","site_admin":false},{"login":"wack17s","id":14200710,"avatar_url":"https://avatars.githubusercontent.com/u/14200710?v=3","gravatar_id":"","url":"https://api.github.com/users/wack17s","html_url":"https://github.com/wack17s","followers_url":"https://api.github.com/users/wack17s/followers","following_url":"https://api.github.com/users/wack17s/following{/other_user}","gists_url":"https://api.github.com/users/wack17s/gists{/gist_id}","starred_url":"https://api.github.com/users/wack17s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wack17s/subscriptions","organizations_url":"https://api.github.com/users/wack17s/orgs","repos_url":"https://api.github.com/users/wack17s/repos","events_url":"https://api.github.com/users/wack17s/events{/privacy}","received_events_url":"https://api.github.com/users/wack17s/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/itkpi/events-parser/pulls/21/commits","review_comments_url":"https://api.github.com/repos/itkpi/events-parser/pulls/21/comments","review_comment_url":"https://api.github.com/repos/itkpi/events-parser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/itkpi/events-parser/issues/21/comments","statuses_url":"https://api.github.com/repos/itkpi/events-parser/statuses/0c6ee804473b15cb29e343b58347858d6affcbaf","head":{"label":"itkpi:refactoring","ref":"refactoring","sha":"0c6ee804473b15cb29e343b58347858d6affcbaf","user":{"login":"itkpi","id":12073380,"avatar_url":"https://avatars.githubusercontent.com/u/12073380?v=3","gravatar_id":"","url":"https://api.github.com/users/itkpi","html_url":"https://github.com/itkpi","followers_url":"https://api.github.com/users/itkpi/followers","following_url":"https://api.github.com/users/itkpi/following{/other_user}","gists_url":"https://api.github.com/users/itkpi/gists{/gist_id}","starred_url":"https://api.github.com/users/itkpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itkpi/subscriptions","organizations_url":"https://api.github.com/users/itkpi/orgs","repos_url":"https://api.github.com/users/itkpi/repos","events_url":"https://api.github.com/users/itkpi/events{/privacy}","received_events_url":"https://api.github.com/users/itkpi/received_events","type":"Organization","site_admin":false},"repo":{"id":51226809,"name":"events-parser","full_name":"itkpi/events-parser","owner":{"login":"itkpi","id":12073380,"avatar_url":"https://avatars.githubusercontent.com/u/12073380?v=3","gravatar_id":"","url":"https://api.github.com/users/itkpi","html_url":"https://github.com/itkpi","followers_url":"https://api.github.com/users/itkpi/followers","following_url":"https://api.github.com/users/itkpi/following{/other_user}","gists_url":"https://api.github.com/users/itkpi/gists{/gist_id}","starred_url":"https://api.github.com/users/itkpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itkpi/subscriptions","organizations_url":"https://api.github.com/users/itkpi/orgs","repos_url":"https://api.github.com/users/itkpi/repos","events_url":"https://api.github.com/users/itkpi/events{/privacy}","received_events_url":"https://api.github.com/users/itkpi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/itkpi/events-parser","description":"","fork":false,"url":"https://api.github.com/repos/itkpi/events-parser","forks_url":"https://api.github.com/repos/itkpi/events-parser/forks","keys_url":"https://api.github.com/repos/itkpi/events-parser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/itkpi/events-parser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/itkpi/events-parser/teams","hooks_url":"https://api.github.com/repos/itkpi/events-parser/hooks","issue_events_url":"https://api.github.com/repos/itkpi/events-parser/issues/events{/number}","events_url":"https://api.github.com/repos/itkpi/events-parser/events","assignees_url":"https://api.github.com/repos/itkpi/events-parser/assignees{/user}","branches_url":"https://api.github.com/repos/itkpi/events-parser/branches{/branch}","tags_url":"https://api.github.com/repos/itkpi/events-parser/tags","blobs_url":"https://api.github.com/repos/itkpi/events-parser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/itkpi/events-parser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/itkpi/events-parser/git/refs{/sha}","trees_url":"https://api.github.com/repos/itkpi/events-parser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/itkpi/events-parser/statuses/{sha}","languages_url":"https://api.github.com/repos/itkpi/events-parser/languages","stargazers_url":"https://api.github.com/repos/itkpi/events-parser/stargazers","contributors_url":"https://api.github.com/repos/itkpi/events-parser/contributors","subscribers_url":"https://api.github.com/repos/itkpi/events-parser/subscribers","subscription_url":"https://api.github.com/repos/itkpi/events-parser/subscription","commits_url":"https://api.github.com/repos/itkpi/events-parser/commits{/sha}","git_commits_url":"https://api.github.com/repos/itkpi/events-parser/git/commits{/sha}","comments_url":"https://api.github.com/repos/itkpi/events-parser/comments{/number}","issue_comment_url":"https://api.github.com/repos/itkpi/events-parser/issues/comments{/number}","contents_url":"https://api.github.com/repos/itkpi/events-parser/contents/{+path}","compare_url":"https://api.github.com/repos/itkpi/events-parser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/itkpi/events-parser/merges","archive_url":"https://api.github.com/repos/itkpi/events-parser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/itkpi/events-parser/downloads","issues_url":"https://api.github.com/repos/itkpi/events-parser/issues{/number}","pulls_url":"https://api.github.com/repos/itkpi/events-parser/pulls{/number}","milestones_url":"https://api.github.com/repos/itkpi/events-parser/milestones{/number}","notifications_url":"https://api.github.com/repos/itkpi/events-parser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/itkpi/events-parser/labels{/name}","releases_url":"https://api.github.com/repos/itkpi/events-parser/releases{/id}","deployments_url":"https://api.github.com/repos/itkpi/events-parser/deployments","created_at":"2016-02-06T23:15:43Z","updated_at":"2016-02-17T16:09:24Z","pushed_at":"2016-08-05T03:41:16Z","git_url":"git://github.com/itkpi/events-parser.git","ssh_url":"git@github.com:itkpi/events-parser.git","clone_url":"https://github.com/itkpi/events-parser.git","svn_url":"https://github.com/itkpi/events-parser","homepage":"http://itkpi.pp.ua/events/","size":103,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"itkpi:master","ref":"master","sha":"0887e6a1eaa1c92f4e0ef6ee00ccf3add9eafffe","user":{"login":"itkpi","id":12073380,"avatar_url":"https://avatars.githubusercontent.com/u/12073380?v=3","gravatar_id":"","url":"https://api.github.com/users/itkpi","html_url":"https://github.com/itkpi","followers_url":"https://api.github.com/users/itkpi/followers","following_url":"https://api.github.com/users/itkpi/following{/other_user}","gists_url":"https://api.github.com/users/itkpi/gists{/gist_id}","starred_url":"https://api.github.com/users/itkpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itkpi/subscriptions","organizations_url":"https://api.github.com/users/itkpi/orgs","repos_url":"https://api.github.com/users/itkpi/repos","events_url":"https://api.github.com/users/itkpi/events{/privacy}","received_events_url":"https://api.github.com/users/itkpi/received_events","type":"Organization","site_admin":false},"repo":{"id":51226809,"name":"events-parser","full_name":"itkpi/events-parser","owner":{"login":"itkpi","id":12073380,"avatar_url":"https://avatars.githubusercontent.com/u/12073380?v=3","gravatar_id":"","url":"https://api.github.com/users/itkpi","html_url":"https://github.com/itkpi","followers_url":"https://api.github.com/users/itkpi/followers","following_url":"https://api.github.com/users/itkpi/following{/other_user}","gists_url":"https://api.github.com/users/itkpi/gists{/gist_id}","starred_url":"https://api.github.com/users/itkpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itkpi/subscriptions","organizations_url":"https://api.github.com/users/itkpi/orgs","repos_url":"https://api.github.com/users/itkpi/repos","events_url":"https://api.github.com/users/itkpi/events{/privacy}","received_events_url":"https://api.github.com/users/itkpi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/itkpi/events-parser","description":"","fork":false,"url":"https://api.github.com/repos/itkpi/events-parser","forks_url":"https://api.github.com/repos/itkpi/events-parser/forks","keys_url":"https://api.github.com/repos/itkpi/events-parser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/itkpi/events-parser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/itkpi/events-parser/teams","hooks_url":"https://api.github.com/repos/itkpi/events-parser/hooks","issue_events_url":"https://api.github.com/repos/itkpi/events-parser/issues/events{/number}","events_url":"https://api.github.com/repos/itkpi/events-parser/events","assignees_url":"https://api.github.com/repos/itkpi/events-parser/assignees{/user}","branches_url":"https://api.github.com/repos/itkpi/events-parser/branches{/branch}","tags_url":"https://api.github.com/repos/itkpi/events-parser/tags","blobs_url":"https://api.github.com/repos/itkpi/events-parser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/itkpi/events-parser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/itkpi/events-parser/git/refs{/sha}","trees_url":"https://api.github.com/repos/itkpi/events-parser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/itkpi/events-parser/statuses/{sha}","languages_url":"https://api.github.com/repos/itkpi/events-parser/languages","stargazers_url":"https://api.github.com/repos/itkpi/events-parser/stargazers","contributors_url":"https://api.github.com/repos/itkpi/events-parser/contributors","subscribers_url":"https://api.github.com/repos/itkpi/events-parser/subscribers","subscription_url":"https://api.github.com/repos/itkpi/events-parser/subscription","commits_url":"https://api.github.com/repos/itkpi/events-parser/commits{/sha}","git_commits_url":"https://api.github.com/repos/itkpi/events-parser/git/commits{/sha}","comments_url":"https://api.github.com/repos/itkpi/events-parser/comments{/number}","issue_comment_url":"https://api.github.com/repos/itkpi/events-parser/issues/comments{/number}","contents_url":"https://api.github.com/repos/itkpi/events-parser/contents/{+path}","compare_url":"https://api.github.com/repos/itkpi/events-parser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/itkpi/events-parser/merges","archive_url":"https://api.github.com/repos/itkpi/events-parser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/itkpi/events-parser/downloads","issues_url":"https://api.github.com/repos/itkpi/events-parser/issues{/number}","pulls_url":"https://api.github.com/repos/itkpi/events-parser/pulls{/number}","milestones_url":"https://api.github.com/repos/itkpi/events-parser/milestones{/number}","notifications_url":"https://api.github.com/repos/itkpi/events-parser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/itkpi/events-parser/labels{/name}","releases_url":"https://api.github.com/repos/itkpi/events-parser/releases{/id}","deployments_url":"https://api.github.com/repos/itkpi/events-parser/deployments","created_at":"2016-02-06T23:15:43Z","updated_at":"2016-02-17T16:09:24Z","pushed_at":"2016-08-05T03:41:16Z","git_url":"git://github.com/itkpi/events-parser.git","ssh_url":"git@github.com:itkpi/events-parser.git","clone_url":"https://github.com/itkpi/events-parser.git","svn_url":"https://github.com/itkpi/events-parser","homepage":"http://itkpi.pp.ua/events/","size":103,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/itkpi/events-parser/pulls/21"},"html":{"href":"https://github.com/itkpi/events-parser/pull/21"},"issue":{"href":"https://api.github.com/repos/itkpi/events-parser/issues/21"},"comments":{"href":"https://api.github.com/repos/itkpi/events-parser/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/itkpi/events-parser/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/itkpi/events-parser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/itkpi/events-parser/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/itkpi/events-parser/statuses/0c6ee804473b15cb29e343b58347858d6affcbaf"}}}}
{"actor":{"display_login":"codacy-bot"}}