-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-items.rb
94 lines (88 loc) · 2.55 KB
/
generate-items.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
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
require 'faker'
FEED_KIND = "SessionSeries"
def generate_session_series(id)
{
"@context": [
"https://openactive.io/",
"https://openactive.io/ns-beta"
],
type: FEED_KIND,
id: "https://example.com/session-series##{id}",
url: "https://example.com/session-series##{id}",
name: Faker::Company.industry,
startDate: Faker::Time.between(from: Time.mktime(2019,12,6), to: Time.mktime(2019,12,7)).iso8601,
endDate: Faker::Time.between(from: Time.mktime(2019,12,7), to: Time.mktime(2019,12,8)).iso8601,
duration: "PT1H30M",
location: {
type: "Place",
id: "https://example.com/place###{Faker::Alphanumeric.alpha(number: 10)}",
name: Faker::Company.name,
address: {
type: "PostalAddress",
streetAddress: Faker::Address.street_address,
addressLocality: Faker::Address.street_name,
addressRegion: Faker::Address.city,
postalCode: Faker::Address.postcode,
addressCountry: Faker::Address.country_code,
}
},
activity: [
{
type: "Concept",
id: "https://example.com/activity-list##{Faker::Alphanumeric.alpha(number: 10)}",
inScheme: "https://openactive.io/activity-list",
prefLabel: Faker::Esport.game,
},
],
eventSchedule: [
{
type: "PartialSchedule",
repeatFrequency: "P7D",
startTime: "20:15:00",
endTime: "20:45:00",
byDay: [
"https://schema.org/Monday",
"https://schema.org/Wednesday",
"https://schema.org/Friday",
],
},
],
organizer: {
type: "Organization",
id: "https://example.com/organization##{Faker::Alphanumeric.alpha(number: 10)}",
name: Faker::Company.name,
},
offers: [
{
type: "Offer",
id: "https://example.com/offer##{Faker::Alphanumeric.alpha(number: 10)}",
price: Faker::Number.between(from: 1, to: 100),
price_currency: Faker::Currency.code,
},
{
type: "Offer",
id: "https://example.com/offer##{Faker::Alphanumeric.alpha(number: 10)}",
price: Faker::Number.between(from: 200, to: 500),
price_currency: Faker::Currency.code,
},
],
}
end
items = 5.times.map do |i|
id = (i+1).to_s
modified = Time.mktime(2019,11,6).to_i + i*60
item = {
id: id,
modified: modified,
kind: FEED_KIND,
}
# mark 1 in 10 as deleted
if i % 10 == 2
item[:state] = "deleted"
else
item[:state] = "updated"
item[:data] = generate_session_series(id)
end
item
end
puts items.to_json