{"action":"created","comment":{"url":"https://api.github.com/repos/propeopleua/d8intranet/pulls/comments/42480425","id":42480425,"diff_hunk":"@@ -0,0 +1,107 @@\n+<?php\n+use Drupal\\Core\\Entity\\EntityTypeInterface;\n+use Drupal\\Core\\Field\\BaseFieldDefinition;\n+use Drupal\\Core\\Routing\\RouteMatchInterface;\n+use Drupal\\intranet_jira\\IntranetJiraApiRest;\n+use Drupal\\intranet_jira\\IntranetJiraProjectTask;\n+\n+/**\n+ * Add jira field to user entity\n+ *\n+ * @param $fields\n+ * @param \\Drupal\\Core\\Entity\\EntityTypeInterface $entity_type\n+ */\n+function intranet_jira_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {\n+  // Alter the field to use a custom class.\n+  if ($entity_type->id() == 'user') {\n+    $fields['field_jira_worklog'] = BaseFieldDefinition::create('list_string')\n+      ->setName('field_jira_worklog')\n+      ->setLabel(t('field_jira_worklog'))\n+      ->setDescription(t('field_jira_worklog.'))\n+      ->setTranslatable(FALSE)\n+      ->setQueryable(FALSE)\n+      ->setComputed(TRUE);\n+\n+  }\n+}\n+\n+/**\n+ * Add worklog time to entity\n+ *\n+ * @param array $entities\n+ * @param $entity_type_id\n+ */\n+function intranet_jira_entity_load(array $entities, $entity_type_id) {\n+\n+  if ($entity_type_id == \"user\") {\n+\n+    $storage = \\Drupal::service(\"intranet_jira.storage\");\n+\n+    foreach ($entities as $entity) {\n+      $res = $storage->getLoggedTime($entity->name->value);\n+\n+      $entity->field_jira_worklog = array($res);\n+\n+    }\n+  }\n+\n+}\n+\n+\n+/**\n+ * Implements hook_help().\n+ */\n+function intranet_jira_help($route_name, RouteMatchInterface $route_match) {\n+  switch ($route_name) {\n+    // Main module help for the intranet_jira module.\n+    case 'help.page.intranet_jira':\n+      $output = '';\n+      $output .= '<h3>' . t('About') . '</h3>';\n+      $output .= '<p>' . t('Intranet Jira Integration') . '</p>';\n+      return $output;\n+\n+    default:\n+  }\n+}\n+/**\n+ * Implements hook_cron().\n+ *\n+ */\n+function intranet_jira_cron() {\n+\n+  $queue = \\Drupal::queue('intranet_jira_aggregator');\n+\n+  /**\n+   * @var IntranetJiraApiRest $jira\n+   */\n+  $jira = \\Drupal::service(\"intranet_jira.api_rest\");\n+\n+  /**\n+   * @var IntranetJiraProjectTask $project_task\n+   */\n+  foreach ($jira->loadMultiple(-3) as $project_task) {\n+\n+    if (!$project_task->timeExists() || !$project_task->timeUpdated()) {\n+      /**\n+       * @see IntranetJiraAggregator::processItem($project_task)\n+       */\n+      $queue->createItem($project_task);\n+    }\n+  }\n+\n+  /**\n+   * Clean up old worklogs\n+   */\n+  $query = \\Drupal::entityQuery('node')\n+    ->condition('type', 'jira_worklog')\n+    ->condition('field_jira_started', date(\"Y-m-d\", REQUEST_TIME - (86400 * 4)), '<');","path":"drupal/modules/custom/intranet_jira/intranet_jira.module","position":97,"original_position":97,"commit_id":"d81bc4c766ddf77998649d21717dd0af35200905","original_commit_id":"d81bc4c766ddf77998649d21717dd0af35200905","user":{"login":"Propeople-ua","id":3874464,"avatar_url":"https://avatars.githubusercontent.com/u/3874464?v=3","gravatar_id":"","url":"https://api.github.com/users/Propeople-ua","html_url":"https://github.com/Propeople-ua","followers_url":"https://api.github.com/users/Propeople-ua/followers","following_url":"https://api.github.com/users/Propeople-ua/following{/other_user}","gists_url":"https://api.github.com/users/Propeople-ua/gists{/gist_id}","starred_url":"https://api.github.com/users/Propeople-ua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Propeople-ua/subscriptions","organizations_url":"https://api.github.com/users/Propeople-ua/orgs","repos_url":"https://api.github.com/users/Propeople-ua/repos","events_url":"https://api.github.com/users/Propeople-ua/events{/privacy}","received_events_url":"https://api.github.com/users/Propeople-ua/received_events","type":"User","site_admin":false},"body":"86400 value should be const in class definition. For example ONE_DAY","created_at":"2015-10-20T10:49:23Z","updated_at":"2015-10-20T10:49:23Z","html_url":"https://github.com/propeopleua/d8intranet/pull/68#discussion_r42480425","pull_request_url":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68","_links":{"self":{"href":"https://api.github.com/repos/propeopleua/d8intranet/pulls/comments/42480425"},"html":{"href":"https://github.com/propeopleua/d8intranet/pull/68#discussion_r42480425"},"pull_request":{"href":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68"}}},"pull_request":{"url":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68","id":48134037,"html_url":"https://github.com/propeopleua/d8intranet/pull/68","diff_url":"https://github.com/propeopleua/d8intranet/pull/68.diff","patch_url":"https://github.com/propeopleua/d8intranet/pull/68.patch","issue_url":"https://api.github.com/repos/propeopleua/d8intranet/issues/68","number":68,"state":"closed","locked":false,"title":"Jira Rest Worklog User Helper","user":{"login":"spheresh","id":2073591,"avatar_url":"https://avatars.githubusercontent.com/u/2073591?v=3","gravatar_id":"","url":"https://api.github.com/users/spheresh","html_url":"https://github.com/spheresh","followers_url":"https://api.github.com/users/spheresh/followers","following_url":"https://api.github.com/users/spheresh/following{/other_user}","gists_url":"https://api.github.com/users/spheresh/gists{/gist_id}","starred_url":"https://api.github.com/users/spheresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spheresh/subscriptions","organizations_url":"https://api.github.com/users/spheresh/orgs","repos_url":"https://api.github.com/users/spheresh/repos","events_url":"https://api.github.com/users/spheresh/events{/privacy}","received_events_url":"https://api.github.com/users/spheresh/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-19T22:17:05Z","updated_at":"2015-10-20T10:49:23Z","closed_at":"2015-10-20T10:37:26Z","merged_at":"2015-10-20T10:37:26Z","merge_commit_sha":"6fa968dc76ffc3742cdf63a136d970b2ef755169","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68/commits","review_comments_url":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68/comments","review_comment_url":"https://api.github.com/repos/propeopleua/d8intranet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/propeopleua/d8intranet/issues/68/comments","statuses_url":"https://api.github.com/repos/propeopleua/d8intranet/statuses/d81bc4c766ddf77998649d21717dd0af35200905","head":{"label":"spheresh:BR-11","ref":"BR-11","sha":"d81bc4c766ddf77998649d21717dd0af35200905","user":{"login":"spheresh","id":2073591,"avatar_url":"https://avatars.githubusercontent.com/u/2073591?v=3","gravatar_id":"","url":"https://api.github.com/users/spheresh","html_url":"https://github.com/spheresh","followers_url":"https://api.github.com/users/spheresh/followers","following_url":"https://api.github.com/users/spheresh/following{/other_user}","gists_url":"https://api.github.com/users/spheresh/gists{/gist_id}","starred_url":"https://api.github.com/users/spheresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spheresh/subscriptions","organizations_url":"https://api.github.com/users/spheresh/orgs","repos_url":"https://api.github.com/users/spheresh/repos","events_url":"https://api.github.com/users/spheresh/events{/privacy}","received_events_url":"https://api.github.com/users/spheresh/received_events","type":"User","site_admin":false},"repo":{"id":43894792,"name":"d8intranet","full_name":"spheresh/d8intranet","owner":{"login":"spheresh","id":2073591,"avatar_url":"https://avatars.githubusercontent.com/u/2073591?v=3","gravatar_id":"","url":"https://api.github.com/users/spheresh","html_url":"https://github.com/spheresh","followers_url":"https://api.github.com/users/spheresh/followers","following_url":"https://api.github.com/users/spheresh/following{/other_user}","gists_url":"https://api.github.com/users/spheresh/gists{/gist_id}","starred_url":"https://api.github.com/users/spheresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spheresh/subscriptions","organizations_url":"https://api.github.com/users/spheresh/orgs","repos_url":"https://api.github.com/users/spheresh/repos","events_url":"https://api.github.com/users/spheresh/events{/privacy}","received_events_url":"https://api.github.com/users/spheresh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spheresh/d8intranet","description":"d8intranet","fork":true,"url":"https://api.github.com/repos/spheresh/d8intranet","forks_url":"https://api.github.com/repos/spheresh/d8intranet/forks","keys_url":"https://api.github.com/repos/spheresh/d8intranet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spheresh/d8intranet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spheresh/d8intranet/teams","hooks_url":"https://api.github.com/repos/spheresh/d8intranet/hooks","issue_events_url":"https://api.github.com/repos/spheresh/d8intranet/issues/events{/number}","events_url":"https://api.github.com/repos/spheresh/d8intranet/events","assignees_url":"https://api.github.com/repos/spheresh/d8intranet/assignees{/user}","branches_url":"https://api.github.com/repos/spheresh/d8intranet/branches{/branch}","tags_url":"https://api.github.com/repos/spheresh/d8intranet/tags","blobs_url":"https://api.github.com/repos/spheresh/d8intranet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spheresh/d8intranet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spheresh/d8intranet/git/refs{/sha}","trees_url":"https://api.github.com/repos/spheresh/d8intranet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spheresh/d8intranet/statuses/{sha}","languages_url":"https://api.github.com/repos/spheresh/d8intranet/languages","stargazers_url":"https://api.github.com/repos/spheresh/d8intranet/stargazers","contributors_url":"https://api.github.com/repos/spheresh/d8intranet/contributors","subscribers_url":"https://api.github.com/repos/spheresh/d8intranet/subscribers","subscription_url":"https://api.github.com/repos/spheresh/d8intranet/subscription","commits_url":"https://api.github.com/repos/spheresh/d8intranet/commits{/sha}","git_commits_url":"https://api.github.com/repos/spheresh/d8intranet/git/commits{/sha}","comments_url":"https://api.github.com/repos/spheresh/d8intranet/comments{/number}","issue_comment_url":"https://api.github.com/repos/spheresh/d8intranet/issues/comments{/number}","contents_url":"https://api.github.com/repos/spheresh/d8intranet/contents/{+path}","compare_url":"https://api.github.com/repos/spheresh/d8intranet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spheresh/d8intranet/merges","archive_url":"https://api.github.com/repos/spheresh/d8intranet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spheresh/d8intranet/downloads","issues_url":"https://api.github.com/repos/spheresh/d8intranet/issues{/number}","pulls_url":"https://api.github.com/repos/spheresh/d8intranet/pulls{/number}","milestones_url":"https://api.github.com/repos/spheresh/d8intranet/milestones{/number}","notifications_url":"https://api.github.com/repos/spheresh/d8intranet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spheresh/d8intranet/labels{/name}","releases_url":"https://api.github.com/repos/spheresh/d8intranet/releases{/id}","created_at":"2015-10-08T14:37:08Z","updated_at":"2015-10-08T14:37:26Z","pushed_at":"2015-10-19T22:15:07Z","git_url":"git://github.com/spheresh/d8intranet.git","ssh_url":"git@github.com:spheresh/d8intranet.git","clone_url":"https://github.com/spheresh/d8intranet.git","svn_url":"https://github.com/spheresh/d8intranet","homepage":null,"size":23341,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"propeopleua:jira","ref":"jira","sha":"a4535ee10209f02e6e8d4c5efa55ea323abbaf44","user":{"login":"propeopleua","id":10233804,"avatar_url":"https://avatars.githubusercontent.com/u/10233804?v=3","gravatar_id":"","url":"https://api.github.com/users/propeopleua","html_url":"https://github.com/propeopleua","followers_url":"https://api.github.com/users/propeopleua/followers","following_url":"https://api.github.com/users/propeopleua/following{/other_user}","gists_url":"https://api.github.com/users/propeopleua/gists{/gist_id}","starred_url":"https://api.github.com/users/propeopleua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/propeopleua/subscriptions","organizations_url":"https://api.github.com/users/propeopleua/orgs","repos_url":"https://api.github.com/users/propeopleua/repos","events_url":"https://api.github.com/users/propeopleua/events{/privacy}","received_events_url":"https://api.github.com/users/propeopleua/received_events","type":"Organization","site_admin":false},"repo":{"id":33937951,"name":"d8intranet","full_name":"propeopleua/d8intranet","owner":{"login":"propeopleua","id":10233804,"avatar_url":"https://avatars.githubusercontent.com/u/10233804?v=3","gravatar_id":"","url":"https://api.github.com/users/propeopleua","html_url":"https://github.com/propeopleua","followers_url":"https://api.github.com/users/propeopleua/followers","following_url":"https://api.github.com/users/propeopleua/following{/other_user}","gists_url":"https://api.github.com/users/propeopleua/gists{/gist_id}","starred_url":"https://api.github.com/users/propeopleua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/propeopleua/subscriptions","organizations_url":"https://api.github.com/users/propeopleua/orgs","repos_url":"https://api.github.com/users/propeopleua/repos","events_url":"https://api.github.com/users/propeopleua/events{/privacy}","received_events_url":"https://api.github.com/users/propeopleua/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/propeopleua/d8intranet","description":"d8intranet","fork":false,"url":"https://api.github.com/repos/propeopleua/d8intranet","forks_url":"https://api.github.com/repos/propeopleua/d8intranet/forks","keys_url":"https://api.github.com/repos/propeopleua/d8intranet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/propeopleua/d8intranet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/propeopleua/d8intranet/teams","hooks_url":"https://api.github.com/repos/propeopleua/d8intranet/hooks","issue_events_url":"https://api.github.com/repos/propeopleua/d8intranet/issues/events{/number}","events_url":"https://api.github.com/repos/propeopleua/d8intranet/events","assignees_url":"https://api.github.com/repos/propeopleua/d8intranet/assignees{/user}","branches_url":"https://api.github.com/repos/propeopleua/d8intranet/branches{/branch}","tags_url":"https://api.github.com/repos/propeopleua/d8intranet/tags","blobs_url":"https://api.github.com/repos/propeopleua/d8intranet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/propeopleua/d8intranet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/propeopleua/d8intranet/git/refs{/sha}","trees_url":"https://api.github.com/repos/propeopleua/d8intranet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/propeopleua/d8intranet/statuses/{sha}","languages_url":"https://api.github.com/repos/propeopleua/d8intranet/languages","stargazers_url":"https://api.github.com/repos/propeopleua/d8intranet/stargazers","contributors_url":"https://api.github.com/repos/propeopleua/d8intranet/contributors","subscribers_url":"https://api.github.com/repos/propeopleua/d8intranet/subscribers","subscription_url":"https://api.github.com/repos/propeopleua/d8intranet/subscription","commits_url":"https://api.github.com/repos/propeopleua/d8intranet/commits{/sha}","git_commits_url":"https://api.github.com/repos/propeopleua/d8intranet/git/commits{/sha}","comments_url":"https://api.github.com/repos/propeopleua/d8intranet/comments{/number}","issue_comment_url":"https://api.github.com/repos/propeopleua/d8intranet/issues/comments{/number}","contents_url":"https://api.github.com/repos/propeopleua/d8intranet/contents/{+path}","compare_url":"https://api.github.com/repos/propeopleua/d8intranet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/propeopleua/d8intranet/merges","archive_url":"https://api.github.com/repos/propeopleua/d8intranet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/propeopleua/d8intranet/downloads","issues_url":"https://api.github.com/repos/propeopleua/d8intranet/issues{/number}","pulls_url":"https://api.github.com/repos/propeopleua/d8intranet/pulls{/number}","milestones_url":"https://api.github.com/repos/propeopleua/d8intranet/milestones{/number}","notifications_url":"https://api.github.com/repos/propeopleua/d8intranet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/propeopleua/d8intranet/labels{/name}","releases_url":"https://api.github.com/repos/propeopleua/d8intranet/releases{/id}","created_at":"2015-04-14T14:50:14Z","updated_at":"2015-09-21T09:20:26Z","pushed_at":"2015-10-20T10:37:27Z","git_url":"git://github.com/propeopleua/d8intranet.git","ssh_url":"git@github.com:propeopleua/d8intranet.git","clone_url":"https://github.com/propeopleua/d8intranet.git","svn_url":"https://github.com/propeopleua/d8intranet","homepage":null,"size":23929,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":9,"forks":7,"open_issues":9,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68"},"html":{"href":"https://github.com/propeopleua/d8intranet/pull/68"},"issue":{"href":"https://api.github.com/repos/propeopleua/d8intranet/issues/68"},"comments":{"href":"https://api.github.com/repos/propeopleua/d8intranet/issues/68/comments"},"review_comments":{"href":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68/comments"},"review_comment":{"href":"https://api.github.com/repos/propeopleua/d8intranet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/propeopleua/d8intranet/pulls/68/commits"},"statuses":{"href":"https://api.github.com/repos/propeopleua/d8intranet/statuses/d81bc4c766ddf77998649d21717dd0af35200905"}}}}