{"action":"created","issue":{"url":"https://api.github.com/repos/drone/drone/issues/2230","repository_url":"https://api.github.com/repos/drone/drone","labels_url":"https://api.github.com/repos/drone/drone/issues/2230/labels{/name}","comments_url":"https://api.github.com/repos/drone/drone/issues/2230/comments","events_url":"https://api.github.com/repos/drone/drone/issues/2230/events","html_url":"https://github.com/drone/drone/issues/2230","id":260438100,"number":2230,"title":"optimize repository synchronization process","user":{"login":"bradrydzewski","id":817538,"avatar_url":"https://avatars1.githubusercontent.com/u/817538?v=4","gravatar_id":"","url":"https://api.github.com/users/bradrydzewski","html_url":"https://github.com/bradrydzewski","followers_url":"https://api.github.com/users/bradrydzewski/followers","following_url":"https://api.github.com/users/bradrydzewski/following{/other_user}","gists_url":"https://api.github.com/users/bradrydzewski/gists{/gist_id}","starred_url":"https://api.github.com/users/bradrydzewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradrydzewski/subscriptions","organizations_url":"https://api.github.com/users/bradrydzewski/orgs","repos_url":"https://api.github.com/users/bradrydzewski/repos","events_url":"https://api.github.com/users/bradrydzewski/events{/privacy}","received_events_url":"https://api.github.com/users/bradrydzewski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-25T22:47:38Z","updated_at":"2017-09-25T22:57:59Z","closed_at":null,"author_association":"OWNER","body":"When syncing a large number of repositories it can take many seconds. During this time period additional http requests from the same user could result in duplicate synchronizations. This can be resolved by immediately setting the user synchronization date.\r\n\r\nThe change to the relevant [sections of code](https://github.com/drone/drone/blob/ec6016062bd1d7d702c5edf383eb0728df33dbdd/server/user.go#L69:L83) would roughly look like this:\r\n\r\n```diff\r\n+\t\tuser.Synced = time.Now().Unix()\r\n+\t\tstore.FromContext(c).UpdateUser(user)\r\n\t\tsync := syncer{\r\n\t\t\tremote: remote.FromContext(c),\r\n\t\t\tstore:  store.FromContext(c),\r\n\t\t\tperms:  store.FromContext(c),\r\n\t\t}\r\n\t\tif err := sync.Sync(user); err != nil {\r\n\t\t\tlogrus.Debugf(\"sync error: %s: %s\", user.Login, err)\r\n-\t\t} else {\r\n-\t\t\tlogrus.Debugf(\"sync complete: %s\", user.Login)\r\n-\t\t\tuser.Synced = time.Now().Unix()\r\n-\t\t}\r\n```\r\n\r\nIn addition we should optimize the automatic synchronization process to immediately return the repository list prior to synchronization (this means the list could be slightly stale) and then perform the synchronization async in the background. "},"comment":{"url":"https://api.github.com/repos/drone/drone/issues/comments/332037438","html_url":"https://github.com/drone/drone/issues/2230#issuecomment-332037438","issue_url":"https://api.github.com/repos/drone/drone/issues/2230","id":332037438,"user":{"login":"bradrydzewski","id":817538,"avatar_url":"https://avatars1.githubusercontent.com/u/817538?v=4","gravatar_id":"","url":"https://api.github.com/users/bradrydzewski","html_url":"https://github.com/bradrydzewski","followers_url":"https://api.github.com/users/bradrydzewski/followers","following_url":"https://api.github.com/users/bradrydzewski/following{/other_user}","gists_url":"https://api.github.com/users/bradrydzewski/gists{/gist_id}","starred_url":"https://api.github.com/users/bradrydzewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradrydzewski/subscriptions","organizations_url":"https://api.github.com/users/bradrydzewski/orgs","repos_url":"https://api.github.com/users/bradrydzewski/repos","events_url":"https://api.github.com/users/bradrydzewski/events{/privacy}","received_events_url":"https://api.github.com/users/bradrydzewski/received_events","type":"User","site_admin":false},"created_at":"2017-09-25T22:57:59Z","updated_at":"2017-09-25T22:57:59Z","author_association":"OWNER","body":"the patch to prevent duplicate sync should be easy enough. I am not sure yet how I want to handle the async aspect and UI notification. I need to think through it a bit more, but expect a solution and 0.8.1 tag this week."}}
{"actor":{"display_login":"bradrydzewski"}}