{"action":"created","issue":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/issues/15","repository_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android","labels_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/issues/15/comments","events_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/issues/15/events","html_url":"https://github.com/wordpress-mobile/WordPress-Stores-Android/pull/15","id":140228639,"number":15,"title":"SiteStore implementation","user":{"login":"aforcier","id":9613966,"avatar_url":"https://avatars.githubusercontent.com/u/9613966?v=3","gravatar_id":"","url":"https://api.github.com/users/aforcier","html_url":"https://github.com/aforcier","followers_url":"https://api.github.com/users/aforcier/followers","following_url":"https://api.github.com/users/aforcier/following{/other_user}","gists_url":"https://api.github.com/users/aforcier/gists{/gist_id}","starred_url":"https://api.github.com/users/aforcier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aforcier/subscriptions","organizations_url":"https://api.github.com/users/aforcier/orgs","repos_url":"https://api.github.com/users/aforcier/repos","events_url":"https://api.github.com/users/aforcier/events{/privacy}","received_events_url":"https://api.github.com/users/aforcier/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/labels/Not%20Ready%20for%20Review","name":"Not Ready for Review","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-11T16:29:46Z","updated_at":"2016-03-12T17:09:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/pulls/15","html_url":"https://github.com/wordpress-mobile/WordPress-Stores-Android/pull/15","diff_url":"https://github.com/wordpress-mobile/WordPress-Stores-Android/pull/15.diff","patch_url":"https://github.com/wordpress-mobile/WordPress-Stores-Android/pull/15.patch"},"body":"Fills out SiteStore, mirroring all the methods for the `accounts` table of `WordPressDB`.\r\n\r\nNot ready for merge yet.\r\n\r\nRemaining:\r\n- [ ] The `getBlogsBy(...)` methods of `WordPressDB` are too generic, find all its usages and provide less generic methods for each so we can drop `getBlogsBy(...)` (or at least not have to expose it anymore)\r\n- [ ] Add unit tests and regression tests\r\n- [ ] Offload the SQL methods to `SiteSqlUtils`\r\n\r\n<h4>Implementation/Import details:</h4>\r\n<h5>Methods implemented:</h5>\r\n* `addBlog(Blog blog)` > already implemented as `SiteSqlUtils.insertOrUpdateSite(site)`\r\n* `saveBlog(Blog blog)` > already implemented as `SiteSqlUtils.insertOrUpdateSite(site)`\r\n\r\n* `instantiateBlogByLocalId(int localId)` > `getSiteByLocalId(int id)`\r\n\r\n* `getNumBlogs()` > `getSitesCount()`\r\n* `hasAnyJetpackBlogs()` > `hasJetpackSite()`\r\n* `getNumDotComBlogs()` > `getDotComSitesCount()`\r\n* `getVisibleBlogs()` > `getVisibleDotComSites()`\r\n* `getNumVisibleBlogs()` > `getVisibleDotComSitesCount()`\r\n\r\n* `setAllDotComBlogsVisibility(boolean visible)` > `setAllDotComSitesVisibility(boolean visible)`\r\n* `setDotComBlogsVisibility(int id, boolean visible)` > `setDotComSiteVisibilityByLocalId(int id, boolean visible)`\r\n* `isDotComBlogVisible(int blogId)` > `isDotComSiteVisibleByLocalId(int id)`\r\n\r\n* `isBlogInDatabase(int blogId, String xmlRpcUrl)` > `hasSiteWithSiteIdAndXmlRpcUrl(int siteId, String xmlRpcUrl)`\r\n* `isLocalBlogIdInDatabase(int localBlogId)` > `hasSiteWithSiteId(int id)`\r\n\r\n* `isCurrentUserAdminOfRemoteBlogId(long remoteBlogId)` > `isCurrentUserAdminOfSiteId(int siteId)`\r\n\r\n* `deleteBlog(Context ctx, int id)` > `deleteSite(SiteModel site)`\r\n* `deleteWordPressComBlogs(Context ctx)` > handled by `SiteAction.DELETE_WPCOM_SITES`\r\n\r\n<h5>Methods implemented reliant on the Jetpack WPCOM site id</h5>\r\n* `getLocalTableBlogIdForJetpackRemoteID(int remoteBlogId, String xmlRpcUrl)` > `getLocalIdForJetpackRemoteId(int jetpackRemoteId, String xmlRpcUrl)`\r\n* `getLocalTableBlogIdForRemoteBlogId(int remoteBlogId)` > `getLocalIdForRemoteSiteId(int siteId)`\r\n* `getLocalTableBlogIdForRemoteBlogIdAndXmlRpcUrl(int remoteBlogId, String xmlRpcUrl)` > `getLocalIdForRemoteSiteIdAndXmlRpcUrl(int siteId, String xmlRpcUrl)`\r\n* `getRemoteBlogIdForLocalTableBlogId(int localBlogId)` > `getSiteIdForLocalId(int id)`\r\n* `isRemoteBlogIdDotComOrJetpack(int remoteBlogId)` > `hasDotComOrJetpackSiteWithSiteId(int siteId)`\r\n* `getBlogForDotComBlogId(String dotComBlogId)` > `getSiteByDotComSiteId(String dotComSiteId)`\r\n\r\n<h5>Methods not implemented for special reasons (future work required):</h5>\r\n* `dangerouslyDeleteAllContent()`: this clears all tables, not only sites - we'll probably be implementing this at a higher level later on\r\n* `deleteQuickPressShortcutsForLocalTableBlogId(Context ctx, int blogId)`: this acts on a different Store, added TODOs about handling this when a site is deleted\r\n\r\n<h5>Methods not implemented because they're not necessary:</h5>\r\n* `removeDotComCredentials()` // added to clear credentials from older DB versions (March 2015)\r\n* `updateWPComCredentials(String username, String password)`: this is still called on `saveBlog()` in `WordPressDB`, but we won't be using this going forward (should have been removed at the same time as `removeDotComCredentials()`)\r\n* `updateDotcomFlag()` // added when .COM flag identification changed to fix any mis-labelled sites (https://github.com/wordpress-mobile/WordPress-Android/pull/3548)\r\n* `migrateWPComAccount()` // added for migration when global .COM account support was added: https://github.com/wordpress-mobile/WordPress-Android/commit/efccc0b6b7ef2305b0e9a98eb7c0c1fae5d09f8a\r\n* `migratePasswords()` // added a very long time ago, migration-only\r\n* `getWPCOMBlogID()` // unused, very old method\r\n* `getVisibleDotComBlogs()` // unused, was added for Reader reblogging but that feature has been dropped: https://github.com/wordpress-mobile/WordPress-Android/pull/2836. In any case, performed the same function as `getVisibleBlogs()` (now performed by `getVisibleDotComSites()`), since we only support hiding .com sites\r\n* `getAllBlogsIDs()` // unused\r\n* `hasDotOrgBlogForUsernameAndUrl(String username, String url)` // unused, was used by SignInFragment and was removed here: https://github.com/wordpress-mobile/WordPress-Android/commit/b91838bf69aea8bd66359963a3125515ce89ec06\r\n* `loadStatsLogin(int id)` // unused"},"comment":{"url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/issues/comments/195775702","html_url":"https://github.com/wordpress-mobile/WordPress-Stores-Android/pull/15#issuecomment-195775702","issue_url":"https://api.github.com/repos/wordpress-mobile/WordPress-Stores-Android/issues/15","id":195775702,"user":{"login":"aforcier","id":9613966,"avatar_url":"https://avatars.githubusercontent.com/u/9613966?v=3","gravatar_id":"","url":"https://api.github.com/users/aforcier","html_url":"https://github.com/aforcier","followers_url":"https://api.github.com/users/aforcier/followers","following_url":"https://api.github.com/users/aforcier/following{/other_user}","gists_url":"https://api.github.com/users/aforcier/gists{/gist_id}","starred_url":"https://api.github.com/users/aforcier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aforcier/subscriptions","organizations_url":"https://api.github.com/users/aforcier/orgs","repos_url":"https://api.github.com/users/aforcier/repos","events_url":"https://api.github.com/users/aforcier/events{/privacy}","received_events_url":"https://api.github.com/users/aforcier/received_events","type":"User","site_admin":false},"created_at":"2016-03-12T17:09:28Z","updated_at":"2016-03-12T17:09:28Z","body":"Updated.\r\n\r\n* Use `siteId`/`dotOrgSiteId` instead of `siteId`/`dotComIdForJetpack`\r\n* Used 'Remove Site' instead of 'Delete Site' language\r\n* Added methods to complete coverage of `getBlogsBy` from `WordPressDB`, allowing us not to implement those methods directly as they're too generic\r\n\r\n`getBlogsBy` migration:\r\n* `getBlogsBy(null, extraFields)` > `getSites()`\r\n* `getBlogsBy(\"dotcomFlag=1\", extraFields)` > `getDotComSites()`\r\n* `getBlogsBy(\"isHidden=0\", extraFields)` > `getVisibleSites()`\r\n* `getBlogsBy(\"isHidden=0 AND dotcomFlag=1\", extraFields)` > `getVisibleDotComSites()`\r\n* `getBlogsBy(\"dotcomFlag=0 OR (isHidden=0 AND dotcomFlag=1) \", extraFields)` > `getVisibleSites()`"}}