{"action":"created","comment":{"url":"https://api.github.com/repos/UpWave/internal-management/pulls/comments/133892635","pull_request_review_id":57125111,"id":133892635,"diff_hunk":"@@ -0,0 +1,77 @@\n+module Admin\n+  require 'trello' \n+  class Admin::TimelogsController < ApplicationController\n+    before_action :authenticate_user!\n+    before_action :load_timelog, only: [:update, :destroy]\n+    before_action :load_trello_service, only: [:index, :new]\n+\n+    def index\n+      if params[:filter]\n+        @timelogs = User.find(params[:user_id]).timelogs.paginate(page: params[:page], per_page: 5).send params[:filter] ","path":"app/controllers/admin/timelogs_controller.rb","position":10,"original_position":10,"commit_id":"af0fad86d695b6096f34ea84bd596ad628dd4dbb","original_commit_id":"af0fad86d695b6096f34ea84bd596ad628dd4dbb","user":{"login":"jizak","id":1062952,"avatar_url":"https://avatars0.githubusercontent.com/u/1062952?v=4","gravatar_id":"","url":"https://api.github.com/users/jizak","html_url":"https://github.com/jizak","followers_url":"https://api.github.com/users/jizak/followers","following_url":"https://api.github.com/users/jizak/following{/other_user}","gists_url":"https://api.github.com/users/jizak/gists{/gist_id}","starred_url":"https://api.github.com/users/jizak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jizak/subscriptions","organizations_url":"https://api.github.com/users/jizak/orgs","repos_url":"https://api.github.com/users/jizak/repos","events_url":"https://api.github.com/users/jizak/events{/privacy}","received_events_url":"https://api.github.com/users/jizak/received_events","type":"User","site_admin":false},"body":"what we can do here:\r\n1. `User.find(params[:user_id])`. This code we can find in all actions. So it is better to move it to a separate method and have an instance variable.\r\n2. We can have a method called `filtered_timelogs` which is going to be responsible only for filtering.\r\n```\r\ndef filtered_timelogs\r\n  @user.timelogs.send params[:filter]\r\nend\r\n```\r\nP.S. using send is not the best, but let it be for now :)\r\n3. We can paginate based on format. If it is pdf, we don't need to paginate, just use `filtered_timelogs`. If it is `html` we'll paginate: `filtered_timelogs.paginate...`","created_at":"2017-08-18T07:07:23Z","updated_at":"2017-08-18T07:14:23Z","html_url":"https://github.com/UpWave/internal-management/pull/11#discussion_r133892635","pull_request_url":"https://api.github.com/repos/UpWave/internal-management/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/UpWave/internal-management/pulls/comments/133892635"},"html":{"href":"https://github.com/UpWave/internal-management/pull/11#discussion_r133892635"},"pull_request":{"href":"https://api.github.com/repos/UpWave/internal-management/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/UpWave/internal-management/pulls/11","id":135790265,"html_url":"https://github.com/UpWave/internal-management/pull/11","diff_url":"https://github.com/UpWave/internal-management/pull/11.diff","patch_url":"https://github.com/UpWave/internal-management/pull/11.patch","issue_url":"https://api.github.com/repos/UpWave/internal-management/issues/11","number":11,"state":"open","locked":false,"title":"admin CRUD actions","user":{"login":"markivancho","id":30623974,"avatar_url":"https://avatars1.githubusercontent.com/u/30623974?v=4","gravatar_id":"","url":"https://api.github.com/users/markivancho","html_url":"https://github.com/markivancho","followers_url":"https://api.github.com/users/markivancho/followers","following_url":"https://api.github.com/users/markivancho/following{/other_user}","gists_url":"https://api.github.com/users/markivancho/gists{/gist_id}","starred_url":"https://api.github.com/users/markivancho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markivancho/subscriptions","organizations_url":"https://api.github.com/users/markivancho/orgs","repos_url":"https://api.github.com/users/markivancho/repos","events_url":"https://api.github.com/users/markivancho/events{/privacy}","received_events_url":"https://api.github.com/users/markivancho/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-15T12:25:56Z","updated_at":"2017-08-18T07:14:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ad73cd3b16a32c5c33a988dea4b3fce96d0e677e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/UpWave/internal-management/pulls/11/commits","review_comments_url":"https://api.github.com/repos/UpWave/internal-management/pulls/11/comments","review_comment_url":"https://api.github.com/repos/UpWave/internal-management/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UpWave/internal-management/issues/11/comments","statuses_url":"https://api.github.com/repos/UpWave/internal-management/statuses/af0fad86d695b6096f34ea84bd596ad628dd4dbb","head":{"label":"UpWave:adminFeature","ref":"adminFeature","sha":"af0fad86d695b6096f34ea84bd596ad628dd4dbb","user":{"login":"UpWave","id":23734189,"avatar_url":"https://avatars0.githubusercontent.com/u/23734189?v=4","gravatar_id":"","url":"https://api.github.com/users/UpWave","html_url":"https://github.com/UpWave","followers_url":"https://api.github.com/users/UpWave/followers","following_url":"https://api.github.com/users/UpWave/following{/other_user}","gists_url":"https://api.github.com/users/UpWave/gists{/gist_id}","starred_url":"https://api.github.com/users/UpWave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UpWave/subscriptions","organizations_url":"https://api.github.com/users/UpWave/orgs","repos_url":"https://api.github.com/users/UpWave/repos","events_url":"https://api.github.com/users/UpWave/events{/privacy}","received_events_url":"https://api.github.com/users/UpWave/received_events","type":"Organization","site_admin":false},"repo":{"id":99089019,"name":"internal-management","full_name":"UpWave/internal-management","owner":{"login":"UpWave","id":23734189,"avatar_url":"https://avatars0.githubusercontent.com/u/23734189?v=4","gravatar_id":"","url":"https://api.github.com/users/UpWave","html_url":"https://github.com/UpWave","followers_url":"https://api.github.com/users/UpWave/followers","following_url":"https://api.github.com/users/UpWave/following{/other_user}","gists_url":"https://api.github.com/users/UpWave/gists{/gist_id}","starred_url":"https://api.github.com/users/UpWave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UpWave/subscriptions","organizations_url":"https://api.github.com/users/UpWave/orgs","repos_url":"https://api.github.com/users/UpWave/repos","events_url":"https://api.github.com/users/UpWave/events{/privacy}","received_events_url":"https://api.github.com/users/UpWave/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UpWave/internal-management","description":null,"fork":false,"url":"https://api.github.com/repos/UpWave/internal-management","forks_url":"https://api.github.com/repos/UpWave/internal-management/forks","keys_url":"https://api.github.com/repos/UpWave/internal-management/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UpWave/internal-management/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UpWave/internal-management/teams","hooks_url":"https://api.github.com/repos/UpWave/internal-management/hooks","issue_events_url":"https://api.github.com/repos/UpWave/internal-management/issues/events{/number}","events_url":"https://api.github.com/repos/UpWave/internal-management/events","assignees_url":"https://api.github.com/repos/UpWave/internal-management/assignees{/user}","branches_url":"https://api.github.com/repos/UpWave/internal-management/branches{/branch}","tags_url":"https://api.github.com/repos/UpWave/internal-management/tags","blobs_url":"https://api.github.com/repos/UpWave/internal-management/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UpWave/internal-management/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UpWave/internal-management/git/refs{/sha}","trees_url":"https://api.github.com/repos/UpWave/internal-management/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UpWave/internal-management/statuses/{sha}","languages_url":"https://api.github.com/repos/UpWave/internal-management/languages","stargazers_url":"https://api.github.com/repos/UpWave/internal-management/stargazers","contributors_url":"https://api.github.com/repos/UpWave/internal-management/contributors","subscribers_url":"https://api.github.com/repos/UpWave/internal-management/subscribers","subscription_url":"https://api.github.com/repos/UpWave/internal-management/subscription","commits_url":"https://api.github.com/repos/UpWave/internal-management/commits{/sha}","git_commits_url":"https://api.github.com/repos/UpWave/internal-management/git/commits{/sha}","comments_url":"https://api.github.com/repos/UpWave/internal-management/comments{/number}","issue_comment_url":"https://api.github.com/repos/UpWave/internal-management/issues/comments{/number}","contents_url":"https://api.github.com/repos/UpWave/internal-management/contents/{+path}","compare_url":"https://api.github.com/repos/UpWave/internal-management/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UpWave/internal-management/merges","archive_url":"https://api.github.com/repos/UpWave/internal-management/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UpWave/internal-management/downloads","issues_url":"https://api.github.com/repos/UpWave/internal-management/issues{/number}","pulls_url":"https://api.github.com/repos/UpWave/internal-management/pulls{/number}","milestones_url":"https://api.github.com/repos/UpWave/internal-management/milestones{/number}","notifications_url":"https://api.github.com/repos/UpWave/internal-management/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UpWave/internal-management/labels{/name}","releases_url":"https://api.github.com/repos/UpWave/internal-management/releases{/id}","deployments_url":"https://api.github.com/repos/UpWave/internal-management/deployments","created_at":"2017-08-02T07:57:08Z","updated_at":"2017-08-02T08:03:46Z","pushed_at":"2017-08-17T14:10:44Z","git_url":"git://github.com/UpWave/internal-management.git","ssh_url":"git@github.com:UpWave/internal-management.git","clone_url":"https://github.com/UpWave/internal-management.git","svn_url":"https://github.com/UpWave/internal-management","homepage":null,"size":521,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"UpWave:development","ref":"development","sha":"a240c29fed372f56d9070c9423e03738f56619db","user":{"login":"UpWave","id":23734189,"avatar_url":"https://avatars0.githubusercontent.com/u/23734189?v=4","gravatar_id":"","url":"https://api.github.com/users/UpWave","html_url":"https://github.com/UpWave","followers_url":"https://api.github.com/users/UpWave/followers","following_url":"https://api.github.com/users/UpWave/following{/other_user}","gists_url":"https://api.github.com/users/UpWave/gists{/gist_id}","starred_url":"https://api.github.com/users/UpWave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UpWave/subscriptions","organizations_url":"https://api.github.com/users/UpWave/orgs","repos_url":"https://api.github.com/users/UpWave/repos","events_url":"https://api.github.com/users/UpWave/events{/privacy}","received_events_url":"https://api.github.com/users/UpWave/received_events","type":"Organization","site_admin":false},"repo":{"id":99089019,"name":"internal-management","full_name":"UpWave/internal-management","owner":{"login":"UpWave","id":23734189,"avatar_url":"https://avatars0.githubusercontent.com/u/23734189?v=4","gravatar_id":"","url":"https://api.github.com/users/UpWave","html_url":"https://github.com/UpWave","followers_url":"https://api.github.com/users/UpWave/followers","following_url":"https://api.github.com/users/UpWave/following{/other_user}","gists_url":"https://api.github.com/users/UpWave/gists{/gist_id}","starred_url":"https://api.github.com/users/UpWave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UpWave/subscriptions","organizations_url":"https://api.github.com/users/UpWave/orgs","repos_url":"https://api.github.com/users/UpWave/repos","events_url":"https://api.github.com/users/UpWave/events{/privacy}","received_events_url":"https://api.github.com/users/UpWave/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UpWave/internal-management","description":null,"fork":false,"url":"https://api.github.com/repos/UpWave/internal-management","forks_url":"https://api.github.com/repos/UpWave/internal-management/forks","keys_url":"https://api.github.com/repos/UpWave/internal-management/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UpWave/internal-management/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UpWave/internal-management/teams","hooks_url":"https://api.github.com/repos/UpWave/internal-management/hooks","issue_events_url":"https://api.github.com/repos/UpWave/internal-management/issues/events{/number}","events_url":"https://api.github.com/repos/UpWave/internal-management/events","assignees_url":"https://api.github.com/repos/UpWave/internal-management/assignees{/user}","branches_url":"https://api.github.com/repos/UpWave/internal-management/branches{/branch}","tags_url":"https://api.github.com/repos/UpWave/internal-management/tags","blobs_url":"https://api.github.com/repos/UpWave/internal-management/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UpWave/internal-management/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UpWave/internal-management/git/refs{/sha}","trees_url":"https://api.github.com/repos/UpWave/internal-management/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UpWave/internal-management/statuses/{sha}","languages_url":"https://api.github.com/repos/UpWave/internal-management/languages","stargazers_url":"https://api.github.com/repos/UpWave/internal-management/stargazers","contributors_url":"https://api.github.com/repos/UpWave/internal-management/contributors","subscribers_url":"https://api.github.com/repos/UpWave/internal-management/subscribers","subscription_url":"https://api.github.com/repos/UpWave/internal-management/subscription","commits_url":"https://api.github.com/repos/UpWave/internal-management/commits{/sha}","git_commits_url":"https://api.github.com/repos/UpWave/internal-management/git/commits{/sha}","comments_url":"https://api.github.com/repos/UpWave/internal-management/comments{/number}","issue_comment_url":"https://api.github.com/repos/UpWave/internal-management/issues/comments{/number}","contents_url":"https://api.github.com/repos/UpWave/internal-management/contents/{+path}","compare_url":"https://api.github.com/repos/UpWave/internal-management/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UpWave/internal-management/merges","archive_url":"https://api.github.com/repos/UpWave/internal-management/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UpWave/internal-management/downloads","issues_url":"https://api.github.com/repos/UpWave/internal-management/issues{/number}","pulls_url":"https://api.github.com/repos/UpWave/internal-management/pulls{/number}","milestones_url":"https://api.github.com/repos/UpWave/internal-management/milestones{/number}","notifications_url":"https://api.github.com/repos/UpWave/internal-management/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UpWave/internal-management/labels{/name}","releases_url":"https://api.github.com/repos/UpWave/internal-management/releases{/id}","deployments_url":"https://api.github.com/repos/UpWave/internal-management/deployments","created_at":"2017-08-02T07:57:08Z","updated_at":"2017-08-02T08:03:46Z","pushed_at":"2017-08-17T14:10:44Z","git_url":"git://github.com/UpWave/internal-management.git","ssh_url":"git@github.com:UpWave/internal-management.git","clone_url":"https://github.com/UpWave/internal-management.git","svn_url":"https://github.com/UpWave/internal-management","homepage":null,"size":521,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UpWave/internal-management/pulls/11"},"html":{"href":"https://github.com/UpWave/internal-management/pull/11"},"issue":{"href":"https://api.github.com/repos/UpWave/internal-management/issues/11"},"comments":{"href":"https://api.github.com/repos/UpWave/internal-management/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/UpWave/internal-management/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/UpWave/internal-management/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UpWave/internal-management/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/UpWave/internal-management/statuses/af0fad86d695b6096f34ea84bd596ad628dd4dbb"}}}}
{"actor":{"display_login":"jizak"}}