Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Seed data

  • Loading branch information...
commit 24cdfdf25eac2f43ca3187e6d7c584b9aa52326a 1 parent 184f552
Artem Melnikov authored

Showing 3 changed files with 44 additions and 3 deletions. Show diff stats Hide diff stats

  1. +6 2 ctracker.org
  2. +33 1 db/seeds.rb
  3. +5 0 lib/tasks/load.rake
8 ctracker.org
Source Rendered
... ... @@ -1,10 +1,10 @@
1 1 #+STARTUP: showall
2 2 #+BEGIN: clocktable :maxlevel 2 :scope file
3   -Clock summary at [2012-10-25 Thu 11:17]
  3 +Clock summary at [2012-10-25 Thu 12:08]
4 4
5 5 | Headline | Time |
6 6 |----------------------------------------------------------------------------------+---------|
7   -| *Total time* | *18:22* |
  7 +| *Total time* | *19:06* |
8 8 |----------------------------------------------------------------------------------+---------|
9 9 | DONE Setup. Understand the task. Read existed code. | 0:37 |
10 10 | DONE Rake task | 0:07 |
@@ -31,6 +31,7 @@ Clock summary at [2012-10-25 Thu 11:17]
31 31 | DONE Add apply controll | 0:14 |
32 32 | DONE Progress chart | 2:15 |
33 33 | DONE Rewrite from hbtm to has_many | 1:52 |
  34 +| DONE Create seed data | 0:44 |
34 35 #+END:
35 36 #+STARTUP: hidestars
36 37 #+STARTUP: logdone
@@ -123,3 +124,6 @@ Clock summary at [2012-10-25 Thu 11:17]
123 124 * DONE Rewrite from hbtm to has_many
124 125 CLOSED: [2012-10-25 Thu 02:21]
125 126 CLOCK: [2012-10-25 Thu 00:29]--[2012-10-25 Thu 02:21] => 1:52
  127 +* DONE Create seed data
  128 + CLOSED: [2012-10-25 Thu 12:08]
  129 + CLOCK: [2012-10-25 Thu 11:24]--[2012-10-25 Thu 12:08] => 0:44
34 db/seeds.rb
@@ -6,9 +6,41 @@
6 6 # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7 7 # Mayor.create(:name => 'Daley', :city => cities.first)
8 8
9   -User.find_or_create_by_email("user1@example.com", :password => "Password123!")
  9 +user1 = User.find_or_create_by_email("user1@example.com", :password => "Password123!")
10 10 puts """
11 11 You could login as user1
12 12 email: user1@example.com
13 13 password: Password123!
  14 +---------------------------
14 15 """
  16 +
  17 +user2 = User.find_or_create_by_email("user2@example.com", :password => "Password123!")
  18 +puts """
  19 +You could login as user2
  20 +email: user2@example.com
  21 +password: Password123!
  22 +---------------------------
  23 +"""
  24 +
  25 +countries = Country.where("code in (?)", ["af", "ar", "gb", "an", "ht", "mt", "vu"])
  26 +
  27 +countries.each do |country|
  28 + user1.toggle_visiting(country)
  29 +end
  30 +
  31 +puts "-- Faking data"
  32 +start_time = Date.today - 8.days
  33 +ucs = UserCountry.where(:user_id => user1.id).all
  34 +1.upto(7) do |t|
  35 + date = start_time + t.days
  36 + uc = ucs.shift()
  37 + uc.update_attributes({:created_at, date, :updated_at, date})
  38 +
  39 +
  40 + uc.country.currencies.map do |c|
  41 + UserCurrency.where(:user_id => user1.id, :currency_code => c.code).map do |c|
  42 + c.update_attributes({:created_at, date, :updated_at, date})
  43 + end
  44 + end
  45 +end
  46 +puts "-- Done"
5 lib/tasks/load.rake
... ... @@ -1,6 +1,11 @@
1 1 namespace :ctracker do
2 2 desc "Load countries and currencies"
3 3 task :load => :environment do
  4 + puts "-- Loading Currencies and Countries"
4 5 DataUpdater.instance.update
5 6 end
6 7 end
  8 +
  9 +namespace :db do
  10 + task :seed => ["ctracker:load"]
  11 +end

0 comments on commit 24cdfdf

Please sign in to comment.
Something went wrong with that request. Please try again.