shopify_dashboard_plus 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -16
- data/lib/shopify_dashboard_plus.rb +48 -12
- data/public/css/common.css +3 -0
- data/shopify_dashboard_plus.gemspec +1 -1
- data/views/connect.erb +8 -5
- data/views/report.erb +10 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eec23dd7be2f6961002521056ee0b78c7b16f47
|
4
|
+
data.tar.gz: 9476b25596ca4545fe7700488a54322210408195
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5f93de262d3d3a86f49c12d3d8800e6d398372188b6e565d9f6fbbb2ff65185b9dc61a2cb25726b77b1b036ca12106497d174aed3396d48ae1e849bffce3c0
|
7
|
+
data.tar.gz: 8b1526903f8805beaecbb761dae82156c4eecd9fc200950488e7bc74ae2f96cf6448dc05e2bfb703d6cd5299f23e5dc70bebf4adcb95cf83191f32f116e5a660
|
data/README.md
CHANGED
@@ -1,22 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# Shopify_Dashboard_Plus[](http://badge.fury.io/rb/shopify_dashboard_plus)
|
2
2
|
Pretty Dashboard for Shopify Admin with lots of graphs.
|
3
3
|
|
4
|
-
##
|
5
|
-
|
6
|
-
|
7
|
-
* Assign RWX permissions on `lib/shopify-dashboard-plus.rb`
|
8
|
-
* Retrieve `Key, Password and Shop Name for your store from Shopify Admin
|
9
|
-
* `SHP_KEY="my_key" SHP_PWD="my_password" SHP_NAME="my_shop" ./lib/shopify-dashboard-plus.rb`
|
4
|
+
## Screenshots
|
5
|
+
|
6
|
+

|
10
7
|
|
11
8
|
## Metrics
|
12
9
|
Choose the interval over which to get data and see it displayed as:
|
13
10
|
|
14
|
-
*Currency*
|
15
|
-
* Currencies Used per Purchase
|
16
|
-
|
17
|
-
*Countries*
|
18
|
-
* Proportion of Sales per Country
|
19
|
-
|
20
11
|
*Sales*
|
21
12
|
* Daily Sales
|
22
13
|
* Total Sales
|
@@ -30,6 +21,12 @@ Choose the interval over which to get data and see it displayed as:
|
|
30
21
|
* Number of Items Sold Per Price Point
|
31
22
|
* Revenue per Price Point
|
32
23
|
|
24
|
+
*Countries*
|
25
|
+
* Proportion of Sales per Country
|
26
|
+
|
27
|
+
*Currency*
|
28
|
+
* Currencies Used per Purchase
|
29
|
+
|
33
30
|
*Customers*
|
34
31
|
* Purchases per Customer
|
35
32
|
|
@@ -39,6 +36,19 @@ Choose the interval over which to get data and see it displayed as:
|
|
39
36
|
* Revenue Per Referral Site
|
40
37
|
* Revenue Per Specific Referral Site Page
|
41
38
|
|
42
|
-
##
|
43
|
-
|
44
|
-
*
|
39
|
+
## Usage
|
40
|
+
* To install manually:
|
41
|
+
* `git clone https://github.com/at1as/Shopify_Dashboard_Plus.git`
|
42
|
+
* To install via the gem:
|
43
|
+
* `gem install shopify_dashboard_plus`
|
44
|
+
* Note: Gem build will generally trail the repo by days-to-weeks
|
45
|
+
* For dependencies see:
|
46
|
+
* `shopify_dashboard_plus.gemfile`
|
47
|
+
* Retrieve `API Key`, `Password` and `Shop Name` for your store from Shopify Admin
|
48
|
+
* Run (key, password & name can be passed as environment variables, or later thorugh the UI):
|
49
|
+
* `SHP_KEY="my_key" SHP_PWD="my_password" SHP_NAME="my_shop" ./lib/shopify_dashboard_plus.rb`
|
50
|
+
|
51
|
+
## TODO
|
52
|
+
|
53
|
+
* Not all floats render with a two-digit precision
|
54
|
+
* Limited to 250 results
|
@@ -11,6 +11,8 @@ configure do
|
|
11
11
|
set :views, File.expand_path('../../views', __FILE__)
|
12
12
|
|
13
13
|
$connected ||= false
|
14
|
+
$flash ||= nil
|
15
|
+
$metrics ||= false
|
14
16
|
|
15
17
|
HELP = "Set global environment variables before calling script, or call with ENV variables: \
|
16
18
|
\t\nExample: SHP_KEY=\"<shop_key>\" SHP_PWD=\"<shop_password>\" SHP_NAME=\"<shop_name>\" ./lib/shopify-dashboard.rb\n"
|
@@ -39,7 +41,8 @@ helpers do
|
|
39
41
|
include Rack::Utils
|
40
42
|
alias_method :h, :escape_html
|
41
43
|
|
42
|
-
|
44
|
+
## Connection & Setup Helpers
|
45
|
+
# Bind to Shopify Store
|
43
46
|
def set_connection(key, pwd, name)
|
44
47
|
begin
|
45
48
|
shop_url = "https://#{key}:#{pwd}@#{name}.myshopify.com/admin"
|
@@ -69,7 +72,7 @@ helpers do
|
|
69
72
|
end
|
70
73
|
|
71
74
|
|
72
|
-
|
75
|
+
## Generic Helpers
|
73
76
|
def hash_to_list(unprocessed_hash)
|
74
77
|
return_list = []
|
75
78
|
unprocessed_hash.each do |key, value|
|
@@ -81,8 +84,24 @@ helpers do
|
|
81
84
|
DateTime.now.strftime('%Y-%m-%d')
|
82
85
|
end
|
83
86
|
|
87
|
+
# Validate User Date is valid and start date <= end date
|
88
|
+
def validate_date_range(from, to)
|
89
|
+
interval_start = DateTime.parse(from) rescue nil
|
90
|
+
interval_end = DateTime.parse(to) rescue nil
|
84
91
|
|
85
|
-
|
92
|
+
if interval_start && interval_end
|
93
|
+
if interval_start <= interval_end
|
94
|
+
return true
|
95
|
+
else
|
96
|
+
return false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
false
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
## Metrics Helpers
|
86
105
|
def get_total_revenue(orders)
|
87
106
|
revenue = orders.collect{|order| order.total_price.to_f }.inject(:+).round(2) rescue 0
|
88
107
|
revenue ||= 0
|
@@ -212,17 +231,24 @@ helpers do
|
|
212
231
|
else
|
213
232
|
host = URI(order.referring_site).host.downcase
|
214
233
|
host = host.start_with?('www.') ? host[4..-1] : host
|
215
|
-
|
234
|
+
page = order.referring_site
|
235
|
+
page = page.start_with?('http://') ? page[7..-1] : page
|
236
|
+
page = page.start_with?('https://') ? page[8..-1] : page
|
237
|
+
referring_pages[page] += 1
|
216
238
|
referring_sites[host] += 1
|
217
239
|
end
|
218
240
|
order.line_items.each do |line_item|
|
219
241
|
if order.attributes['referring_site'].empty?
|
220
|
-
revenue_per_referral_page['None'] += line_item.price.to_f
|
221
|
-
revenue_per_referral_site['None'] += line_item.price.to_f
|
242
|
+
revenue_per_referral_page['None'] += line_item.price.to_f.round(2) rescue 0
|
243
|
+
revenue_per_referral_site['None'] += line_item.price.to_f.round(2) rescue 0
|
222
244
|
else
|
223
245
|
host = URI(order.referring_site).host
|
224
|
-
|
225
|
-
|
246
|
+
host = host.start_with?('www.') ? host[4..-1] : host
|
247
|
+
page = order.referring_site
|
248
|
+
page = page.start_with?('http://') ? page[7..-1] : page
|
249
|
+
page = page.start_with?('https://') ? page[8..-1] : page
|
250
|
+
revenue_per_referral_site[host] += line_item.price.to_f.round(2) rescue 0
|
251
|
+
revenue_per_referral_page[page] += line_item.price.to_f.round(2) rescue 0
|
226
252
|
end
|
227
253
|
end
|
228
254
|
end
|
@@ -230,8 +256,8 @@ helpers do
|
|
230
256
|
order.line_items.each do |line_item|
|
231
257
|
products[line_item.title] += 1
|
232
258
|
prices[line_item.price] += 1
|
233
|
-
revenue_per_price_point[line_item.price] += line_item.price.to_f
|
234
|
-
revenue_per_product[line_item.title] += line_item.price.to_f
|
259
|
+
revenue_per_price_point[line_item.price] += line_item.price.to_f.round(2) rescue 0
|
260
|
+
revenue_per_product[line_item.title] += line_item.price.to_f.round(2) rescue 0
|
235
261
|
|
236
262
|
revenue_per_country.push({:name => line_item.title, :data => [order.billing_address.country, line_item.price.to_f]})
|
237
263
|
customer_sales.push({:name => line_item.title, :data => [order.customer.id.to_s, line_item.price.to_f]})
|
@@ -262,6 +288,11 @@ helpers do
|
|
262
288
|
end
|
263
289
|
end
|
264
290
|
|
291
|
+
before do
|
292
|
+
$flash = nil
|
293
|
+
$metrics = false
|
294
|
+
end
|
295
|
+
|
265
296
|
|
266
297
|
get '/' do
|
267
298
|
redirect '/connect' unless connected?
|
@@ -273,7 +304,12 @@ get '/' do
|
|
273
304
|
from = (params[:from] if not params[:from].empty? rescue nil) || (params[:to] if not params[:to].empty? rescue nil) || @today
|
274
305
|
to = (params[:to] if not params[:to].empty? rescue nil) || @today
|
275
306
|
|
276
|
-
|
307
|
+
if validate_date_range(from, to)
|
308
|
+
@metrics = get_detailed_revenue_metrics(from, to)
|
309
|
+
$metrics = true
|
310
|
+
else
|
311
|
+
$flash = "Invalid Dates. Please use format YYYY-MM-DD"
|
312
|
+
end
|
277
313
|
|
278
314
|
erb :report
|
279
315
|
end
|
@@ -288,6 +324,7 @@ post '/connect' do
|
|
288
324
|
if connected?
|
289
325
|
redirect '/'
|
290
326
|
else
|
327
|
+
$flash = "Failed to Connect..."
|
291
328
|
erb :connect
|
292
329
|
end
|
293
330
|
end
|
@@ -308,4 +345,3 @@ after '/quit' do
|
|
308
345
|
puts "\nExiting..."
|
309
346
|
exit!
|
310
347
|
end
|
311
|
-
|
data/public/css/common.css
CHANGED
@@ -8,7 +8,7 @@ require 'date'
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = "shopify_dashboard_plus"
|
10
10
|
spec.date = Date.today.to_s
|
11
|
-
spec.version = "0.0.
|
11
|
+
spec.version = "0.0.3"
|
12
12
|
spec.authors = ["Jason Willems"]
|
13
13
|
spec.email = ["jason@willems.ca"]
|
14
14
|
spec.summary = "Extended dashboard for shopify admin"
|
data/views/connect.erb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
<h2 style="margin-top:10px; margin-bottom:20px">Connect to your Shopify Admin</h2>
|
3
3
|
<hr>
|
4
4
|
<% if not connected? %>
|
5
|
+
<% if $flash %><p class="flash"><%= $flash %><% end %>
|
5
6
|
<form class="form-inline" id="connect" method="post" action="/connect">
|
6
7
|
<div class="form-group">
|
7
8
|
<input id="api_key" name="api_key" class="form-control form-field-small" value="<%= h(params[:api_key]) %>" pattern="^[0-9a-z]*$" placeholder="API_KEY">
|
@@ -9,21 +10,23 @@
|
|
9
10
|
<input id="shop_name" name="shop_name" class="form-control form-field-small" value="<%= h(params[:shop_name]) %>" pattern="^[0-9a-z]*$" placeholder="SHOP NAME">
|
10
11
|
</div>
|
11
12
|
<div class="form-group" style="margin-top:20px">
|
12
|
-
<input type="submit" class="btn btn-primary" value="Set Connection">
|
13
|
+
<input type="submit" class="btn btn-primary" style="width:200px" value="Set Connection">
|
13
14
|
</div>
|
14
15
|
</form>
|
15
16
|
<% else %>
|
16
17
|
<form class="form-inline" id="connect" method="post" action="/disconnect">
|
17
|
-
Currently connected as
|
18
|
-
<
|
18
|
+
Currently connected as <b><%= shop_name %></b><br/>
|
19
|
+
<div style="margin-top:10px">
|
20
|
+
<a href="/">Back to Metrics</a>
|
21
|
+
</div>
|
19
22
|
<div class="form-group" style="display:block; margin-top:20px">
|
20
|
-
<input type="submit" class="btn btn-primary" value="Disconnect">
|
23
|
+
<input type="submit" class="btn btn-primary" style="width:200px" value="Disconnect">
|
21
24
|
</div>
|
22
25
|
</form>
|
23
26
|
<% end %>
|
24
27
|
<form class="form-inline" id="connect" method="post" action="/quit">
|
25
28
|
<div class="form-group" style="display:block; margin-top:20px">
|
26
|
-
<input type="submit" class="btn btn-primary" value="Quit Application">
|
29
|
+
<input type="submit" class="btn btn-primary" style="width:200px" value="Quit Application">
|
27
30
|
</div>
|
28
31
|
</form>
|
29
32
|
</div>
|
data/views/report.erb
CHANGED
@@ -2,21 +2,24 @@
|
|
2
2
|
<div class="well" style="text-align:center; max-width:600px; margin-left:auto; margin-right:auto; margin-top:30px">
|
3
3
|
<h2 style="margin-top:10px; margin-bottom:20px">Shopify Dashboard Plus</h2>
|
4
4
|
<hr>
|
5
|
-
|
6
|
-
|
5
|
+
<% if $flash %><p class="flash"><%= $flash %></p><% end %>
|
6
|
+
<div style="margin-bottom:20px;">
|
7
|
+
Retrieve metrics over the following period <% if shop_name %>for: <br/><i><b><%= shop_name %>.myshopify.com/admin</b></i><% end %>
|
7
8
|
</div>
|
8
9
|
<form class="form-inline" id="set-date" method="get" action="/">
|
9
|
-
<h4>
|
10
|
+
<h4 style="margin-bottom:10px">
|
10
11
|
<input id="from" name="from" class="form-control form-field-small" value="<%= h(params[:from]) %>" pattern="^[1-2][0-9]{3}-[0-3][0-9]-[0-3][0-9]$" placeholder="<%= @today %>">
|
11
12
|
to
|
12
13
|
<input id="to" name="to" class="form-control form-field-small" value="<%= h(params[:to]) %>" pattern="^[1-2][0-9]{3}-[0-3][0-9]-[0-3][0-9]$"% placeholder="<%= @today %>">
|
13
|
-
<input type="submit" class="btn btn-primary" value="Get Data">
|
14
14
|
</h4>
|
15
|
+
<input type="submit" class="btn btn-primary" value="Get Data" style="width:200px">
|
15
16
|
<form>
|
16
|
-
<
|
17
|
+
<div style="margin-top:10px">
|
18
|
+
<a href="/connect">Application Configuration</a>
|
19
|
+
</div>
|
17
20
|
</div>
|
18
21
|
|
19
|
-
|
22
|
+
<% if $metrics %>
|
20
23
|
<h3 class="section-divider">Sales</h3>
|
21
24
|
<div class="graph-container">
|
22
25
|
<div class="graph-border">
|
@@ -125,6 +128,6 @@
|
|
125
128
|
}
|
126
129
|
</script>
|
127
130
|
-->
|
128
|
-
|
131
|
+
<% end %>
|
129
132
|
</div>
|
130
133
|
|