{"action":"created","comment":{"url":"https://api.github.com/repos/kibimon/monstodon/pulls/comments/183244771","pull_request_review_id":114208672,"id":183244771,"diff_hunk":"@@ -17,10 +17,49 @@ def find_local(username)\n     end\n \n     def find_remote(username, domain)\n+      return AccountByIdFinder.new(username[4..-1], :mon_id).account if domain.nil? && username.match?(/\\Amon_/i)\n+      return AccountByIdFinder.new(username[6..-1], :route_no).account if domain.nil? && username.match?(/\\Aroute_/i)\n       AccountFinder.new(username, domain).account\n     end\n   end\n \n+  class AccountByIdFinder\n+    attr_reader :the_id, :id_name\n+\n+    def initialize(the_id, id_name)\n+      @the_id = the_id\n+      @id_name = id_name\n+    end\n+\n+    def account\n+      scoped_accounts.order(id: :asc).take\n+    end\n+\n+    private\n+\n+    def scoped_accounts\n+      Account.unscoped.tap do |scope|\n+        scope.merge! with_id\n+        scope.merge! matching_id\n+        scope.merge! matching_domain\n+      end\n+    end\n+\n+    def with_id\n+      search = Hash.new\n+      search[id_name] = 0\n+      Account.where.not(search)\n+    end\n+\n+    def matching_id\n+      Account.where(Account.arel_table[id_name].eq the_id.to_i)","path":"app/models/concerns/account_finder_concern.rb","position":39,"original_position":39,"commit_id":"db9ad71a9fd14b3ad0488a26437c42b369f755e6","original_commit_id":"5fa669cc645f684955014cd74f3da6b4a224e860","user":{"login":"ekiru","id":75553,"avatar_url":"https://avatars3.githubusercontent.com/u/75553?v=4","gravatar_id":"","url":"https://api.github.com/users/ekiru","html_url":"https://github.com/ekiru","followers_url":"https://api.github.com/users/ekiru/followers","following_url":"https://api.github.com/users/ekiru/following{/other_user}","gists_url":"https://api.github.com/users/ekiru/gists{/gist_id}","starred_url":"https://api.github.com/users/ekiru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekiru/subscriptions","organizations_url":"https://api.github.com/users/ekiru/orgs","repos_url":"https://api.github.com/users/ekiru/repos","events_url":"https://api.github.com/users/ekiru/events{/privacy}","received_events_url":"https://api.github.com/users/ekiru/received_events","type":"User","site_admin":false},"body":"Isn't this the same as `Account.where(id_name => the_id.to_i)`?","created_at":"2018-04-22T17:39:25Z","updated_at":"2018-04-22T18:04:52Z","html_url":"https://github.com/kibimon/monstodon/pull/3#discussion_r183244771","pull_request_url":"https://api.github.com/repos/kibimon/monstodon/pulls/3","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/kibimon/monstodon/pulls/comments/183244771"},"html":{"href":"https://github.com/kibimon/monstodon/pull/3#discussion_r183244771"},"pull_request":{"href":"https://api.github.com/repos/kibimon/monstodon/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/kibimon/monstodon/pulls/3","id":183193571,"html_url":"https://github.com/kibimon/monstodon/pull/3","diff_url":"https://github.com/kibimon/monstodon/pull/3.diff","patch_url":"https://github.com/kibimon/monstodon/pull/3.patch","issue_url":"https://api.github.com/repos/kibimon/monstodon/issues/3","number":3,"state":"open","locked":false,"title":"[WIP] Phase 1 of the Implementation Plan","user":{"login":"ekiru","id":75553,"avatar_url":"https://avatars3.githubusercontent.com/u/75553?v=4","gravatar_id":"","url":"https://api.github.com/users/ekiru","html_url":"https://github.com/ekiru","followers_url":"https://api.github.com/users/ekiru/followers","following_url":"https://api.github.com/users/ekiru/following{/other_user}","gists_url":"https://api.github.com/users/ekiru/gists{/gist_id}","starred_url":"https://api.github.com/users/ekiru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekiru/subscriptions","organizations_url":"https://api.github.com/users/ekiru/orgs","repos_url":"https://api.github.com/users/ekiru/repos","events_url":"https://api.github.com/users/ekiru/events{/privacy}","received_events_url":"https://api.github.com/users/ekiru/received_events","type":"User","site_admin":false},"body":"From #1 \r\n\r\n* <del>Create an `ActivityMon::Record` class with `self.abstract_class = true` and `self.table_name_prefix = 'activitymon'` from which to inherit all the other ActivityMon models with their own tables.</del>\r\n  * This turns out to be unnecessary: we can just set the prefix on the `ActivityMon` module\r\n  * [x] Define `ActivityMon.table_name_prefix` to \"activitymon\"\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/9baea84792d03d828da1e1598ab0067e41ce7272#diff-716c55d26e9f82047a4b253114b75d3f\r\n* [x] Create an `ActivityMon::Species` model with just `id`, `name`, and `uri` columns.\r\n  * Done in https://github.com/kibimon/monstodon/pull/3/commits/9baea84792d03d828da1e1598ab0067e41ce7272\r\n* [x] Create an `ActivityMon::Trainer` model inheriting from `Account`.\r\n  * Done in https://github.com/kibimon/monstodon/pull/3/commits/b8eb74474dedc85d1ef1b0d469d614ff61bebcd7#diff-4c9c49aa598af63e3db7747eb0a72f47\r\n  * [x] Create a migration which adds a `type` column defaulting to `ActivityMon::Trainer` to the `accounts` table, defaulting all existing accounts to `ActivityMon::Trainer`.\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/b8eb74474dedc85d1ef1b0d469d614ff61bebcd7#diff-54a532b490bf122cba18ed60b9062c5e\r\n  * [x] <ins>Create a migration to backfill the `type` column on the `accounts` table.</ins>\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/1a93edf150dd8ec81e7a12bc3c268754992079a0\r\n  * [x] Add a validation to ensure that Trainers do not have owners or species.\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/65f2c89a48c545f0dd665437e9a28bb334cdf393#diff-4c9c49aa598af63e3db7747eb0a72f47R53\r\n  * [x] ??? Make sure any existing accounts stuff that needs to be is aware of Trainer.\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/e6d38536440cd088cfbfd4af51cd7e8fb9ecf2b1\r\n* [x] Create an `ActivityMon::Mon` model inheriting from `Account` with just additional `owner` and `species` relationships.\r\n  * Done in https://github.com/kibimon/monstodon/pull/3/commits/65f2c89a48c545f0dd665437e9a28bb334cdf393\r\n  * [x] Create a migration which adds `owner_id` and `species_id` columns to the `accounts` table.\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/65f2c89a48c545f0dd665437e9a28bb334cdf393#diff-9a44092eadaa444aa78862d04e1b89cb\r\n  * [x] Add a validation to `Mon` requiring that the `user` be `nil`.\r\n    * https://github.com/kibimon/monstodon/pull/3/commits/c8bf9b4e9395625ef26cbd7a237a7baf6da6a9e5 implements this with a validation on `User`.\r\n  * [x] Add a validation to `Mon` requiring that the `owner` must be a `Trainer`.\r\n    * Setting the `class_name` option to `belongs_to` enforces this.\r\n  * [x] Add the `mon` collection to `Trainer` as the inverse of `owner`.\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/65f2c89a48c545f0dd665437e9a28bb334cdf393#diff-4c9c49aa598af63e3db7747eb0a72f47R53\r\n  * [x] Add an inflection to the application configuration specifying that the plural of \"mon\" is \"mon\".\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/65f2c89a48c545f0dd665437e9a28bb334cdf393#diff-cae6c97fa7e78133081d47707cf11197\r\n* [x] Add an `Admin::ActivityMon::Species` controller\r\n  * Done in https://github.com/kibimon/monstodon/pull/3/commits/088e770e29f147c383cf7d7ccf7362e81846dee8\r\n  * [x] With an `index` action listing all known `Species`.\r\n    * Done in https://github.com/kibimon/monstodon/pull/3/commits/088e770e29f147c383cf7d7ccf7362e81846dee8\r\n  * [ ] With a `new` action for a creation form.\r\n  * [ ] With a `create` action for creating new `Species`.\r\n* [x] Add information about Mon to the `Admin::AccountsController`\r\n* [x] Add a `create` action to the `Admin::AccountsController` that can be used for manually creating new `Mon` (eventually `Route`s too).\r\n* [x] Add an `ActivityMon::MonController`\r\n  * [x] With an `index` action at `/users/:username/mon` to list trainer's mon\r\n  * [x] With a `show` action at `/users/:username/mon/:id` to view an individual mon's profile","created_at":"2018-04-20T23:58:11Z","updated_at":"2018-04-22T18:04:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d4a96146eeec5af468f8b8a5ed8d36472346346","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kibimon/monstodon/pulls/3/commits","review_comments_url":"https://api.github.com/repos/kibimon/monstodon/pulls/3/comments","review_comment_url":"https://api.github.com/repos/kibimon/monstodon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kibimon/monstodon/issues/3/comments","statuses_url":"https://api.github.com/repos/kibimon/monstodon/statuses/db9ad71a9fd14b3ad0488a26437c42b369f755e6","head":{"label":"kibimon:activitymon-phase-1","ref":"activitymon-phase-1","sha":"db9ad71a9fd14b3ad0488a26437c42b369f755e6","user":{"login":"kibimon","id":38513712,"avatar_url":"https://avatars2.githubusercontent.com/u/38513712?v=4","gravatar_id":"","url":"https://api.github.com/users/kibimon","html_url":"https://github.com/kibimon","followers_url":"https://api.github.com/users/kibimon/followers","following_url":"https://api.github.com/users/kibimon/following{/other_user}","gists_url":"https://api.github.com/users/kibimon/gists{/gist_id}","starred_url":"https://api.github.com/users/kibimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kibimon/subscriptions","organizations_url":"https://api.github.com/users/kibimon/orgs","repos_url":"https://api.github.com/users/kibimon/repos","events_url":"https://api.github.com/users/kibimon/events{/privacy}","received_events_url":"https://api.github.com/users/kibimon/received_events","type":"Organization","site_admin":false},"repo":{"id":130140315,"name":"monstodon","full_name":"kibimon/monstodon","owner":{"login":"kibimon","id":38513712,"avatar_url":"https://avatars2.githubusercontent.com/u/38513712?v=4","gravatar_id":"","url":"https://api.github.com/users/kibimon","html_url":"https://github.com/kibimon","followers_url":"https://api.github.com/users/kibimon/followers","following_url":"https://api.github.com/users/kibimon/following{/other_user}","gists_url":"https://api.github.com/users/kibimon/gists{/gist_id}","starred_url":"https://api.github.com/users/kibimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kibimon/subscriptions","organizations_url":"https://api.github.com/users/kibimon/orgs","repos_url":"https://api.github.com/users/kibimon/repos","events_url":"https://api.github.com/users/kibimon/events{/privacy}","received_events_url":"https://api.github.com/users/kibimon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kibimon/monstodon","description":"An ActivityMon implementation via Mastodon","fork":true,"url":"https://api.github.com/repos/kibimon/monstodon","forks_url":"https://api.github.com/repos/kibimon/monstodon/forks","keys_url":"https://api.github.com/repos/kibimon/monstodon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kibimon/monstodon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kibimon/monstodon/teams","hooks_url":"https://api.github.com/repos/kibimon/monstodon/hooks","issue_events_url":"https://api.github.com/repos/kibimon/monstodon/issues/events{/number}","events_url":"https://api.github.com/repos/kibimon/monstodon/events","assignees_url":"https://api.github.com/repos/kibimon/monstodon/assignees{/user}","branches_url":"https://api.github.com/repos/kibimon/monstodon/branches{/branch}","tags_url":"https://api.github.com/repos/kibimon/monstodon/tags","blobs_url":"https://api.github.com/repos/kibimon/monstodon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kibimon/monstodon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kibimon/monstodon/git/refs{/sha}","trees_url":"https://api.github.com/repos/kibimon/monstodon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kibimon/monstodon/statuses/{sha}","languages_url":"https://api.github.com/repos/kibimon/monstodon/languages","stargazers_url":"https://api.github.com/repos/kibimon/monstodon/stargazers","contributors_url":"https://api.github.com/repos/kibimon/monstodon/contributors","subscribers_url":"https://api.github.com/repos/kibimon/monstodon/subscribers","subscription_url":"https://api.github.com/repos/kibimon/monstodon/subscription","commits_url":"https://api.github.com/repos/kibimon/monstodon/commits{/sha}","git_commits_url":"https://api.github.com/repos/kibimon/monstodon/git/commits{/sha}","comments_url":"https://api.github.com/repos/kibimon/monstodon/comments{/number}","issue_comment_url":"https://api.github.com/repos/kibimon/monstodon/issues/comments{/number}","contents_url":"https://api.github.com/repos/kibimon/monstodon/contents/{+path}","compare_url":"https://api.github.com/repos/kibimon/monstodon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kibimon/monstodon/merges","archive_url":"https://api.github.com/repos/kibimon/monstodon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kibimon/monstodon/downloads","issues_url":"https://api.github.com/repos/kibimon/monstodon/issues{/number}","pulls_url":"https://api.github.com/repos/kibimon/monstodon/pulls{/number}","milestones_url":"https://api.github.com/repos/kibimon/monstodon/milestones{/number}","notifications_url":"https://api.github.com/repos/kibimon/monstodon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kibimon/monstodon/labels{/name}","releases_url":"https://api.github.com/repos/kibimon/monstodon/releases{/id}","deployments_url":"https://api.github.com/repos/kibimon/monstodon/deployments","created_at":"2018-04-19T01:08:41Z","updated_at":"2018-04-19T02:57:38Z","pushed_at":"2018-04-22T17:26:18Z","git_url":"git://github.com/kibimon/monstodon.git","ssh_url":"git@github.com:kibimon/monstodon.git","clone_url":"https://github.com/kibimon/monstodon.git","svn_url":"https://github.com/kibimon/monstodon","homepage":"","size":56086,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"kibimon:master","ref":"master","sha":"e3283365cb8b6a53f6ffde29365f8a21da10ff3e","user":{"login":"kibimon","id":38513712,"avatar_url":"https://avatars2.githubusercontent.com/u/38513712?v=4","gravatar_id":"","url":"https://api.github.com/users/kibimon","html_url":"https://github.com/kibimon","followers_url":"https://api.github.com/users/kibimon/followers","following_url":"https://api.github.com/users/kibimon/following{/other_user}","gists_url":"https://api.github.com/users/kibimon/gists{/gist_id}","starred_url":"https://api.github.com/users/kibimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kibimon/subscriptions","organizations_url":"https://api.github.com/users/kibimon/orgs","repos_url":"https://api.github.com/users/kibimon/repos","events_url":"https://api.github.com/users/kibimon/events{/privacy}","received_events_url":"https://api.github.com/users/kibimon/received_events","type":"Organization","site_admin":false},"repo":{"id":130140315,"name":"monstodon","full_name":"kibimon/monstodon","owner":{"login":"kibimon","id":38513712,"avatar_url":"https://avatars2.githubusercontent.com/u/38513712?v=4","gravatar_id":"","url":"https://api.github.com/users/kibimon","html_url":"https://github.com/kibimon","followers_url":"https://api.github.com/users/kibimon/followers","following_url":"https://api.github.com/users/kibimon/following{/other_user}","gists_url":"https://api.github.com/users/kibimon/gists{/gist_id}","starred_url":"https://api.github.com/users/kibimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kibimon/subscriptions","organizations_url":"https://api.github.com/users/kibimon/orgs","repos_url":"https://api.github.com/users/kibimon/repos","events_url":"https://api.github.com/users/kibimon/events{/privacy}","received_events_url":"https://api.github.com/users/kibimon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kibimon/monstodon","description":"An ActivityMon implementation via Mastodon","fork":true,"url":"https://api.github.com/repos/kibimon/monstodon","forks_url":"https://api.github.com/repos/kibimon/monstodon/forks","keys_url":"https://api.github.com/repos/kibimon/monstodon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kibimon/monstodon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kibimon/monstodon/teams","hooks_url":"https://api.github.com/repos/kibimon/monstodon/hooks","issue_events_url":"https://api.github.com/repos/kibimon/monstodon/issues/events{/number}","events_url":"https://api.github.com/repos/kibimon/monstodon/events","assignees_url":"https://api.github.com/repos/kibimon/monstodon/assignees{/user}","branches_url":"https://api.github.com/repos/kibimon/monstodon/branches{/branch}","tags_url":"https://api.github.com/repos/kibimon/monstodon/tags","blobs_url":"https://api.github.com/repos/kibimon/monstodon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kibimon/monstodon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kibimon/monstodon/git/refs{/sha}","trees_url":"https://api.github.com/repos/kibimon/monstodon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kibimon/monstodon/statuses/{sha}","languages_url":"https://api.github.com/repos/kibimon/monstodon/languages","stargazers_url":"https://api.github.com/repos/kibimon/monstodon/stargazers","contributors_url":"https://api.github.com/repos/kibimon/monstodon/contributors","subscribers_url":"https://api.github.com/repos/kibimon/monstodon/subscribers","subscription_url":"https://api.github.com/repos/kibimon/monstodon/subscription","commits_url":"https://api.github.com/repos/kibimon/monstodon/commits{/sha}","git_commits_url":"https://api.github.com/repos/kibimon/monstodon/git/commits{/sha}","comments_url":"https://api.github.com/repos/kibimon/monstodon/comments{/number}","issue_comment_url":"https://api.github.com/repos/kibimon/monstodon/issues/comments{/number}","contents_url":"https://api.github.com/repos/kibimon/monstodon/contents/{+path}","compare_url":"https://api.github.com/repos/kibimon/monstodon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kibimon/monstodon/merges","archive_url":"https://api.github.com/repos/kibimon/monstodon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kibimon/monstodon/downloads","issues_url":"https://api.github.com/repos/kibimon/monstodon/issues{/number}","pulls_url":"https://api.github.com/repos/kibimon/monstodon/pulls{/number}","milestones_url":"https://api.github.com/repos/kibimon/monstodon/milestones{/number}","notifications_url":"https://api.github.com/repos/kibimon/monstodon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kibimon/monstodon/labels{/name}","releases_url":"https://api.github.com/repos/kibimon/monstodon/releases{/id}","deployments_url":"https://api.github.com/repos/kibimon/monstodon/deployments","created_at":"2018-04-19T01:08:41Z","updated_at":"2018-04-19T02:57:38Z","pushed_at":"2018-04-22T17:26:18Z","git_url":"git://github.com/kibimon/monstodon.git","ssh_url":"git@github.com:kibimon/monstodon.git","clone_url":"https://github.com/kibimon/monstodon.git","svn_url":"https://github.com/kibimon/monstodon","homepage":"","size":56086,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kibimon/monstodon/pulls/3"},"html":{"href":"https://github.com/kibimon/monstodon/pull/3"},"issue":{"href":"https://api.github.com/repos/kibimon/monstodon/issues/3"},"comments":{"href":"https://api.github.com/repos/kibimon/monstodon/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/kibimon/monstodon/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/kibimon/monstodon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kibimon/monstodon/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/kibimon/monstodon/statuses/db9ad71a9fd14b3ad0488a26437c42b369f755e6"}},"author_association":"NONE"}}
{"actor":{"display_login":"ekiru"}}