Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: Pagination Missing on "Shop Summary" Merchant Table (βœ“ Sandbox Passed) #99

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7b3d8c3
feat: Updated app/models/summary/shop.rb
sweep-ai[bot] Feb 3, 2024
29e1e9f
feat: Add pagination helper for generating navigat
sweep-ai[bot] Feb 3, 2024
7c7bb77
feat: Updated app/controllers/summarys/shop_contro
sweep-ai[bot] Feb 3, 2024
483ecf0
feat: Updated app/views/summarys/index.html.erb
sweep-ai[bot] Feb 3, 2024
aeab51f
feat: Updated app/controllers/summarys/shop_contro
sweep-ai[bot] Feb 3, 2024
5549357
feat: Updated app/views/summarys/index.html.erb
sweep-ai[bot] Feb 3, 2024
6da5ac6
feat: Updated app/controllers/summarys/shop_contro
sweep-ai[bot] Feb 3, 2024
4d8949d
feat: Updated app/helpers/pagination_helper.rb
sweep-ai[bot] Feb 3, 2024
383ba3d
feat: Updated app/controllers/summarys/shop_contro
sweep-ai[bot] Feb 3, 2024
51029a8
feat: Updated app/helpers/pagination_helper.rb
sweep-ai[bot] Feb 3, 2024
7d2f4fc
Delete app/helpers/pagination_helper.rb
sweep-ai[bot] Feb 3, 2024
ddc2f19
feat: Updated app/views/summarys/index.html.erb
sweep-ai[bot] Feb 3, 2024
30e8888
feat: Add controller test for shop summary paginat
sweep-ai[bot] Feb 4, 2024
171f49d
feat: Updated test/controllers/summarys/shop_contr
sweep-ai[bot] Feb 4, 2024
0168ab2
feat: Updated test/controllers/summarys/shop_contr
sweep-ai[bot] Feb 4, 2024
64d6c72
feat: Updated test/controllers/summarys/shop_contr
sweep-ai[bot] Feb 4, 2024
5b525cb
feat: Updated test/controllers/summarys/shop_contr
sweep-ai[bot] Feb 4, 2024
9f4eb5a
feat: Updated test/controllers/summarys/shop_contr
sweep-ai[bot] Feb 4, 2024
0e136f1
feat: Updated test/controllers/summarys/shop_contr
sweep-ai[bot] Feb 4, 2024
b92ac2f
Merge main into sweep/pagination_missing_on_shop_summary_merch
sweep-ai[bot] Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/summarys/shop_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
class Summarys::ShopController < SummarysController
def index
@selected_app = summary_params[:selected_app]
@summaries = Summary::Shop.new(user: current_user, selected_app: @selected_app).summarize
@page = params[:page] || 1
@per_page = Summary::Shop::TOP_SHOPS_LIMIT
@summaries = Summary::Shop.new(user: current_user, selected_app: @selected_app).summarize(page: @page.to_i, per_page: @per_page.to_i)

render "summarys/index"
end
Expand Down
6 changes: 4 additions & 2 deletions app/models/summary/shop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ def summarize

private

def summarized_shop_data
def summarized_shop_data(page: 1, per_page: TOP_SHOPS_LIMIT)
offset = (page - 1) * per_page
result = payments
.select(SQL_QUERY)
.group(:shop)
.order("total_revenue DESC")
.limit(TOP_SHOPS_LIMIT)
.offset(offset)
.limit(per_page)

result.each_with_object({}) do |record, hash|
hash[record.shop] = record.attributes.except("shop")
Expand Down
1 change: 1 addition & 0 deletions app/views/summarys/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<%= polaris_card do %>
<%= render controller_name, rows: @summaries %>
<% end %>
<%= polaris_pagination(previous_url: @page > 1 ? summary_shop_path(page: @page - 1) : nil, next_url: @page < @total_pages ? summary_shop_path(page: @page + 1) : nil) %>

<% end %>

Expand Down
16 changes: 16 additions & 0 deletions test/controllers/summarys/shop_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'test_helper'
forsbergplustwo marked this conversation as resolved.
Show resolved Hide resolved

class ShopControllerTest < ActionController::TestCase
setup do
@user = users(:one)
@selected_app = apps(:one)
@summary = Summary::Shop.new(user: @user, selected_app: @selected_app).summarize(page: 1, per_page: 1)
sign_in @user
end

test "index pagination" do
get :index, params: { selected_app: @selected_app.id, page: 1 }
forsbergplustwo marked this conversation as resolved.
Show resolved Hide resolved
forsbergplustwo marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[standard] <Layout/SpaceInsideHashLiteralBraces> reported by reviewdog 🐢
Space inside { detected.

Suggested change
get :index, params: { selected_app: @selected_app.id, page: 1 }
get :index, params: {selected_app: @selected_app.id, page: 1}

Copy link
Author

@sweep-ai sweep-ai bot Feb 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸš€ Wrote Changes

Done.

This is an automated message generated by Sweep AI.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[standard] <Layout/SpaceInsideHashLiteralBraces> reported by reviewdog 🐢
Space inside } detected.

Suggested change
get :index, params: { selected_app: @selected_app.id, page: 1 }
get :index, params: { selected_app: @selected_app.id, page: 1

Copy link
Author

@sweep-ai sweep-ai bot Feb 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸš€ Wrote Changes

Done.

This is an automated message generated by Sweep AI.

assert_response :success
assert_equal @summary, assigns(:summaries)
end
end
Loading