{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/comments/230130253","pull_request_review_id":170797545,"id":230130253,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDEzMDI1Mw==","diff_hunk":"@@ -198,36 +203,47 @@ public ContentValues nextValues(Cursor cursor) {\n      * new one can fit. If the log is larger than the max table size, database will be cleared and\n      * the log is not inserted.\n      *\n-     * @param values The entry to be stored.\n+     * @param values         The entry to be stored.\n+     * @param priorityColumn When storage full and deleting data, use this column to determine which entries to delete first.\n      * @return If a log was inserted, the database identifier. Otherwise -1.\n      */\n     @SuppressWarnings(\"TryFinallyCanBeTryWithResources\")\n-    public long put(@NonNull ContentValues values) {\n+    public long put(@NonNull ContentValues values, @NonNull String priorityColumn) {\n+        Long id = null;\n+        Cursor cursor = null;\n         try {\n-            while (true) {\n+            while (id == null) {\n                 try {\n \n                     /* Insert data. */\n-                    return getDatabase().insertOrThrow(mTable, null, values);\n+                    id = getDatabase().insertOrThrow(mTable, null, values);\n                 } catch (SQLiteFullException e) {\n \n                     /* Delete the oldest log. */\n-                    Cursor cursor = getCursor(SQLiteUtils.newSQLiteQueryBuilder(), null, true);\n-                    try {\n-                        if (cursor.moveToNext()) {\n-                            delete(cursor.getLong(0));\n-                        } else {\n-                            return -1;\n-                        }\n-                    } finally {\n-                        cursor.close();\n+                    if (cursor == null) {\n+                        String priority = values.getAsString(priorityColumn);\n+                        SQLiteQueryBuilder queryBuilder = SQLiteUtils.newSQLiteQueryBuilder();\n+                        queryBuilder.appendWhere(priorityColumn + \" <= ?\");\n+                        cursor = getCursor(queryBuilder, SELECT_PRIMARY_KEY, new String[]{priority}, priorityColumn);","path":"sdk/appcenter/src/main/java/com/microsoft/appcenter/utils/storage/DatabaseManager.java","position":50,"original_position":50,"commit_id":"9a5c0b275942784e0c82091124ce886cde3125ec","original_commit_id":"9a5c0b275942784e0c82091124ce886cde3125ec","user":{"login":"jaelim-ms","id":19935783,"node_id":"MDQ6VXNlcjE5OTM1Nzgz","avatar_url":"https://avatars2.githubusercontent.com/u/19935783?v=4","gravatar_id":"","url":"https://api.github.com/users/jaelim-ms","html_url":"https://github.com/jaelim-ms","followers_url":"https://api.github.com/users/jaelim-ms/followers","following_url":"https://api.github.com/users/jaelim-ms/following{/other_user}","gists_url":"https://api.github.com/users/jaelim-ms/gists{/gist_id}","starred_url":"https://api.github.com/users/jaelim-ms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaelim-ms/subscriptions","organizations_url":"https://api.github.com/users/jaelim-ms/orgs","repos_url":"https://api.github.com/users/jaelim-ms/repos","events_url":"https://api.github.com/users/jaelim-ms/events{/privacy}","received_events_url":"https://api.github.com/users/jaelim-ms/received_events","type":"User","site_admin":false},"body":"It would be better to explicitly specify sort order for primary key. `priority` then `oid` ","created_at":"2018-11-01T17:36:32Z","updated_at":"2018-11-01T17:44:39Z","html_url":"https://github.com/Microsoft/AppCenter-SDK-Android/pull/858#discussion_r230130253","pull_request_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/comments/230130253"},"html":{"href":"https://github.com/Microsoft/AppCenter-SDK-Android/pull/858#discussion_r230130253"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858","id":227135734,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3MTM1NzM0","html_url":"https://github.com/Microsoft/AppCenter-SDK-Android/pull/858","diff_url":"https://github.com/Microsoft/AppCenter-SDK-Android/pull/858.diff","patch_url":"https://github.com/Microsoft/AppCenter-SDK-Android/pull/858.patch","issue_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/858","number":858,"state":"open","locked":false,"title":"Purge critical logs last","user":{"login":"guperrot","id":623672,"node_id":"MDQ6VXNlcjYyMzY3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/623672?v=4","gravatar_id":"","url":"https://api.github.com/users/guperrot","html_url":"https://github.com/guperrot","followers_url":"https://api.github.com/users/guperrot/followers","following_url":"https://api.github.com/users/guperrot/following{/other_user}","gists_url":"https://api.github.com/users/guperrot/gists{/gist_id}","starred_url":"https://api.github.com/users/guperrot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guperrot/subscriptions","organizations_url":"https://api.github.com/users/guperrot/orgs","repos_url":"https://api.github.com/users/guperrot/repos","events_url":"https://api.github.com/users/guperrot/events{/privacy}","received_events_url":"https://api.github.com/users/guperrot/received_events","type":"User","site_admin":false},"body":"<!-- \r\nThank you for submitting a pull request! Please add some info (if applicable) to give us some context on the PR.\r\n\r\nWe will review the PR as soon as possible, leave feedback, add a tag, etc. and let you know what's going on.\r\n\r\nCheers!\r\n\r\nThe App Center team -->\r\n\r\nPlease have a look at our [guidelines for contributions](https://github.com/Microsoft/AppCenter-SDK-Android/blob/develop/CONTRIBUTING.md) and consider the following before you submit the PR:\r\n\r\n* [ ] Has `CHANGELOG.md` been updated?\r\n* [x] Are tests passing locally?\r\n* [x] Are the files formatted correctly?\r\n* [x] Did you add unit tests?\r\n* [x] Did you test your change with either the sample apps that are included in the repository or with a blank app that uses your change?\r\n\r\n## Description\r\n\r\nImplement persistence flag for purge of the logs.","created_at":"2018-10-31T02:01:27Z","updated_at":"2018-11-01T17:44:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5221f4a406d6acf2f736d54305014e2ad7344752","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858/commits","review_comments_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858/comments","review_comment_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/858/comments","statuses_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/statuses/9a5c0b275942784e0c82091124ce886cde3125ec","head":{"label":"Microsoft:feature/database-purge-priority","ref":"feature/database-purge-priority","sha":"9a5c0b275942784e0c82091124ce886cde3125ec","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":60783603,"node_id":"MDEwOlJlcG9zaXRvcnk2MDc4MzYwMw==","name":"AppCenter-SDK-Android","full_name":"Microsoft/AppCenter-SDK-Android","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/AppCenter-SDK-Android","description":"Development repository for the App Center SDK for Android","fork":false,"url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android","forks_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/forks","keys_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/teams","hooks_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/events","assignees_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/tags","blobs_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/languages","stargazers_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/subscription","commits_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/merges","archive_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/downloads","issues_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/deployments","created_at":"2016-06-09T15:03:59Z","updated_at":"2018-10-31T23:52:24Z","pushed_at":"2018-11-01T16:47:42Z","git_url":"git://github.com/Microsoft/AppCenter-SDK-Android.git","ssh_url":"git@github.com:Microsoft/AppCenter-SDK-Android.git","clone_url":"https://github.com/Microsoft/AppCenter-SDK-Android.git","svn_url":"https://github.com/Microsoft/AppCenter-SDK-Android","homepage":"","size":10099,"stargazers_count":50,"watchers_count":50,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":53,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":53,"open_issues":7,"watchers":50,"default_branch":"develop"}},"base":{"label":"Microsoft:feature/priority","ref":"feature/priority","sha":"0b410a7e0414dfe3ba624a2c15291da8c7be1f30","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":60783603,"node_id":"MDEwOlJlcG9zaXRvcnk2MDc4MzYwMw==","name":"AppCenter-SDK-Android","full_name":"Microsoft/AppCenter-SDK-Android","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/AppCenter-SDK-Android","description":"Development repository for the App Center SDK for Android","fork":false,"url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android","forks_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/forks","keys_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/teams","hooks_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/events","assignees_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/tags","blobs_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/languages","stargazers_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/subscription","commits_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/merges","archive_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/downloads","issues_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/deployments","created_at":"2016-06-09T15:03:59Z","updated_at":"2018-10-31T23:52:24Z","pushed_at":"2018-11-01T16:47:42Z","git_url":"git://github.com/Microsoft/AppCenter-SDK-Android.git","ssh_url":"git@github.com:Microsoft/AppCenter-SDK-Android.git","clone_url":"https://github.com/Microsoft/AppCenter-SDK-Android.git","svn_url":"https://github.com/Microsoft/AppCenter-SDK-Android","homepage":"","size":10099,"stargazers_count":50,"watchers_count":50,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":53,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":53,"open_issues":7,"watchers":50,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858"},"html":{"href":"https://github.com/Microsoft/AppCenter-SDK-Android/pull/858"},"issue":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/858"},"comments":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/issues/858/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/pulls/858/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/AppCenter-SDK-Android/statuses/9a5c0b275942784e0c82091124ce886cde3125ec"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jaelim-ms"}}