{"action":"created","comment":{"url":"https://api.github.com/repos/adshares/server/pulls/comments/189380086","pull_request_review_id":121556174,"id":189380086,"diff_hunk":"@@ -0,0 +1,167 @@\n+<?php\n+\n+namespace Adshares\\Adserver\\Models;\n+\n+use Adshares\\Adserver\\Models\\NetworkBanner;\n+use Adshares\\Adserver\\Models\\NetworkCampaignExclude;\n+use Adshares\\Adserver\\Models\\NetworkCampaignRequire;\n+\n+use Adshares\\Adserver\\Models\\Traits\\AutomateMutators;\n+use Adshares\\Adserver\\Models\\Traits\\BinHex;\n+\n+use Illuminate\\Database\\Eloquent\\Model;\n+use Illuminate\\Support\\Collection;\n+use Illuminate\\Support\\Facades\\DB;\n+\n+class NetworkCampaign extends Model\n+{\n+    use AutomateMutators;\n+    use BinHex;\n+\n+    /**\n+     * The attributes that are mass assignable.\n+     *\n+     * @var array\n+     */\n+    protected $fillable = [\n+      'uuid',\n+      'source_created_at', 'source_updated_at',\n+      'source_host', 'adshares_address',\n+      'landing_url', 'max_cpm', 'max_cpc', 'budget_per_hour', 'time_start', 'time_end',\n+    ];\n+\n+    /**\n+     * The attributes that should be hidden for arrays.\n+     *\n+     * @var array\n+     */\n+    protected $hidden = [\n+      'id'\n+    ];\n+\n+    /**\n+    * The attributes that use some Models\\Traits with mutator settings automation\n+    *\n+    * @var array\n+    */\n+    protected $traitAutomate = [\n+      'uuid' => 'BinHex',\n+    ];\n+\n+    public function banners()\n+    {\n+        return $this->hasMany('Adshares\\Adserver\\Models\\NetworkBanner');\n+    }\n+\n+    public function campaignExcludes()\n+    {\n+        return $this->hasMany('Adshares\\Adserver\\Models\\NetworkCampaignExclude');\n+    }\n+\n+    public function campaignRequires()\n+    {\n+        return $this->hasMany('Adshares\\Adserver\\Models\\NetworkCampaignRequire');\n+    }\n+\n+    protected static function convertTimestampsToSourceTimestamps($array)\n+    {\n+        $array['source_created_at'] = $array['created_at'];\n+        $array['source_updated_at'] = $array['updated_at'];\n+        unset($array['created_at']);\n+        unset($array['updated_at']);\n+        return $array;\n+    }\n+\n+    protected static function jsonDataMakeUUIDKeys(array &$data)\n+    {\n+        foreach ($data['banners'] as $i => $d) {\n+            $data['banners'][$d['uuid']] = self::convertTimestampsToSourceTimestamps($d);\n+            unset($data['banners'][$i]);\n+        }\n+        foreach ($data['campaign_excludes'] as $i => $d) {\n+            $data['campaign_excludes'][$d['uuid']] = self::convertTimestampsToSourceTimestamps($d);\n+            unset($data['campaign_excludes'][$i]);\n+        }\n+        foreach ($data['campaign_requires'] as $i => $d) {\n+            $data['campaign_requires'][$d['uuid']] = self::convertTimestampsToSourceTimestamps($d);\n+            unset($data['campaign_requires'][$i]);\n+        }\n+    }\n+\n+    public static function fromJsonData(array $data)\n+    {\n+        DB::beginTransaction();\n+\n+        // print_r($data);\n+\n+        $campaign = self::with('Banners', 'CampaignExcludes', 'CampaignRequires')->where('uuid', hex2bin($data['uuid']))->lockForUpdate()->first();\n+\n+        if (empty($campaign)) {\n+            $campaign = self::fromJsonDataNew($data);\n+        } else {\n+            $campaign = self::fromJsonDataUpdate($campaign, $data);\n+        }\n+\n+        // print_r($campaign->toArray());","path":"app/Models/NetworkCampaign.php","position":105,"original_position":105,"commit_id":"fd9ee50e5fa237aa381e5edaf629f5d7d61d1c0a","original_commit_id":"fd9ee50e5fa237aa381e5edaf629f5d7d61d1c0a","user":{"login":"adshares-tech","id":37212325,"avatar_url":"https://avatars2.githubusercontent.com/u/37212325?v=4","gravatar_id":"","url":"https://api.github.com/users/adshares-tech","html_url":"https://github.com/adshares-tech","followers_url":"https://api.github.com/users/adshares-tech/followers","following_url":"https://api.github.com/users/adshares-tech/following{/other_user}","gists_url":"https://api.github.com/users/adshares-tech/gists{/gist_id}","starred_url":"https://api.github.com/users/adshares-tech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adshares-tech/subscriptions","organizations_url":"https://api.github.com/users/adshares-tech/orgs","repos_url":"https://api.github.com/users/adshares-tech/repos","events_url":"https://api.github.com/users/adshares-tech/events{/privacy}","received_events_url":"https://api.github.com/users/adshares-tech/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://sonarsource.github.io/sonar-github/severity-major.png 'Severity: MAJOR') Remove this commented out code. [![rule](https://sonarsource.github.io/sonar-github/rule.png)](https://sonarcloud.io/coding_rules#rule_key=php%3AS125)\n","created_at":"2018-05-18T20:06:18Z","updated_at":"2018-05-18T20:06:18Z","html_url":"https://github.com/adshares/server/pull/29#discussion_r189380086","pull_request_url":"https://api.github.com/repos/adshares/server/pulls/29","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/adshares/server/pulls/comments/189380086"},"html":{"href":"https://github.com/adshares/server/pull/29#discussion_r189380086"},"pull_request":{"href":"https://api.github.com/repos/adshares/server/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/adshares/server/pulls/29","id":189121792,"html_url":"https://github.com/adshares/server/pull/29","diff_url":"https://github.com/adshares/server/pull/29.diff","patch_url":"https://github.com/adshares/server/pull/29.patch","issue_url":"https://api.github.com/repos/adshares/server/issues/29","number":29,"state":"open","locked":false,"title":"Migration step 3","user":{"login":"yodahack","id":19958053,"avatar_url":"https://avatars1.githubusercontent.com/u/19958053?v=4","gravatar_id":"","url":"https://api.github.com/users/yodahack","html_url":"https://github.com/yodahack","followers_url":"https://api.github.com/users/yodahack/followers","following_url":"https://api.github.com/users/yodahack/following{/other_user}","gists_url":"https://api.github.com/users/yodahack/gists{/gist_id}","starred_url":"https://api.github.com/users/yodahack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yodahack/subscriptions","organizations_url":"https://api.github.com/users/yodahack/orgs","repos_url":"https://api.github.com/users/yodahack/repos","events_url":"https://api.github.com/users/yodahack/events{/privacy}","received_events_url":"https://api.github.com/users/yodahack/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-18T20:02:54Z","updated_at":"2018-05-18T20:06:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9830d05edcc9d03c3576ca919e27974af3ff0ffc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/adshares/server/pulls/29/commits","review_comments_url":"https://api.github.com/repos/adshares/server/pulls/29/comments","review_comment_url":"https://api.github.com/repos/adshares/server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adshares/server/issues/29/comments","statuses_url":"https://api.github.com/repos/adshares/server/statuses/fd9ee50e5fa237aa381e5edaf629f5d7d61d1c0a","head":{"label":"adshares:migration-step-3","ref":"migration-step-3","sha":"fd9ee50e5fa237aa381e5edaf629f5d7d61d1c0a","user":{"login":"adshares","id":19405131,"avatar_url":"https://avatars2.githubusercontent.com/u/19405131?v=4","gravatar_id":"","url":"https://api.github.com/users/adshares","html_url":"https://github.com/adshares","followers_url":"https://api.github.com/users/adshares/followers","following_url":"https://api.github.com/users/adshares/following{/other_user}","gists_url":"https://api.github.com/users/adshares/gists{/gist_id}","starred_url":"https://api.github.com/users/adshares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adshares/subscriptions","organizations_url":"https://api.github.com/users/adshares/orgs","repos_url":"https://api.github.com/users/adshares/repos","events_url":"https://api.github.com/users/adshares/events{/privacy}","received_events_url":"https://api.github.com/users/adshares/received_events","type":"Organization","site_admin":false},"repo":{"id":127163371,"name":"server","full_name":"adshares/server","owner":{"login":"adshares","id":19405131,"avatar_url":"https://avatars2.githubusercontent.com/u/19405131?v=4","gravatar_id":"","url":"https://api.github.com/users/adshares","html_url":"https://github.com/adshares","followers_url":"https://api.github.com/users/adshares/followers","following_url":"https://api.github.com/users/adshares/following{/other_user}","gists_url":"https://api.github.com/users/adshares/gists{/gist_id}","starred_url":"https://api.github.com/users/adshares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adshares/subscriptions","organizations_url":"https://api.github.com/users/adshares/orgs","repos_url":"https://api.github.com/users/adshares/repos","events_url":"https://api.github.com/users/adshares/events{/privacy}","received_events_url":"https://api.github.com/users/adshares/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adshares/server","description":null,"fork":false,"url":"https://api.github.com/repos/adshares/server","forks_url":"https://api.github.com/repos/adshares/server/forks","keys_url":"https://api.github.com/repos/adshares/server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adshares/server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adshares/server/teams","hooks_url":"https://api.github.com/repos/adshares/server/hooks","issue_events_url":"https://api.github.com/repos/adshares/server/issues/events{/number}","events_url":"https://api.github.com/repos/adshares/server/events","assignees_url":"https://api.github.com/repos/adshares/server/assignees{/user}","branches_url":"https://api.github.com/repos/adshares/server/branches{/branch}","tags_url":"https://api.github.com/repos/adshares/server/tags","blobs_url":"https://api.github.com/repos/adshares/server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adshares/server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adshares/server/git/refs{/sha}","trees_url":"https://api.github.com/repos/adshares/server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adshares/server/statuses/{sha}","languages_url":"https://api.github.com/repos/adshares/server/languages","stargazers_url":"https://api.github.com/repos/adshares/server/stargazers","contributors_url":"https://api.github.com/repos/adshares/server/contributors","subscribers_url":"https://api.github.com/repos/adshares/server/subscribers","subscription_url":"https://api.github.com/repos/adshares/server/subscription","commits_url":"https://api.github.com/repos/adshares/server/commits{/sha}","git_commits_url":"https://api.github.com/repos/adshares/server/git/commits{/sha}","comments_url":"https://api.github.com/repos/adshares/server/comments{/number}","issue_comment_url":"https://api.github.com/repos/adshares/server/issues/comments{/number}","contents_url":"https://api.github.com/repos/adshares/server/contents/{+path}","compare_url":"https://api.github.com/repos/adshares/server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adshares/server/merges","archive_url":"https://api.github.com/repos/adshares/server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adshares/server/downloads","issues_url":"https://api.github.com/repos/adshares/server/issues{/number}","pulls_url":"https://api.github.com/repos/adshares/server/pulls{/number}","milestones_url":"https://api.github.com/repos/adshares/server/milestones{/number}","notifications_url":"https://api.github.com/repos/adshares/server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adshares/server/labels{/name}","releases_url":"https://api.github.com/repos/adshares/server/releases{/id}","deployments_url":"https://api.github.com/repos/adshares/server/deployments","created_at":"2018-03-28T15:46:40Z","updated_at":"2018-05-10T09:54:37Z","pushed_at":"2018-05-18T20:02:55Z","git_url":"git://github.com/adshares/server.git","ssh_url":"git@github.com:adshares/server.git","clone_url":"https://github.com/adshares/server.git","svn_url":"https://github.com/adshares/server","homepage":null,"size":356,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":17,"license":null,"forks":0,"open_issues":17,"watchers":0,"default_branch":"master"}},"base":{"label":"adshares:master","ref":"master","sha":"7f117ab4bb6b0db86fd4b5692eca9cda0bf83786","user":{"login":"adshares","id":19405131,"avatar_url":"https://avatars2.githubusercontent.com/u/19405131?v=4","gravatar_id":"","url":"https://api.github.com/users/adshares","html_url":"https://github.com/adshares","followers_url":"https://api.github.com/users/adshares/followers","following_url":"https://api.github.com/users/adshares/following{/other_user}","gists_url":"https://api.github.com/users/adshares/gists{/gist_id}","starred_url":"https://api.github.com/users/adshares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adshares/subscriptions","organizations_url":"https://api.github.com/users/adshares/orgs","repos_url":"https://api.github.com/users/adshares/repos","events_url":"https://api.github.com/users/adshares/events{/privacy}","received_events_url":"https://api.github.com/users/adshares/received_events","type":"Organization","site_admin":false},"repo":{"id":127163371,"name":"server","full_name":"adshares/server","owner":{"login":"adshares","id":19405131,"avatar_url":"https://avatars2.githubusercontent.com/u/19405131?v=4","gravatar_id":"","url":"https://api.github.com/users/adshares","html_url":"https://github.com/adshares","followers_url":"https://api.github.com/users/adshares/followers","following_url":"https://api.github.com/users/adshares/following{/other_user}","gists_url":"https://api.github.com/users/adshares/gists{/gist_id}","starred_url":"https://api.github.com/users/adshares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adshares/subscriptions","organizations_url":"https://api.github.com/users/adshares/orgs","repos_url":"https://api.github.com/users/adshares/repos","events_url":"https://api.github.com/users/adshares/events{/privacy}","received_events_url":"https://api.github.com/users/adshares/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/adshares/server","description":null,"fork":false,"url":"https://api.github.com/repos/adshares/server","forks_url":"https://api.github.com/repos/adshares/server/forks","keys_url":"https://api.github.com/repos/adshares/server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adshares/server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adshares/server/teams","hooks_url":"https://api.github.com/repos/adshares/server/hooks","issue_events_url":"https://api.github.com/repos/adshares/server/issues/events{/number}","events_url":"https://api.github.com/repos/adshares/server/events","assignees_url":"https://api.github.com/repos/adshares/server/assignees{/user}","branches_url":"https://api.github.com/repos/adshares/server/branches{/branch}","tags_url":"https://api.github.com/repos/adshares/server/tags","blobs_url":"https://api.github.com/repos/adshares/server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adshares/server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adshares/server/git/refs{/sha}","trees_url":"https://api.github.com/repos/adshares/server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adshares/server/statuses/{sha}","languages_url":"https://api.github.com/repos/adshares/server/languages","stargazers_url":"https://api.github.com/repos/adshares/server/stargazers","contributors_url":"https://api.github.com/repos/adshares/server/contributors","subscribers_url":"https://api.github.com/repos/adshares/server/subscribers","subscription_url":"https://api.github.com/repos/adshares/server/subscription","commits_url":"https://api.github.com/repos/adshares/server/commits{/sha}","git_commits_url":"https://api.github.com/repos/adshares/server/git/commits{/sha}","comments_url":"https://api.github.com/repos/adshares/server/comments{/number}","issue_comment_url":"https://api.github.com/repos/adshares/server/issues/comments{/number}","contents_url":"https://api.github.com/repos/adshares/server/contents/{+path}","compare_url":"https://api.github.com/repos/adshares/server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adshares/server/merges","archive_url":"https://api.github.com/repos/adshares/server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adshares/server/downloads","issues_url":"https://api.github.com/repos/adshares/server/issues{/number}","pulls_url":"https://api.github.com/repos/adshares/server/pulls{/number}","milestones_url":"https://api.github.com/repos/adshares/server/milestones{/number}","notifications_url":"https://api.github.com/repos/adshares/server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adshares/server/labels{/name}","releases_url":"https://api.github.com/repos/adshares/server/releases{/id}","deployments_url":"https://api.github.com/repos/adshares/server/deployments","created_at":"2018-03-28T15:46:40Z","updated_at":"2018-05-10T09:54:37Z","pushed_at":"2018-05-18T20:02:55Z","git_url":"git://github.com/adshares/server.git","ssh_url":"git@github.com:adshares/server.git","clone_url":"https://github.com/adshares/server.git","svn_url":"https://github.com/adshares/server","homepage":null,"size":356,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":17,"license":null,"forks":0,"open_issues":17,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adshares/server/pulls/29"},"html":{"href":"https://github.com/adshares/server/pull/29"},"issue":{"href":"https://api.github.com/repos/adshares/server/issues/29"},"comments":{"href":"https://api.github.com/repos/adshares/server/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/adshares/server/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/adshares/server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adshares/server/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/adshares/server/statuses/fd9ee50e5fa237aa381e5edaf629f5d7d61d1c0a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"adshares-tech"}}