-
Notifications
You must be signed in to change notification settings - Fork 5
/
application.rb
42 lines (32 loc) · 1.15 KB
/
application.rb
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
require 'rubygems'
require 'bundler'
require 'json'
require 'date'
Bundler.require
configure :development do
DataMapper.setup :default, YAML.load(File.new("app/config/database.yml"))[:development]
end
Dir[File.join(File.dirname(__FILE__), 'app/**/*.rb')].sort.each { |f| require f }
DataMapper.finalize
DataMapper.auto_upgrade!
get '/init' do
unless Category.any?
Category.import_from_yaml
10.times { User.generate }
user = User.first
user.plans.create :goal => Goal.get(1)
user.plans.create :goal => Goal.get(2)
user.plans.create :goal => Goal.get(3)
user.plans.create :goal => Goal.get(4)
user.plans.create :goal => Goal.get(5)
today = DateTime.now
user.statistics.create :type => :weight, :date => today, :value => 153
user.statistics.create :type => :weight, :date => today - 7, :value => 160
user.statistics.create :type => :weight, :date => today - 14, :value => 155
user.statistics.create :type => :weight, :date => today - 21, :value => 159
user.statistics.create :type => :weight, :date => today - 28, :value => 165
"Initialised"
else
"Previously initialised"
end
end