Skip to content

Commit adc4ac9

Browse files
committed
add property percentage_complied to ContentRemovalRequestPeriod
1 parent 17a416e commit adc4ac9

7 files changed

+67
-2
lines changed

app/models/content_removal_request.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class ContentRemovalRequest < ActiveRecord::Base
22
belongs_to :content_removal_request_period
3+
34
has_many :products
45
has_many :reasons
56

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class ContentRemovalRequestPeriod < ActiveRecord::Base
22
has_many :content_removal_requests
3+
has_one :country
34

4-
attr_accessible :period_start, :period_end
5+
attr_accessible :period_start, :period_end, :percentage_complied
56
end

app/models/country.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
class Country < ActiveRecord::Base
22
belongs_to :continent
3+
belongs_to :content_removal_request_period
4+
35
validates_presence_of :code, :name
46
validates_uniqueness_of :code
57

db/migrate/20111109012203_create_content_removal_request_periods.rb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def self.up
44
t.date :period_start
55
t.date :period_end
66
t.integer :country_id
7+
t.float :percentage_complied
78
t.timestamps
89
end
910
end

db/schema.rb

+33-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20111108232726) do
14+
ActiveRecord::Schema.define(:version => 20111109012514) do
1515

1616
create_table "city_maps", :force => true do |t|
1717
t.string "city"
@@ -36,6 +36,26 @@
3636
t.datetime "updated_at"
3737
end
3838

39+
create_table "content_removal_request_periods", :force => true do |t|
40+
t.date "period_start"
41+
t.date "period_end"
42+
t.integer "country_id"
43+
t.float "percentage_complied"
44+
t.datetime "created_at"
45+
t.datetime "updated_at"
46+
end
47+
48+
create_table "content_removal_requests", :force => true do |t|
49+
t.integer "content_removal_request_period_id"
50+
t.integer "product_id"
51+
t.integer "reason_id"
52+
t.integer "courtOrders"
53+
t.integer "executive"
54+
t.integer "items"
55+
t.datetime "created_at"
56+
t.datetime "updated_at"
57+
end
58+
3959
create_table "continents", :force => true do |t|
4060
t.string "code"
4161
t.string "name"
@@ -86,6 +106,18 @@
86106
t.datetime "updated_at"
87107
end
88108

109+
create_table "products", :force => true do |t|
110+
t.string "name"
111+
t.datetime "created_at"
112+
t.datetime "updated_at"
113+
end
114+
115+
create_table "reasons", :force => true do |t|
116+
t.string "name"
117+
t.datetime "created_at"
118+
t.datetime "updated_at"
119+
end
120+
89121
create_table "world_measurements", :force => true do |t|
90122
t.date "month"
91123
t.float "DownloadThroughputSplitByClientAndByServer"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace :load_transparencyreport_data do
2+
require 'csv'
3+
require 'open-uri'
4+
5+
desc "Loading transparencyreport data"
6+
task :load_content_removal_requests => :environment do
7+
#csv_text = File.read('https://www.google.com/transparencyreport/governmentrequests/google-content-removal-requests-by-product-and-reason.csv')
8+
c = CSV.parse(open('https://www.google.com/transparencyreport/governmentrequests/google-content-removal-requests.csv'), :headers => true)
9+
c.each do |r|
10+
period_end = Date.strptime(r[0], '%m/%d/%Y')
11+
e = ContentRemovalRequestPeriod.new(
12+
:period_start => Date.new(period_end.year, period_end.month-5, 1),
13+
:period_end => period_end,
14+
:percentage_complied => r[4]
15+
)
16+
#puts r[2], Country.find_by_code(r[2])
17+
e.country_id = Country.find_by_code(r[2]).id
18+
e.save!
19+
end
20+
end
21+
22+
desc "Run all transparencyreport data tasks"
23+
task :all => [:load_content_removal_requests]
24+
25+
end
26+

test/fixtures/content_removal_request_periods.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ one:
22
period_start: 2011-11-09
33
period_end: 2011-11-09
44
country_id: 1
5+
percentage_complied: 1.5
56

67
two:
78
period_start: 2011-11-09
89
period_end: 2011-11-09
910
country_id: 1
11+
percentage_complied: 1.5

0 commit comments

Comments
 (0)