{"action":"created","comment":{"url":"https://api.github.com/repos/medic/cht-core/pulls/comments/349395529","pull_request_review_id":321287418,"id":349395529,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM0OTM5NTUyOQ==","diff_hunk":"@@ -31,6 +45,25 @@ const States = {\n   Failed: 'Failed',\n };\n \n+const getDisplayWindow = (taskEmission) => {\n+  const hasExistingDisplayWindow = taskEmission.startTime || taskEmission.endTime;\n+  if (hasExistingDisplayWindow) {\n+    return {\n+      dueDate: taskEmission.dueDate,\n+      startTime: taskEmission.startTime,\n+      endTime: taskEmission.endTime,\n+    };\n+  }\n+\n+  const dueDate = moment(taskEmission.date);\n+  return {\n+    dueDate: dueDate.valueOf(),\n+    startTime: dueDate.clone().startOf('day').subtract(taskEmission.readyStart || 0, 'days').valueOf(),\n+    endTime: dueDate.clone().startOf('day').add(taskEmission.readyEnd || 0, 'days').add(1, 'day').valueOf() - 1,","path":"shared-libs/rules-engine/src/task-states.js","position":39,"original_position":39,"commit_id":"48b42e320eadc65f2cc159dc6c9800e4fb5492e4","original_commit_id":"48b42e320eadc65f2cc159dc6c9800e4fb5492e4","user":{"login":"kennsippell","id":9014751,"node_id":"MDQ6VXNlcjkwMTQ3NTE=","avatar_url":"https://avatars2.githubusercontent.com/u/9014751?v=4","gravatar_id":"","url":"https://api.github.com/users/kennsippell","html_url":"https://github.com/kennsippell","followers_url":"https://api.github.com/users/kennsippell/followers","following_url":"https://api.github.com/users/kennsippell/following{/other_user}","gists_url":"https://api.github.com/users/kennsippell/gists{/gist_id}","starred_url":"https://api.github.com/users/kennsippell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennsippell/subscriptions","organizations_url":"https://api.github.com/users/kennsippell/orgs","repos_url":"https://api.github.com/users/kennsippell/repos","events_url":"https://api.github.com/users/kennsippell/events{/privacy}","received_events_url":"https://api.github.com/users/kennsippell/received_events","type":"User","site_admin":false},"body":"Moments are not immutable and I believe the `clone` is necessary. https://momentjs.com/docs/#/manipulating/add/\r\n> Mutates the original moment by adding time.","created_at":"2019-11-22T01:16:20Z","updated_at":"2019-11-22T01:16:20Z","html_url":"https://github.com/medic/cht-core/pull/6114#discussion_r349395529","pull_request_url":"https://api.github.com/repos/medic/cht-core/pulls/6114","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/medic/cht-core/pulls/comments/349395529"},"html":{"href":"https://github.com/medic/cht-core/pull/6114#discussion_r349395529"},"pull_request":{"href":"https://api.github.com/repos/medic/cht-core/pulls/6114"}},"in_reply_to_id":349371399},"pull_request":{"url":"https://api.github.com/repos/medic/cht-core/pulls/6114","id":340636800,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQwNjM2ODAw","html_url":"https://github.com/medic/cht-core/pull/6114","diff_url":"https://github.com/medic/cht-core/pull/6114.diff","patch_url":"https://github.com/medic/cht-core/pull/6114.patch","issue_url":"https://api.github.com/repos/medic/cht-core/issues/6114","number":6114,"state":"open","locked":false,"title":"Rules-Engine v2 - Targets Improvements ","user":{"login":"kennsippell","id":9014751,"node_id":"MDQ6VXNlcjkwMTQ3NTE=","avatar_url":"https://avatars2.githubusercontent.com/u/9014751?v=4","gravatar_id":"","url":"https://api.github.com/users/kennsippell","html_url":"https://github.com/kennsippell","followers_url":"https://api.github.com/users/kennsippell/followers","following_url":"https://api.github.com/users/kennsippell/following{/other_user}","gists_url":"https://api.github.com/users/kennsippell/gists{/gist_id}","starred_url":"https://api.github.com/users/kennsippell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennsippell/subscriptions","organizations_url":"https://api.github.com/users/kennsippell/orgs","repos_url":"https://api.github.com/users/kennsippell/repos","events_url":"https://api.github.com/users/kennsippell/events{/privacy}","received_events_url":"https://api.github.com/users/kennsippell/received_events","type":"User","site_admin":false},"body":"# Description\r\n\r\nThis is the \"Targets\" work for the rules-engine v2. To be merged into the `tasks-v2` branch for AT.\r\n\r\n- Stores target emissions in a _local pouchdb doc along with the contact state\r\n- Aggregates the target emissions from the doc into targets\r\n- Writes the aggregated targets into a doc which syncs to the server `target-2019-11-user_id`\r\n- Disabled targets/tasks individually based on permissions\r\n- Implements the isTimely window for tasks (60 days)\r\n- On launch, starts a \"freshness thread\" which ensures all tasks and targets are up to date\r\n- Changes the expected schema with partner code. Instead of a timestamp \"startTime\", we expect \"readyStart\" which is a number of days\r\n- Some cleanup\r\n\r\n#5657 \r\n#5515\r\n\r\n# Code review items\r\n\r\n- Readable: Concise, well named, follows the [style guide](https://github.com/medic/medic-docs/blob/master/development/style-guide.md), documented if necessary.\r\n- Documented: Configuration and user documentation on [medic-docs](https://github.com/medic/medic-docs/)\r\n- Tested: Unit and/or e2e where appropriate\r\n- Internationalised: All user facing text\r\n- Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in Changes.md.\r\n\r\n# License\r\n\r\nThe software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.\r\n","created_at":"2019-11-13T19:50:07Z","updated_at":"2019-11-22T01:16:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"afeca74c4e30c160d853b99a1a7a5ab118c65d46","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/medic/cht-core/pulls/6114/commits","review_comments_url":"https://api.github.com/repos/medic/cht-core/pulls/6114/comments","review_comment_url":"https://api.github.com/repos/medic/cht-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/medic/cht-core/issues/6114/comments","statuses_url":"https://api.github.com/repos/medic/cht-core/statuses/48b42e320eadc65f2cc159dc6c9800e4fb5492e4","head":{"label":"medic:targets-v2","ref":"targets-v2","sha":"48b42e320eadc65f2cc159dc6c9800e4fb5492e4","user":{"login":"medic","id":474424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3NDQyNA==","avatar_url":"https://avatars2.githubusercontent.com/u/474424?v=4","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"repo":{"id":2698821,"node_id":"MDEwOlJlcG9zaXRvcnkyNjk4ODIx","name":"cht-core","full_name":"medic/cht-core","private":false,"owner":{"login":"medic","id":474424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3NDQyNA==","avatar_url":"https://avatars2.githubusercontent.com/u/474424?v=4","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/medic/cht-core","description":"Medic Mobile's Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.","fork":false,"url":"https://api.github.com/repos/medic/cht-core","forks_url":"https://api.github.com/repos/medic/cht-core/forks","keys_url":"https://api.github.com/repos/medic/cht-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/medic/cht-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/medic/cht-core/teams","hooks_url":"https://api.github.com/repos/medic/cht-core/hooks","issue_events_url":"https://api.github.com/repos/medic/cht-core/issues/events{/number}","events_url":"https://api.github.com/repos/medic/cht-core/events","assignees_url":"https://api.github.com/repos/medic/cht-core/assignees{/user}","branches_url":"https://api.github.com/repos/medic/cht-core/branches{/branch}","tags_url":"https://api.github.com/repos/medic/cht-core/tags","blobs_url":"https://api.github.com/repos/medic/cht-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/medic/cht-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/medic/cht-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/medic/cht-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/medic/cht-core/statuses/{sha}","languages_url":"https://api.github.com/repos/medic/cht-core/languages","stargazers_url":"https://api.github.com/repos/medic/cht-core/stargazers","contributors_url":"https://api.github.com/repos/medic/cht-core/contributors","subscribers_url":"https://api.github.com/repos/medic/cht-core/subscribers","subscription_url":"https://api.github.com/repos/medic/cht-core/subscription","commits_url":"https://api.github.com/repos/medic/cht-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/medic/cht-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/medic/cht-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/medic/cht-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/medic/cht-core/contents/{+path}","compare_url":"https://api.github.com/repos/medic/cht-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/medic/cht-core/merges","archive_url":"https://api.github.com/repos/medic/cht-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/medic/cht-core/downloads","issues_url":"https://api.github.com/repos/medic/cht-core/issues{/number}","pulls_url":"https://api.github.com/repos/medic/cht-core/pulls{/number}","milestones_url":"https://api.github.com/repos/medic/cht-core/milestones{/number}","notifications_url":"https://api.github.com/repos/medic/cht-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/medic/cht-core/labels{/name}","releases_url":"https://api.github.com/repos/medic/cht-core/releases{/id}","deployments_url":"https://api.github.com/repos/medic/cht-core/deployments","created_at":"2011-11-02T23:19:55Z","updated_at":"2019-11-21T22:15:06Z","pushed_at":"2019-11-21T22:16:10Z","git_url":"git://github.com/medic/cht-core.git","ssh_url":"git@github.com:medic/cht-core.git","clone_url":"https://github.com/medic/cht-core.git","svn_url":"https://github.com/medic/cht-core","homepage":"http://medicmobile.org/tools","size":72950,"stargazers_count":320,"watchers_count":320,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":98,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":324,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":98,"open_issues":324,"watchers":320,"default_branch":"master"}},"base":{"label":"medic:tasks-v2","ref":"tasks-v2","sha":"ff1142d9b923ac892ec2930b1d0f36271576fd21","user":{"login":"medic","id":474424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3NDQyNA==","avatar_url":"https://avatars2.githubusercontent.com/u/474424?v=4","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"repo":{"id":2698821,"node_id":"MDEwOlJlcG9zaXRvcnkyNjk4ODIx","name":"cht-core","full_name":"medic/cht-core","private":false,"owner":{"login":"medic","id":474424,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3NDQyNA==","avatar_url":"https://avatars2.githubusercontent.com/u/474424?v=4","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/medic/cht-core","description":"Medic Mobile's Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.","fork":false,"url":"https://api.github.com/repos/medic/cht-core","forks_url":"https://api.github.com/repos/medic/cht-core/forks","keys_url":"https://api.github.com/repos/medic/cht-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/medic/cht-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/medic/cht-core/teams","hooks_url":"https://api.github.com/repos/medic/cht-core/hooks","issue_events_url":"https://api.github.com/repos/medic/cht-core/issues/events{/number}","events_url":"https://api.github.com/repos/medic/cht-core/events","assignees_url":"https://api.github.com/repos/medic/cht-core/assignees{/user}","branches_url":"https://api.github.com/repos/medic/cht-core/branches{/branch}","tags_url":"https://api.github.com/repos/medic/cht-core/tags","blobs_url":"https://api.github.com/repos/medic/cht-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/medic/cht-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/medic/cht-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/medic/cht-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/medic/cht-core/statuses/{sha}","languages_url":"https://api.github.com/repos/medic/cht-core/languages","stargazers_url":"https://api.github.com/repos/medic/cht-core/stargazers","contributors_url":"https://api.github.com/repos/medic/cht-core/contributors","subscribers_url":"https://api.github.com/repos/medic/cht-core/subscribers","subscription_url":"https://api.github.com/repos/medic/cht-core/subscription","commits_url":"https://api.github.com/repos/medic/cht-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/medic/cht-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/medic/cht-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/medic/cht-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/medic/cht-core/contents/{+path}","compare_url":"https://api.github.com/repos/medic/cht-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/medic/cht-core/merges","archive_url":"https://api.github.com/repos/medic/cht-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/medic/cht-core/downloads","issues_url":"https://api.github.com/repos/medic/cht-core/issues{/number}","pulls_url":"https://api.github.com/repos/medic/cht-core/pulls{/number}","milestones_url":"https://api.github.com/repos/medic/cht-core/milestones{/number}","notifications_url":"https://api.github.com/repos/medic/cht-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/medic/cht-core/labels{/name}","releases_url":"https://api.github.com/repos/medic/cht-core/releases{/id}","deployments_url":"https://api.github.com/repos/medic/cht-core/deployments","created_at":"2011-11-02T23:19:55Z","updated_at":"2019-11-21T22:15:06Z","pushed_at":"2019-11-21T22:16:10Z","git_url":"git://github.com/medic/cht-core.git","ssh_url":"git@github.com:medic/cht-core.git","clone_url":"https://github.com/medic/cht-core.git","svn_url":"https://github.com/medic/cht-core","homepage":"http://medicmobile.org/tools","size":72950,"stargazers_count":320,"watchers_count":320,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":98,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":324,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":98,"open_issues":324,"watchers":320,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/medic/cht-core/pulls/6114"},"html":{"href":"https://github.com/medic/cht-core/pull/6114"},"issue":{"href":"https://api.github.com/repos/medic/cht-core/issues/6114"},"comments":{"href":"https://api.github.com/repos/medic/cht-core/issues/6114/comments"},"review_comments":{"href":"https://api.github.com/repos/medic/cht-core/pulls/6114/comments"},"review_comment":{"href":"https://api.github.com/repos/medic/cht-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/medic/cht-core/pulls/6114/commits"},"statuses":{"href":"https://api.github.com/repos/medic/cht-core/statuses/48b42e320eadc65f2cc159dc6c9800e4fb5492e4"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kennsippell"}}