{"action":"created","comment":{"url":"https://api.github.com/repos/CanalTP/navitia/pulls/comments/45584412","id":45584412,"diff_hunk":"@@ -115,24 +116,41 @@ struct apply_impacts_visitor : public boost::static_visitor<> {\n     }\n };\n \n-static type::ValidityPattern compute_vp(const std::vector<boost::posix_time::time_period>& periods,\n+// Computes the vp corresponding to the days where base vj's are disrupted\n+static type::ValidityPattern compute_base_disrupted_vp(\n+        const std::vector<boost::posix_time::time_period>& disrupted_vj_periods,\n         const boost::gregorian::date_period& production_period) {\n     type::ValidityPattern vp{production_period.begin()}; // bitset are all initialised to 0\n-    for (const auto& period: periods){\n-        // we may impact vj's passed midnight\n-        bg::day_iterator titr(period.begin().date());\n-        for (; titr <= period.end().date(); ++titr) {\n-            if (! production_period.contains(*titr)) { continue; }\n-            auto day = (*titr - production_period.begin()).days();\n-            vp.add(day);\n-            // Why break here?\n-            // There'll be a problem with VJ passes midnight.\n-            // Ex:\n-            // We'd like to delay a train on 1st, Jan which will pass midnight, without 'break',\n-            // the impact will be applied on 1st, Jan AND 2nd, Jan. So the VJ will be de activated on 1st AND 2nd Jan,\n-            // which may not be wanted\n-            break;\n+    for (const auto& period: disrupted_vj_periods) {\n+        auto start_date = period.begin().date();\n+        if (! production_period.contains(start_date)) { continue; }\n+        // we may impact vj's passing midnight but all we care is start date\n+        auto day = (start_date - production_period.begin()).days();\n+        vp.add(day);\n+    }\n+    return vp;\n+}\n+\n+// Computes the vp corresponding to the the new vj (i.e. realtime vj)\n+static type::ValidityPattern compute_new_vp(\n+        const nt::disruption::Impact& impact,\n+        const boost::gregorian::date_period& production_period) {\n+    type::ValidityPattern vp{production_period.begin()}; // bitset are all initialised to 0\n+    for (const auto& period: impact.application_periods) {\n+        auto start_date = period.begin().date();\n+        if (! production_period.contains(start_date)\n+                || impact.aux_info.stop_times.empty()) {\n+            continue;\n         }\n+        // we may impact vj's passing midnight but all we care is start date\n+        auto day = (start_date - production_period.begin()).days();\n+        int day_offset = impact.aux_info.stop_times.front().arrival_time / ndtu::SECONDS_PER_DAY;\n+        // cannot happen as arrival_time is unsigned, but in order to advance vj,\n+        // it should be possible to have first stop_time negative\n+        if (impact.aux_info.stop_times.front().arrival_time < 0) {","path":"source/kraken/apply_disruption.cpp","position":58,"original_position":58,"commit_id":"7d1f3d86fe384fea7c8b5205b9228a1920d111a8","original_commit_id":"cc59e0e06c353e5507a51536d01606ebaad743c1","user":{"login":"TeXitoi","id":5787066,"avatar_url":"https://avatars.githubusercontent.com/u/5787066?v=3","gravatar_id":"","url":"https://api.github.com/users/TeXitoi","html_url":"https://github.com/TeXitoi","followers_url":"https://api.github.com/users/TeXitoi/followers","following_url":"https://api.github.com/users/TeXitoi/following{/other_user}","gists_url":"https://api.github.com/users/TeXitoi/gists{/gist_id}","starred_url":"https://api.github.com/users/TeXitoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeXitoi/subscriptions","organizations_url":"https://api.github.com/users/TeXitoi/orgs","repos_url":"https://api.github.com/users/TeXitoi/repos","events_url":"https://api.github.com/users/TeXitoi/events{/privacy}","received_events_url":"https://api.github.com/users/TeXitoi/received_events","type":"User","site_admin":false},"body":"I think it's checked in creation of the impact from the trip_update (or it should be). Thus when we want to support it, we'll have to change that.","created_at":"2015-11-23T09:39:48Z","updated_at":"2015-11-23T09:39:48Z","html_url":"https://github.com/CanalTP/navitia/pull/1291#discussion_r45584412","pull_request_url":"https://api.github.com/repos/CanalTP/navitia/pulls/1291","_links":{"self":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/comments/45584412"},"html":{"href":"https://github.com/CanalTP/navitia/pull/1291#discussion_r45584412"},"pull_request":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/1291"}}},"pull_request":{"url":"https://api.github.com/repos/CanalTP/navitia/pulls/1291","id":51381006,"html_url":"https://github.com/CanalTP/navitia/pull/1291","diff_url":"https://github.com/CanalTP/navitia/pull/1291.diff","patch_url":"https://github.com/CanalTP/navitia/pull/1291.patch","issue_url":"https://api.github.com/repos/CanalTP/navitia/issues/1291","number":1291,"state":"open","locked":false,"title":"RT: Disruption pass midnight (no cancel)","user":{"login":"pbougue","id":12812530,"avatar_url":"https://avatars.githubusercontent.com/u/12812530?v=3","gravatar_id":"","url":"https://api.github.com/users/pbougue","html_url":"https://github.com/pbougue","followers_url":"https://api.github.com/users/pbougue/followers","following_url":"https://api.github.com/users/pbougue/following{/other_user}","gists_url":"https://api.github.com/users/pbougue/gists{/gist_id}","starred_url":"https://api.github.com/users/pbougue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbougue/subscriptions","organizations_url":"https://api.github.com/users/pbougue/orgs","repos_url":"https://api.github.com/users/pbougue/repos","events_url":"https://api.github.com/users/pbougue/events{/privacy}","received_events_url":"https://api.github.com/users/pbougue/received_events","type":"User","site_admin":false},"body":"First PR + tests\r\nNot managing disruption cancellation","created_at":"2015-11-20T16:59:08Z","updated_at":"2015-11-23T09:39:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ab77cc0a6af4683382e3d2e408fff9d633549756","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CanalTP/navitia/pulls/1291/commits","review_comments_url":"https://api.github.com/repos/CanalTP/navitia/pulls/1291/comments","review_comment_url":"https://api.github.com/repos/CanalTP/navitia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CanalTP/navitia/issues/1291/comments","statuses_url":"https://api.github.com/repos/CanalTP/navitia/statuses/7d1f3d86fe384fea7c8b5205b9228a1920d111a8","head":{"label":"pbougue:disruption_pass_midnight","ref":"disruption_pass_midnight","sha":"7d1f3d86fe384fea7c8b5205b9228a1920d111a8","user":{"login":"pbougue","id":12812530,"avatar_url":"https://avatars.githubusercontent.com/u/12812530?v=3","gravatar_id":"","url":"https://api.github.com/users/pbougue","html_url":"https://github.com/pbougue","followers_url":"https://api.github.com/users/pbougue/followers","following_url":"https://api.github.com/users/pbougue/following{/other_user}","gists_url":"https://api.github.com/users/pbougue/gists{/gist_id}","starred_url":"https://api.github.com/users/pbougue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbougue/subscriptions","organizations_url":"https://api.github.com/users/pbougue/orgs","repos_url":"https://api.github.com/users/pbougue/repos","events_url":"https://api.github.com/users/pbougue/events{/privacy}","received_events_url":"https://api.github.com/users/pbougue/received_events","type":"User","site_admin":false},"repo":{"id":37126861,"name":"navitia","full_name":"pbougue/navitia","owner":{"login":"pbougue","id":12812530,"avatar_url":"https://avatars.githubusercontent.com/u/12812530?v=3","gravatar_id":"","url":"https://api.github.com/users/pbougue","html_url":"https://github.com/pbougue","followers_url":"https://api.github.com/users/pbougue/followers","following_url":"https://api.github.com/users/pbougue/following{/other_user}","gists_url":"https://api.github.com/users/pbougue/gists{/gist_id}","starred_url":"https://api.github.com/users/pbougue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbougue/subscriptions","organizations_url":"https://api.github.com/users/pbougue/orgs","repos_url":"https://api.github.com/users/pbougue/repos","events_url":"https://api.github.com/users/pbougue/events{/privacy}","received_events_url":"https://api.github.com/users/pbougue/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pbougue/navitia","description":"The REST API to build cool stuff with public transport","fork":true,"url":"https://api.github.com/repos/pbougue/navitia","forks_url":"https://api.github.com/repos/pbougue/navitia/forks","keys_url":"https://api.github.com/repos/pbougue/navitia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pbougue/navitia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pbougue/navitia/teams","hooks_url":"https://api.github.com/repos/pbougue/navitia/hooks","issue_events_url":"https://api.github.com/repos/pbougue/navitia/issues/events{/number}","events_url":"https://api.github.com/repos/pbougue/navitia/events","assignees_url":"https://api.github.com/repos/pbougue/navitia/assignees{/user}","branches_url":"https://api.github.com/repos/pbougue/navitia/branches{/branch}","tags_url":"https://api.github.com/repos/pbougue/navitia/tags","blobs_url":"https://api.github.com/repos/pbougue/navitia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pbougue/navitia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pbougue/navitia/git/refs{/sha}","trees_url":"https://api.github.com/repos/pbougue/navitia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pbougue/navitia/statuses/{sha}","languages_url":"https://api.github.com/repos/pbougue/navitia/languages","stargazers_url":"https://api.github.com/repos/pbougue/navitia/stargazers","contributors_url":"https://api.github.com/repos/pbougue/navitia/contributors","subscribers_url":"https://api.github.com/repos/pbougue/navitia/subscribers","subscription_url":"https://api.github.com/repos/pbougue/navitia/subscription","commits_url":"https://api.github.com/repos/pbougue/navitia/commits{/sha}","git_commits_url":"https://api.github.com/repos/pbougue/navitia/git/commits{/sha}","comments_url":"https://api.github.com/repos/pbougue/navitia/comments{/number}","issue_comment_url":"https://api.github.com/repos/pbougue/navitia/issues/comments{/number}","contents_url":"https://api.github.com/repos/pbougue/navitia/contents/{+path}","compare_url":"https://api.github.com/repos/pbougue/navitia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pbougue/navitia/merges","archive_url":"https://api.github.com/repos/pbougue/navitia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pbougue/navitia/downloads","issues_url":"https://api.github.com/repos/pbougue/navitia/issues{/number}","pulls_url":"https://api.github.com/repos/pbougue/navitia/pulls{/number}","milestones_url":"https://api.github.com/repos/pbougue/navitia/milestones{/number}","notifications_url":"https://api.github.com/repos/pbougue/navitia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pbougue/navitia/labels{/name}","releases_url":"https://api.github.com/repos/pbougue/navitia/releases{/id}","created_at":"2015-06-09T10:57:48Z","updated_at":"2015-06-09T10:57:50Z","pushed_at":"2015-11-20T17:34:28Z","git_url":"git://github.com/pbougue/navitia.git","ssh_url":"git@github.com:pbougue/navitia.git","clone_url":"https://github.com/pbougue/navitia.git","svn_url":"https://github.com/pbougue/navitia","homepage":"http://www.navitia.io","size":26444,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"dev"}},"base":{"label":"CanalTP:dev","ref":"dev","sha":"ae56230d87b5a9408234c226cae3db7ddba011a8","user":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?v=3","gravatar_id":"","url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"repo":{"id":10797333,"name":"navitia","full_name":"CanalTP/navitia","owner":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?v=3","gravatar_id":"","url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CanalTP/navitia","description":"The REST API to build cool stuff with public transport","fork":false,"url":"https://api.github.com/repos/CanalTP/navitia","forks_url":"https://api.github.com/repos/CanalTP/navitia/forks","keys_url":"https://api.github.com/repos/CanalTP/navitia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanalTP/navitia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanalTP/navitia/teams","hooks_url":"https://api.github.com/repos/CanalTP/navitia/hooks","issue_events_url":"https://api.github.com/repos/CanalTP/navitia/issues/events{/number}","events_url":"https://api.github.com/repos/CanalTP/navitia/events","assignees_url":"https://api.github.com/repos/CanalTP/navitia/assignees{/user}","branches_url":"https://api.github.com/repos/CanalTP/navitia/branches{/branch}","tags_url":"https://api.github.com/repos/CanalTP/navitia/tags","blobs_url":"https://api.github.com/repos/CanalTP/navitia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanalTP/navitia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanalTP/navitia/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanalTP/navitia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanalTP/navitia/statuses/{sha}","languages_url":"https://api.github.com/repos/CanalTP/navitia/languages","stargazers_url":"https://api.github.com/repos/CanalTP/navitia/stargazers","contributors_url":"https://api.github.com/repos/CanalTP/navitia/contributors","subscribers_url":"https://api.github.com/repos/CanalTP/navitia/subscribers","subscription_url":"https://api.github.com/repos/CanalTP/navitia/subscription","commits_url":"https://api.github.com/repos/CanalTP/navitia/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanalTP/navitia/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanalTP/navitia/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanalTP/navitia/issues/comments{/number}","contents_url":"https://api.github.com/repos/CanalTP/navitia/contents/{+path}","compare_url":"https://api.github.com/repos/CanalTP/navitia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanalTP/navitia/merges","archive_url":"https://api.github.com/repos/CanalTP/navitia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanalTP/navitia/downloads","issues_url":"https://api.github.com/repos/CanalTP/navitia/issues{/number}","pulls_url":"https://api.github.com/repos/CanalTP/navitia/pulls{/number}","milestones_url":"https://api.github.com/repos/CanalTP/navitia/milestones{/number}","notifications_url":"https://api.github.com/repos/CanalTP/navitia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanalTP/navitia/labels{/name}","releases_url":"https://api.github.com/repos/CanalTP/navitia/releases{/id}","created_at":"2013-06-19T15:34:30Z","updated_at":"2015-10-11T20:06:49Z","pushed_at":"2015-11-23T09:19:00Z","git_url":"git://github.com/CanalTP/navitia.git","ssh_url":"git@github.com:CanalTP/navitia.git","clone_url":"https://github.com/CanalTP/navitia.git","svn_url":"https://github.com/CanalTP/navitia","homepage":"http://www.navitia.io","size":27326,"stargazers_count":128,"watchers_count":128,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":18,"forks":45,"open_issues":18,"watchers":128,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/1291"},"html":{"href":"https://github.com/CanalTP/navitia/pull/1291"},"issue":{"href":"https://api.github.com/repos/CanalTP/navitia/issues/1291"},"comments":{"href":"https://api.github.com/repos/CanalTP/navitia/issues/1291/comments"},"review_comments":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/1291/comments"},"review_comment":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/1291/commits"},"statuses":{"href":"https://api.github.com/repos/CanalTP/navitia/statuses/7d1f3d86fe384fea7c8b5205b9228a1920d111a8"}}}}