workarea-wish_lists 3.0.5 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.json +35 -0
- data/.github/workflows/ci.yml +60 -0
- data/.rubocop.yml +3 -0
- data/.stylelintrc.json +8 -0
- data/CHANGELOG.md +0 -51
- data/Gemfile +3 -2
- data/Rakefile +5 -4
- data/app/assets/javascripts/workarea/storefront/wish_lists/modules/wish_list_analytics.js +31 -0
- data/app/controllers/workarea/admin/reports_controller.decorator +10 -0
- data/app/controllers/workarea/storefront/analytics_controller.decorator +17 -0
- data/app/controllers/workarea/storefront/users/wish_lists_controller.rb +7 -6
- data/app/helpers/workarea/storefront/wish_list_analytics_helper.rb +21 -0
- data/app/models/workarea/insights/most_wish_listed_products.rb +32 -0
- data/app/models/workarea/metrics/product_by_day.decorator +10 -0
- data/app/models/workarea/wish_list.rb +1 -2
- data/app/models/workarea/wish_list/item.rb +1 -2
- data/app/queries/workarea/order_metrics.decorator +24 -0
- data/app/queries/workarea/reports/wish_list_products.rb +51 -0
- data/app/seeds/workarea/wish_list_seeds.rb +11 -0
- data/app/services/workarea/wish_list_session.rb +11 -11
- data/app/view_models/workarea/admin/dashboards/reports_view_model.decorator +10 -0
- data/app/view_models/workarea/admin/reports/wish_list_products_view_model.rb +20 -0
- data/app/views/workarea/admin/dashboards/_wish_list_products_card.html.haml +17 -0
- data/app/views/workarea/admin/insights/_most_wish_listed_products.html.haml +22 -0
- data/app/views/workarea/admin/reports/wish_list_products.html.haml +38 -0
- data/app/views/workarea/storefront/carts/_move_to_wish_list.html.haml +1 -1
- data/app/views/workarea/storefront/pages/_wish_lists_robots.text.erb +1 -0
- data/app/views/workarea/storefront/products/_add_to_wish_list.html.haml +1 -1
- data/app/views/workarea/storefront/users/accounts/_wish_list_summary.html.haml +3 -1
- data/app/views/workarea/storefront/users/wish_lists/show.html.haml +9 -4
- data/app/views/workarea/storefront/wish_lists/show.html.haml +8 -3
- data/app/workers/workarea/save_order_metrics.decorator +21 -0
- data/config/initializers/append_points.rb +12 -1
- data/config/locales/en.yml +20 -0
- data/config/routes.rb +7 -0
- data/lib/workarea/wish_lists/engine.rb +6 -0
- data/lib/workarea/wish_lists/version.rb +1 -1
- data/package.json +9 -0
- data/test/dummy/config/initializers/session_store.rb +3 -1
- data/test/integration/workarea/storefront/wish_lists_integration_test.rb +2 -2
- data/test/models/workarea/insights/most_wish_listed_products_test.rb +63 -0
- data/test/queries/workarea/reports/wish_list_products_test.rb +122 -0
- data/test/queries/workarea/wish_list_order_metrics_test.rb +49 -0
- data/test/system/workarea/admin/wish_list_products_report_system_test.rb +44 -0
- data/test/system/workarea/storefront/wish_list_analytics_system_test.rb +75 -0
- data/test/view_models/workarea/storefront/{wish_list_user_view_model_test.rb → user_view_model_test.rb} +0 -0
- data/workarea-wish_lists.gemspec +4 -4
- metadata +35 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a060b4ac8c812642c3468a8c04bf2d41d350bf82129d80bc23e80fc8a7f1076
|
4
|
+
data.tar.gz: d0e73f8423e4e6d9ba3977ea33329778cbea295cea8485933a2ec2ed625cade0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86bcf3cf9b45407591b95c8827edb4f6bc748f20e81501dab7ffb08642b2456a6e606b881fa6d6e89e36d6f5236ae5bd845bd4046a48766d484aa65ae12e5771
|
7
|
+
data.tar.gz: 5c9e81aa4102e7beea127fb4c0606316a07bd1db7eba1e8f982dc513dee1d59dc442de3acc902067b5aee62ce5befc429155375fa9f0fffdc0af69dd8f2a1262
|
data/.eslintrc.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"extends": "eslint:recommended",
|
3
|
+
"rules": {
|
4
|
+
"semi": ["error", "always"],
|
5
|
+
"eqeqeq": ["error", "always"]
|
6
|
+
},
|
7
|
+
"globals": {
|
8
|
+
"window": true,
|
9
|
+
"document": true,
|
10
|
+
"WORKAREA": true,
|
11
|
+
"$": true,
|
12
|
+
"jQuery": true,
|
13
|
+
"_": true,
|
14
|
+
"feature": true,
|
15
|
+
"JST": true,
|
16
|
+
"Turbolinks": true,
|
17
|
+
"I18n": true,
|
18
|
+
"Chart": true,
|
19
|
+
"Dropzone": true,
|
20
|
+
"strftime": true,
|
21
|
+
"Waypoint": true,
|
22
|
+
"wysihtml": true,
|
23
|
+
"LocalTime": true,
|
24
|
+
"describe": true,
|
25
|
+
"after": true,
|
26
|
+
"afterEach": true,
|
27
|
+
"before": true,
|
28
|
+
"beforeEach": true,
|
29
|
+
"it": true,
|
30
|
+
"expect": true,
|
31
|
+
"sinon": true,
|
32
|
+
"fixture": true,
|
33
|
+
"chai": true
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
static_analysis:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v1
|
9
|
+
- uses: workarea-commerce/ci/bundler-audit@v1
|
10
|
+
- uses: workarea-commerce/ci/rubocop@v1
|
11
|
+
- uses: workarea-commerce/ci/eslint@v1
|
12
|
+
with:
|
13
|
+
args: '**/*.js'
|
14
|
+
- uses: workarea-commerce/ci/stylelint@v1
|
15
|
+
with:
|
16
|
+
args: '**/*.scss'
|
17
|
+
|
18
|
+
admin_tests:
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v1
|
22
|
+
- uses: actions/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: 2.6.x
|
25
|
+
- uses: workarea-commerce/ci/test@v1
|
26
|
+
with:
|
27
|
+
command: bin/rails app:workarea:test:admin
|
28
|
+
|
29
|
+
core_tests:
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
steps:
|
32
|
+
- uses: actions/checkout@v1
|
33
|
+
- uses: actions/setup-ruby@v1
|
34
|
+
with:
|
35
|
+
ruby-version: 2.6.x
|
36
|
+
- uses: workarea-commerce/ci/test@v1
|
37
|
+
with:
|
38
|
+
command: bin/rails app:workarea:test:core
|
39
|
+
|
40
|
+
storefront_tests:
|
41
|
+
runs-on: ubuntu-latest
|
42
|
+
steps:
|
43
|
+
- uses: actions/checkout@v1
|
44
|
+
- uses: actions/setup-ruby@v1
|
45
|
+
with:
|
46
|
+
ruby-version: 2.6.x
|
47
|
+
- uses: workarea-commerce/ci/test@v1
|
48
|
+
with:
|
49
|
+
command: bin/rails app:workarea:test:storefront
|
50
|
+
|
51
|
+
plugins_tests:
|
52
|
+
runs-on: ubuntu-latest
|
53
|
+
steps:
|
54
|
+
- uses: actions/checkout@v1
|
55
|
+
- uses: actions/setup-ruby@v1
|
56
|
+
with:
|
57
|
+
ruby-version: 2.6.x
|
58
|
+
- uses: workarea-commerce/ci/test@v1
|
59
|
+
with:
|
60
|
+
command: bin/rails app:workarea:test:plugins
|
data/.rubocop.yml
ADDED
data/.stylelintrc.json
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,54 +1,3 @@
|
|
1
|
-
Workarea Wish Lists 3.0.5 (2020-10-22)
|
2
|
-
--------------------------------------------------------------------------------
|
3
|
-
|
4
|
-
* Fix typo to filename for WishListUserViewModelTest
|
5
|
-
|
6
|
-
|
7
|
-
Basia
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Workarea Wish Lists 3.0.4 (2019-08-21)
|
12
|
-
--------------------------------------------------------------------------------
|
13
|
-
|
14
|
-
* Open Source!
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Workarea Wish Lists 3.0.3 (2019-06-11)
|
19
|
-
--------------------------------------------------------------------------------
|
20
|
-
|
21
|
-
* Improve Empty Wish List Copy Text
|
22
|
-
|
23
|
-
Change the copy text for when a wish list is empty to indicate whether
|
24
|
-
the items in the wish list are purchased or not purchased yet.
|
25
|
-
|
26
|
-
WISHLISTS-88
|
27
|
-
Tom Scott
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
Workarea Wish Lists 3.0.2 (2019-04-30)
|
32
|
-
--------------------------------------------------------------------------------
|
33
|
-
|
34
|
-
* Move utility nav link partial to a better location
|
35
|
-
|
36
|
-
The `_wish_lists_link.html.haml` partial was stored in
|
37
|
-
`app/views/layouts` which causes it to not be skipped or overridden in
|
38
|
-
the expected way. This commit duplicates the file into
|
39
|
-
`app/views/workarea/storefront/wish_lists` to avoid developer confusion
|
40
|
-
and to allow it to be skipped by normal means.
|
41
|
-
|
42
|
-
The previous file remains in place in order to not cause issues for
|
43
|
-
applications that include this plugin, but will now fire off a
|
44
|
-
deprecation warning, prompting developers to update the path themselves
|
45
|
-
in their app.
|
46
|
-
|
47
|
-
WISHLISTS-127
|
48
|
-
Curt Howard
|
49
|
-
|
50
|
-
|
51
|
-
|
52
1
|
Workarea Wish Lists 3.0.1 (2019-04-16)
|
53
2
|
--------------------------------------------------------------------------------
|
54
3
|
|
data/Gemfile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
git_source(:github) { |repo| "
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'workarea', '>= 3.
|
6
|
+
# gem 'workarea', '>= 3.4.0'
|
7
|
+
gem 'workarea', github: 'workarea-commerce/workarea'
|
data/Rakefile
CHANGED
@@ -38,12 +38,13 @@ desc "Release version #{Workarea::WishLists::VERSION} of the gem"
|
|
38
38
|
task :release do
|
39
39
|
host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
|
40
40
|
|
41
|
-
Rake::Task['workarea:changelog'].execute
|
42
|
-
system 'git add CHANGELOG.md'
|
43
|
-
system 'git commit -m "Update CHANGELOG"'
|
41
|
+
#Rake::Task['workarea:changelog'].execute
|
42
|
+
#system 'git add CHANGELOG.md'
|
43
|
+
#system 'git commit -m "Update CHANGELOG"'
|
44
|
+
#system 'git push origin HEAD'
|
44
45
|
|
45
46
|
system "git tag -a v#{Workarea::WishLists::VERSION} -m 'Tagging #{Workarea::WishLists::VERSION}'"
|
46
|
-
system 'git push
|
47
|
+
system 'git push --tags'
|
47
48
|
|
48
49
|
system 'gem build workarea-wish_lists.gemspec'
|
49
50
|
system "gem push workarea-wish_lists-#{Workarea::WishLists::VERSION}.gem"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/**
|
2
|
+
* @method
|
3
|
+
* @name registerAdapter
|
4
|
+
* @memberof WORKAREA.analytics
|
5
|
+
*/
|
6
|
+
WORKAREA.analytics.registerAdapter('wish_lists', function () {
|
7
|
+
'use strict';
|
8
|
+
|
9
|
+
return {
|
10
|
+
'addToWishList': function (payload) {
|
11
|
+
if (payload.id) {
|
12
|
+
$.ajax({
|
13
|
+
type: 'POST',
|
14
|
+
url: WORKAREA.routes.storefront.analyticsWishListAddPath(
|
15
|
+
{ product_id: payload.id }
|
16
|
+
),
|
17
|
+
});
|
18
|
+
}
|
19
|
+
},
|
20
|
+
'removeFromWishList': function (payload) {
|
21
|
+
if (payload.id) {
|
22
|
+
$.ajax({
|
23
|
+
type: 'POST',
|
24
|
+
url: WORKAREA.routes.storefront.analyticsWishListRemovePath(
|
25
|
+
{ product_id: payload.id }
|
26
|
+
),
|
27
|
+
});
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
31
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Storefront::AnalyticsController, with: :wish_lists do
|
3
|
+
def wish_list_add
|
4
|
+
Metrics::ProductByDay.inc(
|
5
|
+
key: { product_id: params[:product_id] },
|
6
|
+
wish_list_adds: 1
|
7
|
+
)
|
8
|
+
end
|
9
|
+
|
10
|
+
def wish_list_remove
|
11
|
+
Metrics::ProductByDay.inc(
|
12
|
+
key: { product_id: params[:product_id] },
|
13
|
+
wish_list_deletes: 1
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -70,8 +70,9 @@ module Workarea
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def require_login_and_redirect
|
73
|
-
|
74
|
-
|
73
|
+
result = require_login
|
74
|
+
remember_location(users_wish_list_path) if result == false
|
75
|
+
result
|
75
76
|
end
|
76
77
|
|
77
78
|
def current_wish_list
|
@@ -88,18 +89,18 @@ module Workarea
|
|
88
89
|
end
|
89
90
|
|
90
91
|
def add_item_from_session
|
91
|
-
item_id =
|
92
|
+
item_id = cookies[:wish_list_item_id]
|
92
93
|
|
93
94
|
wish_list_session.add_item(current_wish_list)
|
94
|
-
current_order.remove_item(item_id) if item_id.present?
|
95
|
+
current_order.remove_item(item_id) if current_order.items.where(id: item_id).present?
|
95
96
|
end
|
96
97
|
|
97
98
|
def wish_list_session
|
98
|
-
WishListSession.new(
|
99
|
+
WishListSession.new(cookies)
|
99
100
|
end
|
100
101
|
|
101
102
|
def item_stored_in_session?
|
102
|
-
|
103
|
+
cookies.key?(:wish_list_product_id)
|
103
104
|
end
|
104
105
|
|
105
106
|
def customizations
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Storefront
|
3
|
+
module WishListAnalyticsHelper
|
4
|
+
def add_to_wish_list_analytics_data(product)
|
5
|
+
{
|
6
|
+
event: 'addToWishList',
|
7
|
+
domEvent: 'click',
|
8
|
+
payload: product_analytics_data(product)
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def remove_from_wish_list_analytics_data(product)
|
13
|
+
{
|
14
|
+
event: 'removeFromWishList',
|
15
|
+
domEvent: 'submit',
|
16
|
+
payload: product_analytics_data(product)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Insights
|
3
|
+
class MostWishListedProducts < Base
|
4
|
+
class << self
|
5
|
+
def dashboards
|
6
|
+
%w(catalog)
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate_monthly!
|
10
|
+
results = generate_results
|
11
|
+
create!(results: results) if results.present?
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_results
|
15
|
+
report
|
16
|
+
.results
|
17
|
+
.take(Workarea.config.insights_products_list_max_results)
|
18
|
+
.map { |result| result.merge(product_id: result['_id']) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def report
|
22
|
+
Reports::WishListProducts.new(
|
23
|
+
starts_at: beginning_of_last_month,
|
24
|
+
ends_at: end_of_last_month,
|
25
|
+
sort_by: 'adds',
|
26
|
+
sort_direction: 'desc'
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Metrics::ProductByDay, with: :wish_lists do
|
3
|
+
decorated do
|
4
|
+
field :wish_list_adds, type: Integer, default: 0
|
5
|
+
field :wish_list_deletes, type: Integer, default: 0
|
6
|
+
field :wish_list_units_sold, type: Integer, default: 0
|
7
|
+
field :wish_list_revenue, type: Float, default: 0.0
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate OrderMetrics, with: :wish_lists do
|
3
|
+
def products_from_wish_lists
|
4
|
+
@products_from_wish_lists ||=
|
5
|
+
wish_list_items
|
6
|
+
.group_by(&:product_id)
|
7
|
+
.transform_values do |items|
|
8
|
+
values = calculate_based_on_items(items)
|
9
|
+
|
10
|
+
{
|
11
|
+
wish_list_units_sold: values[:units_sold],
|
12
|
+
wish_list_revenue: values[:revenue]
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def wish_list_items
|
18
|
+
@wish_list_items ||= items.select do |item|
|
19
|
+
via = GlobalID.parse(item.via)
|
20
|
+
via.present? && via.model_class.name == 'Workarea::WishList'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Reports
|
3
|
+
class WishListProducts
|
4
|
+
include Report
|
5
|
+
|
6
|
+
self.reporting_class = Metrics::ProductByDay
|
7
|
+
self.sort_fields = %w(revenue units_sold adds deletes)
|
8
|
+
|
9
|
+
def aggregation
|
10
|
+
[filter_results, project_used_fields, group_by_product]
|
11
|
+
end
|
12
|
+
|
13
|
+
def filter_results
|
14
|
+
{
|
15
|
+
'$match' => {
|
16
|
+
'reporting_on' => { '$gte' => starts_at, '$lte' => ends_at },
|
17
|
+
'$or' => [
|
18
|
+
{ 'wish_list_adds' => { '$gt' => 0 } },
|
19
|
+
{ 'wish_list_deletes' => { '$gt' => 0 } },
|
20
|
+
{ 'wish_list_units_sold' => { '$gt' => 0 } }
|
21
|
+
]
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def project_used_fields
|
27
|
+
{
|
28
|
+
'$project' => {
|
29
|
+
'product_id' => 1,
|
30
|
+
'wish_list_units_sold' => 1,
|
31
|
+
'wish_list_adds' => 1,
|
32
|
+
'wish_list_deletes' => 1,
|
33
|
+
'wish_list_revenue' => 1
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def group_by_product
|
39
|
+
{
|
40
|
+
'$group' => {
|
41
|
+
'_id' => '$product_id',
|
42
|
+
'units_sold' => { '$sum' => '$wish_list_units_sold' },
|
43
|
+
'adds' => { '$sum' => '$wish_list_adds' },
|
44
|
+
'deletes' => { '$sum' => '$wish_list_deletes' },
|
45
|
+
'revenue' => { '$sum' => '$wish_list_revenue' }
|
46
|
+
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|