-
Notifications
You must be signed in to change notification settings - Fork 13
/
Rakefile
114 lines (97 loc) · 2.49 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require './lib/bothan'
class Random
def location(lat, lng, max_dist_meters)
max_radius = Math.sqrt((max_dist_meters ** 2) / 2.0)
lat_offset = rand(10 ** (Math.log10(max_radius / 1.11)-5))
lng_offset = rand(10 ** (Math.log10(max_radius / 1.11)-5))
lat += [1,-1].sample * lat_offset
lng += [1,-1].sample * lng_offset
lat = [[-90, lat].max, 90].min
lng = [[-180, lng].max, 180].min
[lng, lat]
end
end
desc "Purely for setting up metrics on the demo site"
namespace :demo do
task :setup do
Metric.all.delete
MetricMetadata.all.delete
5.times do |i|
Metric.create(
name: "simple-metric",
time: DateTime.now - i,
value: rand(100)
)
Metric.create(
name: "metric-with-target",
time: DateTime.now - i,
value: {
actual: rand(0..100),
annual_target: rand(100..1000)
}
)
MetricMetadata.create(
name: "metric-with-target",
type: "target"
)
Metric.create(
name: "metric-with-ytd-target",
time: DateTime.now - i,
value: {
actual: rand(0..100),
ytd_target: rand(100..500),
annual_target: rand(500..1000)
}
)
MetricMetadata.create(
name: "metric-with-ytd-target",
type: "target"
)
Metric.create(
name: "metric-with-multiple-values",
time: DateTime.now - i,
value: {
total: {
value1: rand(100),
value2: rand(100),
value3: rand(100),
value4: rand(100),
}
}
)
MetricMetadata.create(
name: "metric-with-multiple-values",
type: "pie"
)
features = []
5.times do |i|
features << {
type: "Feature",
geometry: {
type: "Point",
coordinates: Random.new.location(54.110943,-4.130859, 500000)
}
}
end
Metric.create(
name: "metric-with-geodata",
time: DateTime.now - i,
value: {
type: "FeatureCollection",
features: features
}
)
end
end
end
unless ENV['RACK_ENV'] == 'production'
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
require 'coveralls/rake/task'
Cucumber::Rake::Task.new
RSpec::Core::RakeTask.new
Coveralls::RakeTask.new
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
task :default => [:cucumber, :spec, 'jasmine:ci', 'coveralls:push']
end