From 7b3d8c3694290cbb9825d7b6ecec41e936873c9f Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 18:50:41 +0000
Subject: [PATCH 01/19] feat: Updated app/models/summary/shop.rb
---
app/models/summary/shop.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/models/summary/shop.rb b/app/models/summary/shop.rb
index 660d7f6..97c144d 100644
--- a/app/models/summary/shop.rb
+++ b/app/models/summary/shop.rb
@@ -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")
From 29e1e9fc4d3bb631a8a2866dafa6eb7aad1d0efe Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 18:53:22 +0000
Subject: [PATCH 02/19] feat: Add pagination helper for generating navigat
---
app/helpers/pagination_helper.rb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 app/helpers/pagination_helper.rb
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
new file mode 100644
index 0000000..a50f46c
--- /dev/null
+++ b/app/helpers/pagination_helper.rb
@@ -0,0 +1,17 @@
+module PaginationHelper
+ def paginate(total_items, items_per_page, current_page, base_url)
+ total_pages = (total_items.to_f / items_per_page).ceil
+ pagination_html = '
'
+ pagination_html.html_safe
+ end
+end
From 7c7bb772734396f9a32b751ae7f552d2d81845e1 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 18:55:20 +0000
Subject: [PATCH 03/19] feat: Updated app/controllers/summarys/shop_contro
---
app/controllers/summarys/shop_controller.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/controllers/summarys/shop_controller.rb b/app/controllers/summarys/shop_controller.rb
index ecd9c45..a653c3e 100644
--- a/app/controllers/summarys/shop_controller.rb
+++ b/app/controllers/summarys/shop_controller.rb
@@ -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 = params[: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
From 483ecf04bed955e113daeb8e1f8cf4abc84857c7 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 18:57:29 +0000
Subject: [PATCH 04/19] feat: Updated app/views/summarys/index.html.erb
---
app/views/summarys/index.html.erb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/views/summarys/index.html.erb b/app/views/summarys/index.html.erb
index 6b6c4bc..9b344bd 100644
--- a/app/views/summarys/index.html.erb
+++ b/app/views/summarys/index.html.erb
@@ -14,6 +14,7 @@
<%= polaris_card do %>
<%= render controller_name, rows: @summaries %>
<% end %>
+ <%= paginate(@summaries.count, @per_page.to_i, @page.to_i, summary_shop_path) %>
<% end %>
From aeab51ffa527722c80c1025ca901dfd5ec39f8e3 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 20:44:08 +0000
Subject: [PATCH 05/19] feat: Updated app/controllers/summarys/shop_contro
---
app/controllers/summarys/shop_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/summarys/shop_controller.rb b/app/controllers/summarys/shop_controller.rb
index a653c3e..9550ad0 100644
--- a/app/controllers/summarys/shop_controller.rb
+++ b/app/controllers/summarys/shop_controller.rb
@@ -2,7 +2,7 @@ class Summarys::ShopController < SummarysController
def index
@selected_app = summary_params[:selected_app]
@page = params[:page] || 1
- @per_page = params[:per_page] || Summary::Shop::TOP_SHOPS_LIMIT
+ @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"
From 5549357111452e49d900179babe93622aaebc8d9 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 20:44:43 +0000
Subject: [PATCH 06/19] feat: Updated app/views/summarys/index.html.erb
---
app/views/summarys/index.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/summarys/index.html.erb b/app/views/summarys/index.html.erb
index 9b344bd..3cf8cb5 100644
--- a/app/views/summarys/index.html.erb
+++ b/app/views/summarys/index.html.erb
@@ -14,7 +14,7 @@
<%= polaris_card do %>
<%= render controller_name, rows: @summaries %>
<% end %>
- <%= paginate(@summaries.count, @per_page.to_i, @page.to_i, summary_shop_path) %>
+ <%= polaris_pagination(previous_url: summary_shop_path(page: @page.to_i - 1), next_url: summary_shop_path(page: @page.to_i + 1)) %>
<% end %>
From 6da5ac6f40800c14f8145c63cbc5ff93c7d20422 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 20:46:01 +0000
Subject: [PATCH 07/19] feat: Updated app/controllers/summarys/shop_contro
---
app/controllers/summarys/shop_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/summarys/shop_controller.rb b/app/controllers/summarys/shop_controller.rb
index 9550ad0..778f59e 100644
--- a/app/controllers/summarys/shop_controller.rb
+++ b/app/controllers/summarys/shop_controller.rb
@@ -5,6 +5,6 @@ def index
@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"
+ render 'summarys/index'
end
end
From 4d8949d475328b6894015d71bb8cfe21252e7269 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 20:46:53 +0000
Subject: [PATCH 08/19] feat: Updated app/helpers/pagination_helper.rb
---
app/helpers/pagination_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
index a50f46c..e8093e0 100644
--- a/app/helpers/pagination_helper.rb
+++ b/app/helpers/pagination_helper.rb
@@ -11,7 +11,7 @@ def paginate(total_items, items_per_page, current_page, base_url)
pagination_html += '' + link_to('Next', "#{base_url}?page=#{current_page + 1}") + ''
end
- pagination_html += ''
+ pagination_html += ""
pagination_html.html_safe
end
end
From 383ba3d6358923d69f968a52994fd3763e05182b Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 20:47:32 +0000
Subject: [PATCH 09/19] feat: Updated app/controllers/summarys/shop_contro
---
app/controllers/summarys/shop_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/summarys/shop_controller.rb b/app/controllers/summarys/shop_controller.rb
index 778f59e..9550ad0 100644
--- a/app/controllers/summarys/shop_controller.rb
+++ b/app/controllers/summarys/shop_controller.rb
@@ -5,6 +5,6 @@ def index
@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'
+ render "summarys/index"
end
end
From 51029a8776fecce0a42a6b92eaf5c0cf039e884d Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 20:55:07 +0000
Subject: [PATCH 10/19] feat: Updated app/helpers/pagination_helper.rb
---
app/helpers/pagination_helper.rb | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
index e8093e0..7f2d065 100644
--- a/app/helpers/pagination_helper.rb
+++ b/app/helpers/pagination_helper.rb
@@ -1,17 +1,2 @@
-module PaginationHelper
- def paginate(total_items, items_per_page, current_page, base_url)
- total_pages = (total_items.to_f / items_per_page).ceil
- pagination_html = '"
- pagination_html.html_safe
- end
end
From 7d2f4fcbe5c1f0cea172c259565f77eedb8c9c8e Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 21:42:26 +0000
Subject: [PATCH 11/19] Delete app/helpers/pagination_helper.rb
---
app/helpers/pagination_helper.rb | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 app/helpers/pagination_helper.rb
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
deleted file mode 100644
index 7f2d065..0000000
--- a/app/helpers/pagination_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-
-end
From ddc2f19eec40dde44a4a11c286b749ce9e444100 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sat, 3 Feb 2024 22:14:24 +0000
Subject: [PATCH 12/19] feat: Updated app/views/summarys/index.html.erb
---
app/views/summarys/index.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/summarys/index.html.erb b/app/views/summarys/index.html.erb
index 3cf8cb5..c386fd0 100644
--- a/app/views/summarys/index.html.erb
+++ b/app/views/summarys/index.html.erb
@@ -14,7 +14,7 @@
<%= polaris_card do %>
<%= render controller_name, rows: @summaries %>
<% end %>
- <%= polaris_pagination(previous_url: summary_shop_path(page: @page.to_i - 1), next_url: summary_shop_path(page: @page.to_i + 1)) %>
+ <%= 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 %>
From 30e88881981b1a50d897cd4d5d697f2241efcb52 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:08:14 +0000
Subject: [PATCH 13/19] feat: Add controller test for shop summary paginat
---
.../controllers/summarys/shop_controller_test.rb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 test/controllers/summarys/shop_controller_test.rb
diff --git a/test/controllers/summarys/shop_controller_test.rb b/test/controllers/summarys/shop_controller_test.rb
new file mode 100644
index 0000000..fdc664d
--- /dev/null
+++ b/test/controllers/summarys/shop_controller_test.rb
@@ -0,0 +1,16 @@
+require 'test_helper'
+
+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 }
+ assert_response :success
+ assert_equal @summary, assigns(:summaries)
+ end
+end
From 171f49dee093df12cdffce8e2e4b2b87a0b84215 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:09:15 +0000
Subject: [PATCH 14/19] feat: Updated test/controllers/summarys/shop_contr
---
test/controllers/summarys/shop_controller_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/controllers/summarys/shop_controller_test.rb b/test/controllers/summarys/shop_controller_test.rb
index fdc664d..9662fcd 100644
--- a/test/controllers/summarys/shop_controller_test.rb
+++ b/test/controllers/summarys/shop_controller_test.rb
@@ -1,4 +1,4 @@
-require 'test_helper'
+require "test_helper"
class ShopControllerTest < ActionController::TestCase
setup do
From 0168ab2a12fdc1563dcb6e4d559042444ac11e09 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:09:24 +0000
Subject: [PATCH 15/19] feat: Updated test/controllers/summarys/shop_contr
---
test/controllers/summarys/shop_controller_test.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/controllers/summarys/shop_controller_test.rb b/test/controllers/summarys/shop_controller_test.rb
index 9662fcd..8c68e32 100644
--- a/test/controllers/summarys/shop_controller_test.rb
+++ b/test/controllers/summarys/shop_controller_test.rb
@@ -1,4 +1,4 @@
-require "test_helper"
+require 'test_helper'
class ShopControllerTest < ActionController::TestCase
setup do
@@ -9,7 +9,7 @@ class ShopControllerTest < ActionController::TestCase
end
test "index pagination" do
- get :index, params: { selected_app: @selected_app.id, page: 1 }
+ get :index, params: { selected_app: @selected_app.id, page: 1}
assert_response :success
assert_equal @summary, assigns(:summaries)
end
From 64d6c72e3bba0988ccd9d11a4f357ee2f71f8b87 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:09:57 +0000
Subject: [PATCH 16/19] feat: Updated test/controllers/summarys/shop_contr
---
test/controllers/summarys/shop_controller_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/controllers/summarys/shop_controller_test.rb b/test/controllers/summarys/shop_controller_test.rb
index 8c68e32..df36913 100644
--- a/test/controllers/summarys/shop_controller_test.rb
+++ b/test/controllers/summarys/shop_controller_test.rb
@@ -9,7 +9,7 @@ class ShopControllerTest < ActionController::TestCase
end
test "index pagination" do
- get :index, params: { selected_app: @selected_app.id, page: 1}
+ get :index, params: {selected_app: @selected_app.id, page: 1 }
assert_response :success
assert_equal @summary, assigns(:summaries)
end
From 5b525cb7fb1263e2525ef22649aae5097a76a46e Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:10:10 +0000
Subject: [PATCH 17/19] feat: Updated test/controllers/summarys/shop_contr
---
test/controllers/summarys/shop_controller_test.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/controllers/summarys/shop_controller_test.rb b/test/controllers/summarys/shop_controller_test.rb
index df36913..bc45b3e 100644
--- a/test/controllers/summarys/shop_controller_test.rb
+++ b/test/controllers/summarys/shop_controller_test.rb
@@ -9,7 +9,7 @@ class ShopControllerTest < ActionController::TestCase
end
test "index pagination" do
- get :index, params: {selected_app: @selected_app.id, page: 1 }
+ get :index, params: {selected_app: @selected_app.id, page: 1}
assert_response :success
assert_equal @summary, assigns(:summaries)
end
From 9f4eb5a4eea7c3b0fa3ba00683006d5d5c0c0f90 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:10:23 +0000
Subject: [PATCH 18/19] feat: Updated test/controllers/summarys/shop_contr
From 0e136f1977b851440c57ef92bbf2c536a6ea48a0 Mon Sep 17 00:00:00 2001
From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com>
Date: Sun, 4 Feb 2024 14:10:32 +0000
Subject: [PATCH 19/19] feat: Updated test/controllers/summarys/shop_contr