{"action":"created","comment":{"url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/comments/31383451","id":31383451,"diff_hunk":"@@ -47,21 +68,59 @@ public CounterController(IMongoDBStorage mongoDbStorage)\n \t\t[Authorize(Roles = \"buildserver\")]\r\n \t\tpublic async Task<long> Bumping([FromUri] string revisionName)\r\n \t\t{\r\n+\t\t\t// попробуем обновить документ\r\n+\t\t\tvar result = await FindOneAndUpdateRevisionModelAsync(revisionName);\r\n+\t\t\tif (result != null)\r\n+\t\t\t\treturn result.CurrentNumber;\r\n+\r\n+\t\t\tvar insertFailed = false;\r\n+\t\t\t// если не получилось, значит документ еще не был создан\r\n+\t\t\t// создадим его с начальным значением 0\r\n+\t\t\ttry\r\n+\t\t\t{\r\n+\t\t\t\tawait _mongoDbStorage.Revisions\r\n+\t\t\t\t\t.InsertOneAsync(new RevisionModel\r\n+\t\t\t\t\t{\r\n+\t\t\t\t\t\tId = revisionName,\r\n+\t\t\t\t\t\tCurrentNumber = 0,\r\n+\t\t\t\t\t\tCreated = DateTime.UtcNow\r\n+\t\t\t\t\t});\r\n+\t\t\t\treturn 0;\r\n+\t\t\t}\r\n+\t\t\tcatch (MongoDuplicateKeyException)\r\n+\t\t\t{\r\n+\t\t\t\t// если при вставке произошла ошибка значит мы не успели и запись там уже есть\r\n+\t\t\t\t// и теперь попытка обновления должна пройти без ошибок\r\n+\t\t\t\tinsertFailed = true;\r\n+\t\t\t}\r\n+\r\n+\t\t\tif (insertFailed)\r","path":"BuildRevisionCounter/Controllers/CounterController.cs","position":72,"original_position":72,"commit_id":"66261c6c79f7a7457b477119110756ec8830a65a","original_commit_id":"2dfcb496688a7867208708d282c6a04bc7f532b3","user":{"login":"solovyevsa","id":12154149,"avatar_url":"https://avatars.githubusercontent.com/u/12154149?v=3","gravatar_id":"","url":"https://api.github.com/users/solovyevsa","html_url":"https://github.com/solovyevsa","followers_url":"https://api.github.com/users/solovyevsa/followers","following_url":"https://api.github.com/users/solovyevsa/following{/other_user}","gists_url":"https://api.github.com/users/solovyevsa/gists{/gist_id}","starred_url":"https://api.github.com/users/solovyevsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solovyevsa/subscriptions","organizations_url":"https://api.github.com/users/solovyevsa/orgs","repos_url":"https://api.github.com/users/solovyevsa/repos","events_url":"https://api.github.com/users/solovyevsa/events{/privacy}","received_events_url":"https://api.github.com/users/solovyevsa/received_events","type":"User","site_admin":false},"body":"Насчет выхода из метода - тут согласен. Но я посчитал, что повторная вставка нам нужна только когда <code>MongoDuplicateKeyException</code> брошено, а все остальные случаи нас не интересуют. ","created_at":"2015-05-30T19:04:10Z","updated_at":"2015-05-30T19:04:10Z","html_url":"https://github.com/ExM/BuildRevisionCounter/pull/24#discussion_r31383451","pull_request_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/comments/31383451"},"html":{"href":"https://github.com/ExM/BuildRevisionCounter/pull/24#discussion_r31383451"},"pull_request":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24","id":35730695,"html_url":"https://github.com/ExM/BuildRevisionCounter/pull/24","diff_url":"https://github.com/ExM/BuildRevisionCounter/pull/24.diff","patch_url":"https://github.com/ExM/BuildRevisionCounter/pull/24.patch","issue_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues/24","number":24,"state":"open","locked":false,"title":"Сделано #15 Реализовать интеграционное тестирование методов Web Api","user":{"login":"solovyevsa","id":12154149,"avatar_url":"https://avatars.githubusercontent.com/u/12154149?v=3","gravatar_id":"","url":"https://api.github.com/users/solovyevsa","html_url":"https://github.com/solovyevsa","followers_url":"https://api.github.com/users/solovyevsa/followers","following_url":"https://api.github.com/users/solovyevsa/following{/other_user}","gists_url":"https://api.github.com/users/solovyevsa/gists{/gist_id}","starred_url":"https://api.github.com/users/solovyevsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solovyevsa/subscriptions","organizations_url":"https://api.github.com/users/solovyevsa/orgs","repos_url":"https://api.github.com/users/solovyevsa/repos","events_url":"https://api.github.com/users/solovyevsa/events{/privacy}","received_events_url":"https://api.github.com/users/solovyevsa/received_events","type":"User","site_admin":false},"body":"1. Добавлена возможность интеграционного тестирования методов Web Api - Fixes #15 \r\n2. Добавлены интеграционные тесты\r\n3. Исправлено поведение при создании нового счетчика - Fixes #5 - в данном случае фикс взял у AleXKarasev. В его версии уже исправлено поведение метода Bumping. Без этого исправления интеграционные тесты падают.\r\n4. Исправлен тест контроллера для проверки нового поведения","created_at":"2015-05-19T13:37:23Z","updated_at":"2015-05-30T19:04:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96481a38a5aa1182260e08d2edba0a61b863cd7e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24/commits","review_comments_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24/comments","review_comment_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues/24/comments","statuses_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/statuses/66261c6c79f7a7457b477119110756ec8830a65a","head":{"label":"solovyevsa:master","ref":"master","sha":"66261c6c79f7a7457b477119110756ec8830a65a","user":{"login":"solovyevsa","id":12154149,"avatar_url":"https://avatars.githubusercontent.com/u/12154149?v=3","gravatar_id":"","url":"https://api.github.com/users/solovyevsa","html_url":"https://github.com/solovyevsa","followers_url":"https://api.github.com/users/solovyevsa/followers","following_url":"https://api.github.com/users/solovyevsa/following{/other_user}","gists_url":"https://api.github.com/users/solovyevsa/gists{/gist_id}","starred_url":"https://api.github.com/users/solovyevsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solovyevsa/subscriptions","organizations_url":"https://api.github.com/users/solovyevsa/orgs","repos_url":"https://api.github.com/users/solovyevsa/repos","events_url":"https://api.github.com/users/solovyevsa/events{/privacy}","received_events_url":"https://api.github.com/users/solovyevsa/received_events","type":"User","site_admin":false},"repo":{"id":35777013,"name":"BuildRevisionCounter","full_name":"solovyevsa/BuildRevisionCounter","owner":{"login":"solovyevsa","id":12154149,"avatar_url":"https://avatars.githubusercontent.com/u/12154149?v=3","gravatar_id":"","url":"https://api.github.com/users/solovyevsa","html_url":"https://github.com/solovyevsa","followers_url":"https://api.github.com/users/solovyevsa/followers","following_url":"https://api.github.com/users/solovyevsa/following{/other_user}","gists_url":"https://api.github.com/users/solovyevsa/gists{/gist_id}","starred_url":"https://api.github.com/users/solovyevsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solovyevsa/subscriptions","organizations_url":"https://api.github.com/users/solovyevsa/orgs","repos_url":"https://api.github.com/users/solovyevsa/repos","events_url":"https://api.github.com/users/solovyevsa/events{/privacy}","received_events_url":"https://api.github.com/users/solovyevsa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/solovyevsa/BuildRevisionCounter","description":"Обучающий проект: веб-сервер для генерации номеров ревизий для непрерывной интеграции.","fork":true,"url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter","forks_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/forks","keys_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/teams","hooks_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/hooks","issue_events_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/issues/events{/number}","events_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/events","assignees_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/assignees{/user}","branches_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/branches{/branch}","tags_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/tags","blobs_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/git/refs{/sha}","trees_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/statuses/{sha}","languages_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/languages","stargazers_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/stargazers","contributors_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/contributors","subscribers_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/subscribers","subscription_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/subscription","commits_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/commits{/sha}","git_commits_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/git/commits{/sha}","comments_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/comments{/number}","issue_comment_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/issues/comments{/number}","contents_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/contents/{+path}","compare_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/merges","archive_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/downloads","issues_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/issues{/number}","pulls_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/pulls{/number}","milestones_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/milestones{/number}","notifications_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/labels{/name}","releases_url":"https://api.github.com/repos/solovyevsa/BuildRevisionCounter/releases{/id}","created_at":"2015-05-17T18:14:35Z","updated_at":"2015-05-17T18:14:35Z","pushed_at":"2015-05-30T13:30:57Z","git_url":"git://github.com/solovyevsa/BuildRevisionCounter.git","ssh_url":"git@github.com:solovyevsa/BuildRevisionCounter.git","clone_url":"https://github.com/solovyevsa/BuildRevisionCounter.git","svn_url":"https://github.com/solovyevsa/BuildRevisionCounter","homepage":null,"size":138,"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":"master"}},"base":{"label":"ExM:master","ref":"master","sha":"c525cac2c5bad624e1fb9f60d2dfe84dfb066a4f","user":{"login":"ExM","id":485331,"avatar_url":"https://avatars.githubusercontent.com/u/485331?v=3","gravatar_id":"","url":"https://api.github.com/users/ExM","html_url":"https://github.com/ExM","followers_url":"https://api.github.com/users/ExM/followers","following_url":"https://api.github.com/users/ExM/following{/other_user}","gists_url":"https://api.github.com/users/ExM/gists{/gist_id}","starred_url":"https://api.github.com/users/ExM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ExM/subscriptions","organizations_url":"https://api.github.com/users/ExM/orgs","repos_url":"https://api.github.com/users/ExM/repos","events_url":"https://api.github.com/users/ExM/events{/privacy}","received_events_url":"https://api.github.com/users/ExM/received_events","type":"User","site_admin":false},"repo":{"id":30503597,"name":"BuildRevisionCounter","full_name":"ExM/BuildRevisionCounter","owner":{"login":"ExM","id":485331,"avatar_url":"https://avatars.githubusercontent.com/u/485331?v=3","gravatar_id":"","url":"https://api.github.com/users/ExM","html_url":"https://github.com/ExM","followers_url":"https://api.github.com/users/ExM/followers","following_url":"https://api.github.com/users/ExM/following{/other_user}","gists_url":"https://api.github.com/users/ExM/gists{/gist_id}","starred_url":"https://api.github.com/users/ExM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ExM/subscriptions","organizations_url":"https://api.github.com/users/ExM/orgs","repos_url":"https://api.github.com/users/ExM/repos","events_url":"https://api.github.com/users/ExM/events{/privacy}","received_events_url":"https://api.github.com/users/ExM/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ExM/BuildRevisionCounter","description":"Обучающий проект: веб-сервер для генерации номеров ревизий для непрерывной интеграции.","fork":false,"url":"https://api.github.com/repos/ExM/BuildRevisionCounter","forks_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/forks","keys_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/teams","hooks_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/hooks","issue_events_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues/events{/number}","events_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/events","assignees_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/assignees{/user}","branches_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/branches{/branch}","tags_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/tags","blobs_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/git/refs{/sha}","trees_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/statuses/{sha}","languages_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/languages","stargazers_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/stargazers","contributors_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/contributors","subscribers_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/subscribers","subscription_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/subscription","commits_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/commits{/sha}","git_commits_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/git/commits{/sha}","comments_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/comments{/number}","issue_comment_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues/comments{/number}","contents_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/contents/{+path}","compare_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/merges","archive_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/downloads","issues_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues{/number}","pulls_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls{/number}","milestones_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/milestones{/number}","notifications_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/labels{/name}","releases_url":"https://api.github.com/repos/ExM/BuildRevisionCounter/releases{/id}","created_at":"2015-02-08T19:55:56Z","updated_at":"2015-05-07T20:25:16Z","pushed_at":"2015-05-30T13:30:58Z","git_url":"git://github.com/ExM/BuildRevisionCounter.git","ssh_url":"git@github.com:ExM/BuildRevisionCounter.git","clone_url":"https://github.com/ExM/BuildRevisionCounter.git","svn_url":"https://github.com/ExM/BuildRevisionCounter","homepage":null,"size":917,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":10,"forks":12,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24"},"html":{"href":"https://github.com/ExM/BuildRevisionCounter/pull/24"},"issue":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues/24"},"comments":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/ExM/BuildRevisionCounter/statuses/66261c6c79f7a7457b477119110756ec8830a65a"}}}}