{"action":"created","comment":{"url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/comments/111739372","pull_request_review_id":33000546,"id":111739372,"diff_hunk":"@@ -0,0 +1,42 @@\n+<?php\n+\n+namespace Happyr\\DoctrineSpecification\\Result;\n+\n+use Doctrine\\ORM\\AbstractQuery;\n+use Doctrine\\ORM\\Query\\Parameter;\n+\n+/**\n+ * Round DateTime to seconds in query params.\n+ */\n+class RoundTime implements ResultModifier\n+{\n+    /**\n+     * @var int How may seconds to round time\n+     */\n+    private $roundSeconds;\n+\n+    /**\n+     * @param int $roundSeconds How may seconds to round time\n+     */\n+    public function __construct($roundSeconds)\n+    {\n+        $this->roundSeconds = $roundSeconds;\n+    }\n+\n+    /**\n+     * @param AbstractQuery $query\n+     */\n+    public function modify(AbstractQuery $query)\n+    {\n+        foreach ($query->getParameters() as $parameter) {\n+            /* @var $parameter Parameter */\n+            if ($parameter->getValue() instanceof \\DateTime) {\n+                // round down so that the results do not include data that should not be there.\n+                $date = clone $parameter->getValue();\n+                $date->setTimestamp(floor($date->getTimestamp() / $this->roundSeconds) * $this->roundSeconds);","path":"src/Result/RoundTime.php","position":36,"original_position":36,"commit_id":"0e5b87781498fefffd1618c2e6cf2dfb796c6732","original_commit_id":"0e5b87781498fefffd1618c2e6cf2dfb796c6732","user":{"login":"Nyholm","id":1275206,"avatar_url":"https://avatars1.githubusercontent.com/u/1275206?v=3","gravatar_id":"","url":"https://api.github.com/users/Nyholm","html_url":"https://github.com/Nyholm","followers_url":"https://api.github.com/users/Nyholm/followers","following_url":"https://api.github.com/users/Nyholm/following{/other_user}","gists_url":"https://api.github.com/users/Nyholm/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyholm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyholm/subscriptions","organizations_url":"https://api.github.com/users/Nyholm/orgs","repos_url":"https://api.github.com/users/Nyholm/repos","events_url":"https://api.github.com/users/Nyholm/events{/privacy}","received_events_url":"https://api.github.com/users/Nyholm/received_events","type":"User","site_admin":false},"body":"$data = $date->..","created_at":"2017-04-17T13:09:30Z","updated_at":"2017-04-17T13:14:38Z","html_url":"https://github.com/Happyr/Doctrine-Specification/pull/146#discussion_r111739372","pull_request_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146","_links":{"self":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/comments/111739372"},"html":{"href":"https://github.com/Happyr/Doctrine-Specification/pull/146#discussion_r111739372"},"pull_request":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146"}}},"pull_request":{"url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146","id":114778832,"html_url":"https://github.com/Happyr/Doctrine-Specification/pull/146","diff_url":"https://github.com/Happyr/Doctrine-Specification/pull/146.diff","patch_url":"https://github.com/Happyr/Doctrine-Specification/pull/146.patch","issue_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues/146","number":146,"state":"open","locked":false,"title":"Round DateTime in query params","user":{"login":"peter-gribanov","id":1954436,"avatar_url":"https://avatars2.githubusercontent.com/u/1954436?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-gribanov","html_url":"https://github.com/peter-gribanov","followers_url":"https://api.github.com/users/peter-gribanov/followers","following_url":"https://api.github.com/users/peter-gribanov/following{/other_user}","gists_url":"https://api.github.com/users/peter-gribanov/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-gribanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-gribanov/subscriptions","organizations_url":"https://api.github.com/users/peter-gribanov/orgs","repos_url":"https://api.github.com/users/peter-gribanov/repos","events_url":"https://api.github.com/users/peter-gribanov/events{/privacy}","received_events_url":"https://api.github.com/users/peter-gribanov/received_events","type":"User","site_admin":false},"body":"**BC broken!**\r\n\r\n## Why is this necessary?\r\n\r\nThis is necessary for the normal operation of the caching system.\r\nThe Doctrine creates a cache key based on the query and its parameters.\r\nIf you use time with seconds as a parameter, the cache will not work because time changes constantly.\r\n\r\nExample\r\n\r\n```php\r\n// this query will not be cached\r\n$result = $rep->match(Spec::lt('date_publication', new \\DateTime()), Spec::cache(60));\r\n```\r\n\r\n```php\r\n// remove seconds from DateTime\r\n$now =  new \\DateTime();\r\n$now->setTime($now->format('H'), $now->format('i'), 0);\r\n\r\n// this query will be cached in 1 minute\r\n$result = $rep->match(Spec::lt('date_publication', $now), Spec::cache(60));\r\n```\r\n\r\n*It is probably better to make corrections to the Doctrine, and not to your library.*\r\n\r\nI began to actively use this functionality in the project on which i am currently working even before I started using your library.\r\n\r\nNow i use a wrapper over your method.","created_at":"2017-04-07T09:37:54Z","updated_at":"2017-04-17T13:14:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d5db31c9716ef3a35374008f21e2f99bfc8d973f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146/commits","review_comments_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146/comments","review_comment_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues/146/comments","statuses_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/statuses/0e5b87781498fefffd1618c2e6cf2dfb796c6732","head":{"label":"peter-gribanov:RoundDateOnCache","ref":"RoundDateOnCache","sha":"0e5b87781498fefffd1618c2e6cf2dfb796c6732","user":{"login":"peter-gribanov","id":1954436,"avatar_url":"https://avatars2.githubusercontent.com/u/1954436?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-gribanov","html_url":"https://github.com/peter-gribanov","followers_url":"https://api.github.com/users/peter-gribanov/followers","following_url":"https://api.github.com/users/peter-gribanov/following{/other_user}","gists_url":"https://api.github.com/users/peter-gribanov/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-gribanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-gribanov/subscriptions","organizations_url":"https://api.github.com/users/peter-gribanov/orgs","repos_url":"https://api.github.com/users/peter-gribanov/repos","events_url":"https://api.github.com/users/peter-gribanov/events{/privacy}","received_events_url":"https://api.github.com/users/peter-gribanov/received_events","type":"User","site_admin":false},"repo":{"id":86579233,"name":"Doctrine-Specification","full_name":"peter-gribanov/Doctrine-Specification","owner":{"login":"peter-gribanov","id":1954436,"avatar_url":"https://avatars2.githubusercontent.com/u/1954436?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-gribanov","html_url":"https://github.com/peter-gribanov","followers_url":"https://api.github.com/users/peter-gribanov/followers","following_url":"https://api.github.com/users/peter-gribanov/following{/other_user}","gists_url":"https://api.github.com/users/peter-gribanov/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-gribanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-gribanov/subscriptions","organizations_url":"https://api.github.com/users/peter-gribanov/orgs","repos_url":"https://api.github.com/users/peter-gribanov/repos","events_url":"https://api.github.com/users/peter-gribanov/events{/privacy}","received_events_url":"https://api.github.com/users/peter-gribanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peter-gribanov/Doctrine-Specification","description":"This library gives you a new way for writing queries. Using the Specification pattern you will get small Specification classes that are highly reusable.","fork":true,"url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification","forks_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/forks","keys_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/teams","hooks_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/hooks","issue_events_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/issues/events{/number}","events_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/events","assignees_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/assignees{/user}","branches_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/branches{/branch}","tags_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/tags","blobs_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/git/refs{/sha}","trees_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/statuses/{sha}","languages_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/languages","stargazers_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/stargazers","contributors_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/contributors","subscribers_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/subscribers","subscription_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/subscription","commits_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/commits{/sha}","git_commits_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/git/commits{/sha}","comments_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/comments{/number}","issue_comment_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/issues/comments{/number}","contents_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/contents/{+path}","compare_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/merges","archive_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/downloads","issues_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/issues{/number}","pulls_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/pulls{/number}","milestones_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/milestones{/number}","notifications_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/labels{/name}","releases_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/releases{/id}","deployments_url":"https://api.github.com/repos/peter-gribanov/Doctrine-Specification/deployments","created_at":"2017-03-29T12:26:17Z","updated_at":"2017-03-29T12:26:19Z","pushed_at":"2017-04-14T12:48:23Z","git_url":"git://github.com/peter-gribanov/Doctrine-Specification.git","ssh_url":"git@github.com:peter-gribanov/Doctrine-Specification.git","clone_url":"https://github.com/peter-gribanov/Doctrine-Specification.git","svn_url":"https://github.com/peter-gribanov/Doctrine-Specification","homepage":null,"size":288,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"Happyr:master","ref":"master","sha":"df6e71a93b7203fcfb26965367001e28eb59b719","user":{"login":"Happyr","id":3944224,"avatar_url":"https://avatars3.githubusercontent.com/u/3944224?v=3","gravatar_id":"","url":"https://api.github.com/users/Happyr","html_url":"https://github.com/Happyr","followers_url":"https://api.github.com/users/Happyr/followers","following_url":"https://api.github.com/users/Happyr/following{/other_user}","gists_url":"https://api.github.com/users/Happyr/gists{/gist_id}","starred_url":"https://api.github.com/users/Happyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Happyr/subscriptions","organizations_url":"https://api.github.com/users/Happyr/orgs","repos_url":"https://api.github.com/users/Happyr/repos","events_url":"https://api.github.com/users/Happyr/events{/privacy}","received_events_url":"https://api.github.com/users/Happyr/received_events","type":"Organization","site_admin":false},"repo":{"id":21936868,"name":"Doctrine-Specification","full_name":"Happyr/Doctrine-Specification","owner":{"login":"Happyr","id":3944224,"avatar_url":"https://avatars3.githubusercontent.com/u/3944224?v=3","gravatar_id":"","url":"https://api.github.com/users/Happyr","html_url":"https://github.com/Happyr","followers_url":"https://api.github.com/users/Happyr/followers","following_url":"https://api.github.com/users/Happyr/following{/other_user}","gists_url":"https://api.github.com/users/Happyr/gists{/gist_id}","starred_url":"https://api.github.com/users/Happyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Happyr/subscriptions","organizations_url":"https://api.github.com/users/Happyr/orgs","repos_url":"https://api.github.com/users/Happyr/repos","events_url":"https://api.github.com/users/Happyr/events{/privacy}","received_events_url":"https://api.github.com/users/Happyr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Happyr/Doctrine-Specification","description":"This library gives you a new way for writing queries. Using the Specification pattern you will get small Specification classes that are highly reusable.","fork":false,"url":"https://api.github.com/repos/Happyr/Doctrine-Specification","forks_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/forks","keys_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/teams","hooks_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/hooks","issue_events_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues/events{/number}","events_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/events","assignees_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/assignees{/user}","branches_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/branches{/branch}","tags_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/tags","blobs_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/git/refs{/sha}","trees_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/statuses/{sha}","languages_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/languages","stargazers_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/stargazers","contributors_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/contributors","subscribers_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/subscribers","subscription_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/subscription","commits_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/commits{/sha}","git_commits_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/git/commits{/sha}","comments_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/comments{/number}","issue_comment_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues/comments{/number}","contents_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/contents/{+path}","compare_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/merges","archive_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/downloads","issues_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues{/number}","pulls_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls{/number}","milestones_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/milestones{/number}","notifications_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/labels{/name}","releases_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/releases{/id}","deployments_url":"https://api.github.com/repos/Happyr/Doctrine-Specification/deployments","created_at":"2014-07-17T09:49:21Z","updated_at":"2017-04-13T12:09:56Z","pushed_at":"2017-04-14T12:44:17Z","git_url":"git://github.com/Happyr/Doctrine-Specification.git","ssh_url":"git@github.com:Happyr/Doctrine-Specification.git","clone_url":"https://github.com/Happyr/Doctrine-Specification.git","svn_url":"https://github.com/Happyr/Doctrine-Specification","homepage":null,"size":244,"stargazers_count":146,"watchers_count":146,"language":"PHP","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":24,"forks":23,"open_issues":24,"watchers":146,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146"},"html":{"href":"https://github.com/Happyr/Doctrine-Specification/pull/146"},"issue":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues/146"},"comments":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/issues/146/comments"},"review_comments":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146/comments"},"review_comment":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/pulls/146/commits"},"statuses":{"href":"https://api.github.com/repos/Happyr/Doctrine-Specification/statuses/0e5b87781498fefffd1618c2e6cf2dfb796c6732"}}}}
{"actor":{"display_login":"Nyholm"}}