Active 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/services/IActivity.rb +1 -1
- data/lib/services/activity.rb +217 -83
- data/spec/activity_spec.rb +139 -0
- data/spec/benchmark/search_bench.rb +19 -16
- data/spec/gsa_spec.rb +6 -1
- data/version.txt +1 -1
- metadata +3 -3
data/lib/services/IActivity.rb
CHANGED
@@ -8,7 +8,7 @@ module Active
|
|
8
8
|
attr_accessor
|
9
9
|
|
10
10
|
attr_accessor :title, :url, :categories, :address, :start_date, :start_time, :end_time, :end_date, :category, :desc,
|
11
|
-
:asset_id, :asset_type_id, :data
|
11
|
+
:asset_id, :asset_type_id, :data
|
12
12
|
|
13
13
|
attr_reader :asset_type_id
|
14
14
|
|
data/lib/services/activity.rb
CHANGED
@@ -12,10 +12,16 @@ module Active
|
|
12
12
|
attr_reader :datasources_loaded
|
13
13
|
|
14
14
|
# data is a GSA object
|
15
|
-
def initialize(
|
15
|
+
def initialize(iactivity,preload_data=false)
|
16
16
|
@datasources_loaded=false
|
17
17
|
|
18
|
-
|
18
|
+
if iactivity.source==:gsa
|
19
|
+
@gsa = iactivity
|
20
|
+
elsif iactivity.source==:ats
|
21
|
+
@ats = iactivity
|
22
|
+
else
|
23
|
+
@primary_source = iactivity
|
24
|
+
end
|
19
25
|
|
20
26
|
# if data.respond_to?('source')
|
21
27
|
# @ats = gsa if data.source == :ats
|
@@ -46,18 +52,41 @@ module Active
|
|
46
52
|
|
47
53
|
def ats
|
48
54
|
return @ats if @ats
|
49
|
-
return @ats = ATS.find_by_id(
|
55
|
+
return @ats = ATS.find_by_id(asset_id)
|
56
|
+
end
|
57
|
+
|
58
|
+
def gsa
|
59
|
+
return @gsa if @gsa
|
60
|
+
s = Search.search({:asset_id=>asset_id, :start_date=>"01/01/2000"})
|
61
|
+
if s.results.length > 0
|
62
|
+
@gsa = s.results.first
|
63
|
+
else
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
|
50
67
|
end
|
51
68
|
|
52
69
|
def primary_source
|
53
70
|
return @primary_source if @primary_source
|
54
|
-
if
|
55
|
-
return @primary_source = RegCenter.find_by_id(
|
56
|
-
elsif
|
57
|
-
return @primary_source = ActiveWorks.find_by_id(
|
71
|
+
if asset_type_id == REG_CENTER_ASSET_TYPE_ID || asset_type_id == REG_CENTER_ASSET_TYPE_ID2
|
72
|
+
return @primary_source = RegCenter.find_by_id(substitutionUrl)
|
73
|
+
elsif asset_type_id == ACTIVE_WORKS_ASSET_TYPE_ID
|
74
|
+
return @primary_source = ActiveWorks.find_by_id(substitutionUrl)
|
58
75
|
end
|
59
76
|
end
|
60
77
|
|
78
|
+
def primary_loaded?
|
79
|
+
return true if @primary_source else false
|
80
|
+
end
|
81
|
+
|
82
|
+
def ats_loaded?
|
83
|
+
return true if @ats else false
|
84
|
+
end
|
85
|
+
|
86
|
+
def gsa_loaded?
|
87
|
+
return true if @gsa else false
|
88
|
+
end
|
89
|
+
|
61
90
|
# def load_datasources
|
62
91
|
# return if @datasources_loaded==true
|
63
92
|
#
|
@@ -76,25 +105,26 @@ module Active
|
|
76
105
|
# end
|
77
106
|
|
78
107
|
def title
|
79
|
-
return @
|
108
|
+
return @primary_source.title if primary_loaded?
|
109
|
+
return @ats.title if ats_loaded?
|
110
|
+
return @gsa.title if gsa_loaded?
|
80
111
|
return nil
|
81
112
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
@gsa.asset_id
|
86
|
-
# @asset_id = (value.class==Array) ? value[0] : value
|
113
|
+
|
114
|
+
def _title
|
115
|
+
primary_source.title || ats.title || gsa.title || nil
|
87
116
|
end
|
88
|
-
|
89
|
-
def
|
90
|
-
return @
|
117
|
+
|
118
|
+
def url
|
119
|
+
return @primary_source.url if primary_loaded?
|
120
|
+
return @ats.url if ats_loaded?
|
121
|
+
return @gsa.url if gsa_loaded?
|
91
122
|
return nil
|
92
123
|
end
|
93
124
|
|
94
|
-
def
|
125
|
+
def _url
|
95
126
|
#prefer seo a2 url first, then non seo a2 url, then primary url
|
96
|
-
|
97
|
-
sources = [@ats,@primary,@gsa]
|
127
|
+
sources = [ats,primary_source,gsa]
|
98
128
|
sources.each do |source|
|
99
129
|
return source.url if source.url.downcase.index("www.active.com") && !source.url.downcase.index("detail")
|
100
130
|
end
|
@@ -102,27 +132,162 @@ module Active
|
|
102
132
|
return source.url if source.url.downcase.index("www.active.com")
|
103
133
|
end
|
104
134
|
|
105
|
-
return
|
106
|
-
return
|
107
|
-
return
|
108
|
-
return @url if @url
|
135
|
+
return primary_source.url unless primary_source.nil?
|
136
|
+
return ats.url unless ats.nil?
|
137
|
+
return gsa.url unless gsa.nil?
|
109
138
|
return nil
|
110
139
|
end
|
111
140
|
|
112
141
|
def categories
|
113
|
-
return
|
114
|
-
|
115
|
-
return
|
116
|
-
return
|
117
|
-
|
142
|
+
return primary_source.categories if primary_loaded?
|
143
|
+
return ats.categories if ats_loaded?
|
144
|
+
return gsa.categories if gsa_loaded?
|
145
|
+
return []
|
146
|
+
end
|
147
|
+
|
148
|
+
def _categories
|
149
|
+
return primary_source.categories unless primary_source.nil? || primary_source.categories.length==0
|
150
|
+
return ats.categories unless ats.nil? || ats.categories.length==0
|
151
|
+
return gsa.categories unless gsa.nil? || gsa.categories.length==0
|
118
152
|
return []
|
119
153
|
end
|
120
154
|
|
121
|
-
def
|
122
|
-
return @
|
155
|
+
def address
|
156
|
+
return @primary_source.address if primary_loaded?
|
157
|
+
return @ats.address if ats_loaded?
|
158
|
+
return @gsa.address if gsa_loaded?
|
159
|
+
return nil
|
160
|
+
end
|
161
|
+
|
162
|
+
def _address
|
163
|
+
return primary_source.address unless primary_source.nil? || primary_source.address["address"].nil?
|
164
|
+
return ats.address unless ats.nil? || ats.address["address"].nil?
|
165
|
+
return gsa.address unless gsa.nil? || gsa.address["address"].nil?
|
166
|
+
return nil
|
167
|
+
end
|
168
|
+
|
169
|
+
def start_date
|
170
|
+
return @primary_source.start_date if primary_loaded?
|
171
|
+
return @ats.start_date if ats_loaded?
|
172
|
+
return @gsa.start_date if gsa_loaded?
|
173
|
+
return nil
|
174
|
+
end
|
175
|
+
|
176
|
+
def _start_date
|
177
|
+
return primary_source.start_date unless primary_source.nil? || primary_source.start_date.nil?
|
178
|
+
return ats.start_date unless ats.nil? || ats.start_date.nil?
|
179
|
+
return gsa.start_date unless gsa.nil? || gsa.start_date.nil?
|
180
|
+
return nil
|
181
|
+
end
|
182
|
+
|
183
|
+
def start_time
|
184
|
+
return @primary_source.start_time if primary_loaded?
|
185
|
+
return @ats.start_time if ats_loaded?
|
186
|
+
return @gsa.start_time if gsa_loaded?
|
187
|
+
return nil
|
188
|
+
end
|
189
|
+
|
190
|
+
def _start_time
|
191
|
+
return primary_source.start_time unless primary_source.nil? || primary_source.start_time.nil?
|
192
|
+
return ats.start_time unless ats.nil? || ats.start_time.nil?
|
193
|
+
return gsa.start_time unless gsa.nil? || gsa.start_time.nil?
|
194
|
+
return nil
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
def end_date
|
199
|
+
return @primary_source.end_date if primary_loaded?
|
200
|
+
return @ats.end_date if ats_loaded?
|
201
|
+
return @gsa.end_date if gsa_loaded?
|
202
|
+
return nil
|
203
|
+
end
|
204
|
+
|
205
|
+
def _end_date
|
206
|
+
return primary_source.end_date unless primary_source.nil? || primary_source.end_date.nil?
|
207
|
+
return ats.end_date unless ats.nil? || ats.end_date.nil?
|
208
|
+
return gsa.end_date unless gsa.nil? || gsa.end_date.nil?
|
209
|
+
return nil
|
210
|
+
end
|
211
|
+
|
212
|
+
def end_time
|
213
|
+
return @primary_source.end_time if primary_loaded?
|
214
|
+
return @ats.end_time if ats_loaded?
|
215
|
+
return @gsa.end_time if gsa_loaded?
|
216
|
+
return nil
|
217
|
+
end
|
218
|
+
|
219
|
+
def _end_time
|
220
|
+
return primary_source.end_time unless primary_source.nil? || primary_source.end_time.nil?
|
221
|
+
return ats.end_time unless ats.nil? || ats.end_time.nil?
|
222
|
+
return gsa.end_time unless gsa.nil? || gsa.end_time.nil?
|
223
|
+
return nil
|
224
|
+
end
|
225
|
+
|
226
|
+
def category
|
227
|
+
return @primary_source.category if primary_loaded?
|
228
|
+
return @ats.category if ats_loaded?
|
229
|
+
return @gsa.category if gsa_loaded?
|
230
|
+
return nil
|
231
|
+
end
|
232
|
+
|
233
|
+
def _category
|
234
|
+
return primary_source.category unless primary_source.nil? || primary_source.category.nil?
|
235
|
+
return ats.category unless ats.nil? || ats.category.nil?
|
236
|
+
return gsa.category unless gsa.nil? || gsa.category.nil?
|
123
237
|
return nil
|
124
238
|
end
|
125
239
|
|
240
|
+
def desc
|
241
|
+
return @primary_source.desc if primary_loaded?
|
242
|
+
return @ats.desc if ats_loaded?
|
243
|
+
return @gsa.desc if gsa_loaded?
|
244
|
+
return nil
|
245
|
+
end
|
246
|
+
|
247
|
+
def _desc
|
248
|
+
return primary_source.desc unless primary_source.nil? || primary_source.desc.nil?
|
249
|
+
return ats.desc unless ats.nil? || ats.desc.nil?
|
250
|
+
return gsa.desc unless gsa.nil? || gsa.desc.nil?
|
251
|
+
return nil
|
252
|
+
end
|
253
|
+
|
254
|
+
def asset_id
|
255
|
+
return @primary_source.asset_id if primary_loaded?
|
256
|
+
return @ats.asset_id if ats_loaded?
|
257
|
+
return @gsa.asset_id if gsa_loaded?
|
258
|
+
return nil
|
259
|
+
end
|
260
|
+
|
261
|
+
def _asset_id
|
262
|
+
return primary_source.asset_id unless primary_source.nil? || primary_source.asset_id.nil?
|
263
|
+
return ats.asset_id unless ats.nil? || ats.asset_id.nil?
|
264
|
+
return gsa.asset_id unless gsa.nil? || gsa.asset_id.nil?
|
265
|
+
return nil
|
266
|
+
end
|
267
|
+
|
268
|
+
def asset_type_id
|
269
|
+
return @primary_source.asset_type_id if primary_loaded?
|
270
|
+
return @ats.asset_type_id if ats_loaded?
|
271
|
+
return @gsa.asset_type_id if gsa_loaded?
|
272
|
+
return nil
|
273
|
+
end
|
274
|
+
|
275
|
+
def _asset_type_id
|
276
|
+
return primary_source.asset_type_id unless primary_source.nil? || primary_source.asset_type_id.nil?
|
277
|
+
return ats.asset_type_id unless ats.nil? || ats.asset_type_id.nil?
|
278
|
+
return gsa.asset_type_id unless gsa.nil? || gsa.asset_type_id.nil?
|
279
|
+
return nil
|
280
|
+
end
|
281
|
+
|
282
|
+
# id within a system
|
283
|
+
def asset_id=(value)
|
284
|
+
@gsa.asset_id
|
285
|
+
# @asset_id = (value.class==Array) ? value[0] : value
|
286
|
+
end
|
287
|
+
# The asset type id lets us know what system is came from
|
288
|
+
|
289
|
+
|
290
|
+
|
126
291
|
def primary_category
|
127
292
|
return @primary.primary_category unless @primary.nil?
|
128
293
|
load_datasources
|
@@ -152,8 +317,8 @@ module Active
|
|
152
317
|
# end
|
153
318
|
|
154
319
|
# returns the best address possible from the data returned by the GSA
|
155
|
-
def address
|
156
|
-
@gsa.address
|
320
|
+
#def address
|
321
|
+
# @gsa.address
|
157
322
|
# returned_address = validated_address({})
|
158
323
|
# returned_address = @primary.address unless (@primary.nil? || @primary.address.nil?)
|
159
324
|
# load_datasources
|
@@ -182,7 +347,7 @@ module Active
|
|
182
347
|
# end
|
183
348
|
#
|
184
349
|
# return returned_address
|
185
|
-
end
|
350
|
+
#end
|
186
351
|
# returns the best address possible by loading other data sources
|
187
352
|
# 2. if the primary data source is unknow (ex asset_type_id is unknow ) we will return the GSA address.
|
188
353
|
# 3. if no address but we have lat/lng we'll do a reverse look up
|
@@ -217,7 +382,9 @@ module Active
|
|
217
382
|
end
|
218
383
|
|
219
384
|
def user
|
220
|
-
return @gsa.user
|
385
|
+
return @gsa.user if !@gsa.nil?
|
386
|
+
return @ats.user if !@ats.nil?
|
387
|
+
return @primary.user if !@primary.nil?
|
221
388
|
end
|
222
389
|
|
223
390
|
def _user
|
@@ -231,34 +398,8 @@ module Active
|
|
231
398
|
u
|
232
399
|
end
|
233
400
|
|
234
|
-
def start_date
|
235
|
-
return @gsa.start_date unless @gsa.nil?
|
236
|
-
return nil
|
237
|
-
end
|
238
|
-
|
239
|
-
def start_time
|
240
|
-
return @gsa.start_time unless @gsa.nil?
|
241
|
-
return nil
|
242
|
-
end
|
243
|
-
|
244
|
-
def end_date
|
245
|
-
return @gsa.end_date unless @gsa.nil?
|
246
|
-
return nil
|
247
|
-
end
|
248
401
|
|
249
|
-
def end_time
|
250
|
-
return @gsa.end_time unless @gsa.nil?
|
251
|
-
return nil
|
252
|
-
end
|
253
402
|
|
254
|
-
def category
|
255
|
-
return @primary.category unless @primary.nil?
|
256
|
-
load_datasources
|
257
|
-
return @ats.category unless @ats.nil?
|
258
|
-
return @gsa.category unless @gsa.nil?
|
259
|
-
return @category if @category
|
260
|
-
primary_category
|
261
|
-
end
|
262
403
|
|
263
404
|
def contact_name
|
264
405
|
return @primary.contact_name unless @primary.nil?
|
@@ -278,21 +419,12 @@ module Active
|
|
278
419
|
return nil
|
279
420
|
end
|
280
421
|
|
281
|
-
def desc
|
282
|
-
return @primary.desc unless @primary.nil?
|
283
|
-
load_datasources
|
284
|
-
return @ats.desc unless @ats.nil?
|
285
|
-
return @gsa.desc unless @gsa.nil?
|
286
|
-
return @desc if @desc
|
287
|
-
return nil
|
288
|
-
end
|
289
422
|
|
290
423
|
def substitutionUrl
|
291
|
-
return @
|
292
|
-
|
293
|
-
return @
|
294
|
-
|
295
|
-
return @substitutionUrl if @substitutionUrl
|
424
|
+
return @gsa.substitutionUrl if !@gsa.nil?
|
425
|
+
return @ats.substitutionUrl if !@ats.nil?
|
426
|
+
return @primary.substitutionUrl if !@primary.nil?
|
427
|
+
|
296
428
|
return nil
|
297
429
|
end
|
298
430
|
|
@@ -302,23 +434,25 @@ module Active
|
|
302
434
|
# Activity.find_by_asset_id(:asset_id => "A9EF9D79-F859-4443-A9BB-91E1833DF2D5", :asset_type_id => "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65")
|
303
435
|
# Activity.find_by_asset_id(:asset_id => "A9EF9D79-F859-4443-A9BB-91E1833DF2D5")
|
304
436
|
#
|
305
|
-
def self.
|
306
|
-
|
307
|
-
|
308
|
-
begin
|
309
|
-
return Activity.new(ATS.find_by_id(@asset_id))
|
310
|
-
rescue ATSError => e
|
311
|
-
raise ActivityFindError, "We could not find the activity with the asset_id of #{@asset_id}"
|
312
|
-
end
|
313
|
-
elsif data.has_key?(:substitutionUrl) and data.has_key?(:asset_type_id)
|
437
|
+
def self.find(data)
|
438
|
+
data = HashWithIndifferentAccess.new(data) || HashWithIndifferentAccess.new
|
439
|
+
if data.has_key?(:substitutionUrl) and data.has_key?(:asset_type_id)
|
314
440
|
puts "look up data form the original source"
|
315
441
|
|
316
442
|
if data[:asset_type_id]==REG_CENTER_ASSET_TYPE_ID || data[:asset_type_id]==REG_CENTER_ASSET_TYPE_ID2
|
317
443
|
return Activity.new(RegCenter.find_by_id(data[:substitutionUrl]))
|
318
444
|
elsif data[:asset_type_id]==ACTIVE_WORKS_ASSET_TYPE_ID
|
319
445
|
return Activity.new(ActiveWorks.find_by_id(data[:substitutionUrl]))
|
446
|
+
else
|
447
|
+
return Activity.new(ATS.find_by_id(@asset_id))
|
448
|
+
end
|
449
|
+
elsif data.has_key?(:asset_id)
|
450
|
+
@asset_id = data[:asset_id]
|
451
|
+
begin
|
452
|
+
return Activity.new(ATS.find_by_id(@asset_id))
|
453
|
+
rescue ATSError => e
|
454
|
+
raise ActivityFindError, "We could not find the activity with the asset_id of #{@asset_id}"
|
320
455
|
end
|
321
|
-
|
322
456
|
end
|
323
457
|
raise ActivityFindError, "We could not find the activity with the asset_id of #{@asset_id}"
|
324
458
|
|
data/spec/activity_spec.rb
CHANGED
@@ -134,7 +134,146 @@ describe Activity do
|
|
134
134
|
g.user.email.should eql("eventinfo@sfaf.org")
|
135
135
|
end
|
136
136
|
|
137
|
+
# title
|
138
|
+
it "should have a gsa title" do
|
139
|
+
@a.title.should eql("2011 Rohto Ironman 70.3 California")
|
140
|
+
end
|
141
|
+
it "should have a primary title" do
|
142
|
+
@a.primary_loaded?.should eql(false)
|
143
|
+
@a._title.should eql("2011 Rohto Ironman 70.3 California")
|
144
|
+
@a.primary_loaded?.should eql(true)
|
145
|
+
end
|
146
|
+
it "should have a gsa url" do
|
147
|
+
@a.url.should eql("http://www.active.com/triathlon/oceanside-ca/rohto-ironman-703-california-2011")
|
148
|
+
end
|
149
|
+
it "should have an ats url" do
|
150
|
+
@a.ats_loaded?.should eql(false)
|
151
|
+
@a._url.should eql("http://www.active.com/triathlon/oceanside-ca/rohto-ironman-703-california-2011")
|
152
|
+
@a.ats_loaded?.should eql(true)
|
153
|
+
end
|
154
|
+
it "should have a gsa categories" do
|
155
|
+
@a.categories.should eql(["Triathlon"])
|
156
|
+
end
|
157
|
+
it "should have an primary source categories" do
|
158
|
+
@a.primary_loaded?.should eql(false)
|
159
|
+
@a._categories.should eql(["Triathlon"])
|
160
|
+
@a.primary_loaded?.should eql(true)
|
161
|
+
end
|
162
|
+
it "should have a gsa address" do
|
163
|
+
@a.primary_loaded?.should eql(false)
|
164
|
+
@a.address["address"].should eql("1540 Harbor Drive North")
|
165
|
+
@a.primary_loaded?.should eql(false)
|
166
|
+
end
|
167
|
+
it "should have an primary source address" do
|
168
|
+
@a.primary_loaded?.should eql(false)
|
169
|
+
@a._address["address"].should eql("1540 Harbor Drive North")
|
170
|
+
@a.primary_loaded?.should eql(true)
|
171
|
+
end
|
172
|
+
it "should have a gsa start_date" do
|
173
|
+
@a.primary_loaded?.should eql(false)
|
174
|
+
@a.start_date.should be_an_instance_of(DateTime)
|
175
|
+
@a.primary_loaded?.should eql(false)
|
176
|
+
end
|
177
|
+
it "should have an primary source start_date" do
|
178
|
+
@a.primary_loaded?.should eql(false)
|
179
|
+
@a._start_date.should be_an_instance_of(DateTime)
|
180
|
+
@a.primary_loaded?.should eql(true)
|
181
|
+
end
|
182
|
+
it "should have a gsa start_time" do
|
183
|
+
@a.primary_loaded?.should eql(false)
|
184
|
+
@a.start_time.should be_an_instance_of(DateTime)
|
185
|
+
@a.primary_loaded?.should eql(false)
|
186
|
+
end
|
187
|
+
it "should have an primary source start_time" do
|
188
|
+
@a.primary_loaded?.should eql(false)
|
189
|
+
@a._start_time.should be_an_instance_of(DateTime)
|
190
|
+
@a.primary_loaded?.should eql(true)
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should have a gsa end_date" do
|
194
|
+
@a.primary_loaded?.should eql(false)
|
195
|
+
@a.end_date.should be_an_instance_of(DateTime)
|
196
|
+
@a.primary_loaded?.should eql(false)
|
197
|
+
end
|
198
|
+
it "should have an primary source end_date" do
|
199
|
+
@a.primary_loaded?.should eql(false)
|
200
|
+
@a._end_date.should be_an_instance_of(DateTime)
|
201
|
+
@a.primary_loaded?.should eql(true)
|
202
|
+
end
|
137
203
|
|
204
|
+
it "should have a gsa end_time" do
|
205
|
+
@a.primary_loaded?.should eql(false)
|
206
|
+
@a.end_time.should be_an_instance_of(DateTime)
|
207
|
+
@a.primary_loaded?.should eql(false)
|
208
|
+
end
|
209
|
+
it "should have an primary source end_time" do
|
210
|
+
@a.primary_loaded?.should eql(false)
|
211
|
+
@a._end_time.should be_an_instance_of(DateTime)
|
212
|
+
@a.primary_loaded?.should eql(true)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should have a gsa category" do
|
216
|
+
@a.primary_loaded?.should eql(false)
|
217
|
+
@a.category.should eql("Triathlon")
|
218
|
+
@a.primary_loaded?.should eql(false)
|
219
|
+
end
|
220
|
+
it "should have an ats category" do
|
221
|
+
ats = Activity.new(ATS.find_by_id("77acabbd-ba83-4c78-925d-ce49deddf20c"))
|
222
|
+
ats.gsa_loaded?.should eql(false)
|
223
|
+
ats.category.should eql("Triathlon")
|
224
|
+
ats.primary_loaded?.should eql(false)
|
225
|
+
end
|
226
|
+
it "should have an primary source category" do
|
227
|
+
@a.primary_loaded?.should eql(false)
|
228
|
+
@a._category.should eql("Triathlon")
|
229
|
+
@a.primary_loaded?.should eql(true)
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should have a gsa desc" do
|
233
|
+
@a.primary_loaded?.should eql(false)
|
234
|
+
@a.desc.should eql("")
|
235
|
+
@a.primary_loaded?.should eql(false)
|
236
|
+
end
|
237
|
+
it "should have an primary source desc" do
|
238
|
+
@a.primary_loaded?.should eql(false)
|
239
|
+
@a._desc.should_not eql("")
|
240
|
+
@a.primary_loaded?.should eql(true)
|
241
|
+
end
|
138
242
|
|
243
|
+
it "should have a gsa asset_id" do
|
244
|
+
@a.primary_loaded?.should eql(false)
|
245
|
+
@a.asset_id.should eql("77ACABBD-BA83-4C78-925D-CE49DEDDF20C")
|
246
|
+
@a.primary_loaded?.should eql(false)
|
247
|
+
end
|
248
|
+
it "should have an primary source asset_id" do
|
249
|
+
@a.primary_loaded?.should eql(false)
|
250
|
+
@a._asset_id.should eql("77acabbd-ba83-4c78-925d-ce49deddf20c")
|
251
|
+
@a.primary_loaded?.should eql(true)
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should have a gsa asset_type_id" do
|
255
|
+
@a.primary_loaded?.should eql(false)
|
256
|
+
@a.asset_type_id.should eql("3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6")
|
257
|
+
@a.primary_loaded?.should eql(false)
|
258
|
+
end
|
259
|
+
it "should have an primary source asset_type_id" do
|
260
|
+
@a.primary_loaded?.should eql(false)
|
261
|
+
@a._asset_type_id.should eql("EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65")
|
262
|
+
@a.primary_loaded?.should eql(true)
|
263
|
+
end
|
264
|
+
it "should find by asset_id" do
|
265
|
+
@a = Activity.find({:asset_id=>"3292945B-08DE-41E5-BF6E-95ED5E59E800"})
|
266
|
+
@a.primary_loaded?.should eql(false)
|
267
|
+
@a._asset_type_id.should eql("EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65")
|
268
|
+
@a.primary_loaded?.should eql(true)
|
269
|
+
end
|
270
|
+
it "should find by substitutionUrl and asset_type_id" do
|
271
|
+
@a = Activity.find({:substitutionUrl=>"1877935", :asset_type_id=>"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65"})
|
272
|
+
@a.primary_loaded?.should eql(true)
|
273
|
+
@a.gsa_loaded?.should eql(false)
|
274
|
+
@a.ats_loaded?.should eql(false)
|
275
|
+
@a._url.should eql("http://www.active.com/not-specified-recware-activities/antioch-ca/young-rembrandts-drawing-612-yrs-2010")
|
276
|
+
@a.ats_loaded?.should eql(true)
|
277
|
+
end
|
139
278
|
end
|
140
279
|
end
|
@@ -7,19 +7,22 @@ include Active::Services
|
|
7
7
|
# x.report("array:") { Search.new({:keywords => %w(running swimming yoga)}) }
|
8
8
|
# x.report("Array:") { Search.new({:keywords => ["running","swimming","yoga"]}) }
|
9
9
|
# end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
puts " "
|
22
|
-
puts " "
|
23
|
-
puts " "
|
24
|
-
puts " "
|
25
|
-
puts
|
10
|
+
|
11
|
+
# arr = []
|
12
|
+
# Search.search(:num_results => 100, :page => 1).results.each do |a|
|
13
|
+
# match = (a.user.email == a.ats.contact_email)
|
14
|
+
# email = "--"
|
15
|
+
# if a.primary_source
|
16
|
+
# email = a.primary_source.user.email
|
17
|
+
# end
|
18
|
+
# arr << "#{a.asset_id}"
|
19
|
+
# arr << " GSA= #{a.user.email} ATS= #{a.ats.user.email} #{a.primary_source}=> #{email} "
|
20
|
+
# end
|
21
|
+
# puts " "
|
22
|
+
# puts " "
|
23
|
+
# puts " "
|
24
|
+
# puts " "
|
25
|
+
# puts " "
|
26
|
+
# puts arr
|
27
|
+
|
28
|
+
puts Search.search(:asset_id => "FBF1EF76-B8BF-427A-85DD-D310DB9E075D")
|
data/spec/gsa_spec.rb
CHANGED
@@ -181,7 +181,12 @@ describe GSA do
|
|
181
181
|
g.user.first_name.should eql("City")
|
182
182
|
g.user.last_name.should eql("of San Diego")
|
183
183
|
end
|
184
|
-
|
184
|
+
it "should have a valid first and last name" do
|
185
|
+
g = GSA.new(JSON.parse('{"escapedUrl":"http://www.active.com/running/san-ramon-ca/primos-run-for-education-2010","language":"en","title":"Primo\u0026#39;s Run for Education | San Ramon, California 94568 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/san-ramon-ca/primos-run-for-education-2010","summary":"Active partnered with ESPN. United States. United Kingdom Ireland France\u003cbr\u003e Italy Spain Sweden Germany Portugal Netherlands Austria Australia \u003cb\u003e...\u003c/b\u003e ","meta":{"startDate":"2010-10-11","eventDate":"2010-10-11T00:00:00-07:00","location":"Iron Horse School","tag":["event:10","Running:10"],"state":"California","eventLongitude":"-121.9074859","endDate":"2010-10-11","lastModifiedDateTime":"2010-10-12 10:16:46.88","splitMediaType":["Event","5K","Half Marathon","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"locationName":"Iron Horse School","endTime":"0:00:00","mediaType":["Event","Event\\5K","Event\\Half Marathon","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"city":"San Ramon","google-site-verification":"","estParticipants":"10000","startTime":"0:00:00","assetId":["FBF1EF76-B8BF-427A-85DD-D310DB9E075D","fbf1ef76-b8bf-427a-85dd-d310db9e075d"],"eventId":"1899115","participationCriteria":"Family","description":"","longitude":"-121.9074859","onlineDonationAvailable":"0","substitutionUrl":"1899115","assetName":["Primo\'s Run for Education","Primo\'s Run for Education"],"zip":"94568","contactPhone":"925-875-0405","sortDate":"2000-10-11","eventState":"California","eventLatitude":"37.7130380","keywords":"Event","eventResults":"http://results.active.com/pages/page.jsp?eventID\u003d1899115\u0026pubID\u003d3","contactEmail":"buzz@bwp.com","onlineMembershipAvailable":"0","dma":"San Francisco - Oakland - San Jose","trackbackurl":"http://www.active.com/running/san-ramon-ca/primos-run-for-education-2010","seourl":"http://www.active.com/running/san-ramon-ca/primos-run-for-education-2010","country":"United States","onlineRegistrationAvailable":"false","category":"Activities","market":"San Francisco - Oakland - San Jose","contactName":"Buzz Ayola# (ED_Use this one)","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-10-12","eventZip":"94568","UpdateDateTime":"9/22/2010 11:46:24 AM","latitude":"37.7130380","channel":"Running"}}'))
|
186
|
+
g.user.first_name.should eql("Buzz")
|
187
|
+
g.user.last_name.should eql("Ayola")
|
188
|
+
g.title.should eql("Primo's Run for Education")
|
189
|
+
end
|
185
190
|
it "should pull primary category from seo url" do
|
186
191
|
g = GSA.new(JSON.parse('{"escapedUrl":"http://www.active.com/cycling/san-francisco-ca/seismic-challenge-30-2010","language":"en","title":"Seismic Challenge 3.0 | San Francisco, California 94101 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/cycling/san-francisco-ca/seismic-challenge-30-2010","summary":"","meta":{"startDate":"2010-10-02","eventDate":"2010-10-02T00:00:00-07:00","location":"San Francisco Bay","tag":"event:10","state":"California","eventLongitude":"-122.42","endDate":"2010-10-03","lastModifiedDateTime":"2010-10-04 03:08:51.65","splitMediaType":"Event","locationName":"San Francisco Bay","endTime":"0:00:00","mediaType":"Event","city":"San Francisco","google-site-verification":"","estParticipants":"2000","startTime":"0:00:00","assetId":["35A99FCB-E238-4D78-9205-96179F827CB0","35a99fcb-e238-4d78-9205-96179f827cb0"],"eventId":"1883181","participationCriteria":"All","description":"","longitude":"-122.42","onlineDonationAvailable":"0","substitutionUrl":"1883181","assetName":["Seismic Challenge 3.0","Seismic Challenge 3.0"],"eventURL":"http://greaterthanone.org/events/seismic-challenge/","zip":"94101","contactPhone":"415-487-3053","sortDate":"2000-10-02","eventState":"California","eventLatitude":"37.78","keywords":"Event","contactEmail":"eventinfo@sfaf.org","onlineMembershipAvailable":"0","dma":"San Francisco - Oakland - San Jose","trackbackurl":"http://www.active.com/cycling/san-francisco-ca/seismic-challenge-30-2010","seourl":"http://www.active.com/cycling/san-francisco-ca/seismic-challenge-30-2010","country":"United States","onlineRegistrationAvailable":"false","category":"Activities","market":"San Francisco - Oakland - San Jose","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-10-04","eventZip":"94101","UpdateDateTime":"9/22/2010 11:46:24 AM","latitude":"37.78","channel":"Running,Cycling"}}'))
|
187
192
|
g.primary_category.should eql("Cycling")
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.25
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 25
|
9
|
+
version: 0.0.25
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jonathan Spooner, Brian Levine
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-12 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|