Active 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,12 +30,12 @@ module Active
30
30
 
31
31
  class Search
32
32
  attr_accessor :api_key, :start_date, :end_date, :location, :channels, :keywords, :search, :radius, :limit, :sort, :page, :offset,
33
- :view, :facet, :sort, :num_results
33
+ :view, :facet, :sort, :num_results, :asset_ids
34
34
 
35
35
  attr_reader :results, :endIndex, :pageSize, :searchTime, :numberOfResults, :end_point, :meta
36
36
 
37
37
  SEARCH_URL = "http://search.active.com"
38
- DEFAULT_TIMEOUT = 5
38
+ DEFAULT_TIMEOUT = 60
39
39
 
40
40
  def initialize(data={})
41
41
  self.api_key = data[:api_key] || ""
@@ -52,9 +52,10 @@ module Active
52
52
  self.num_results = data[:num_results] || "10"
53
53
  self.search = data[:search] || ""
54
54
  self.start_date = data[:start_date] || "today"
55
- self.end_date = data[:end_date] || "+"
55
+ self.end_date = data[:end_date] || "+"
56
+ self.asset_ids = data[:asset_ids] || []
57
+ self.asset_id = data[:asset_id] || ""
56
58
 
57
- # Search.construct_url
58
59
  end
59
60
 
60
61
  def location=(value)
@@ -77,8 +78,18 @@ module Active
77
78
  end
78
79
  end
79
80
 
81
+ def asset_ids=(value)
82
+ @asset_ids = value
83
+ end
84
+
85
+ def asset_id=(value)
86
+ return if value.empty?
87
+ @asset_ids<<value
88
+ end
89
+
80
90
  def end_point
81
91
  meta_data = ""
92
+ # CHANNELS
82
93
  channel_keys = []
83
94
  @channels.each do |c|
84
95
  c.to_sym
@@ -88,10 +99,34 @@ module Active
88
99
  end
89
100
  meta_data = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }.join("+OR+")
90
101
  puts meta_data
102
+ # ASSET IDS
103
+
104
+
105
+ unless asset_ids.empty?
106
+ meta_data += "+AND+" unless meta_data == ""
107
+ temp_ids = []
108
+ asset_ids.each do |id|
109
+ temp_ids << "meta:" + CGI.escape("assetId=#{id.gsub("-","%2d")}")
110
+ end
111
+ meta_data += temp_ids.join("+OR+")
112
+ end
113
+
114
+
115
+ # trending_asset_order=[]
116
+ # trending.each do |asset_id|
117
+ # trending_asset_order << asset_id[0]
118
+ # @m = @m + "+OR+" if @m!=""
119
+ #
120
+ # str = "assetId=#{asset_id[0].gsub("-","%2d")}"
121
+ # str = CGI.escape(str)
122
+ # @m = @m + "meta:#{str}"
123
+ # end
124
+
91
125
 
92
126
 
93
- # meta_data = self.channels.join("+OR+")
94
127
 
128
+ # meta_data = self.channels.join("+OR+")
129
+ # AND DATE
95
130
  meta_data += "+AND+" unless meta_data == ""
96
131
  if @start_date.class == Date
97
132
  @start_date = URI.escape(@start_date.strftime("%m/%d/%Y")).gsub(/\//,"%2F")
@@ -100,7 +135,7 @@ module Active
100
135
  @end_date = URI.escape(@end_date.strftime("%m/%d/%Y")).gsub(/\//,"%2F")
101
136
  end
102
137
  meta_data += "meta:startDate:daterange:#{@start_date}..#{@end_date}"
103
-
138
+
104
139
  url = "#{SEARCH_URL}/search?api_key=#{@api_key}&num=#{@num_results}&page=#{@page}&l=#{@location}&f=#{@facet}&v=#{@view}&r=#{@radius}&s=#{@sort}&k=#{@keywords.join("+")}&m=#{meta_data}"
105
140
  end
106
141
 
@@ -145,46 +180,46 @@ module Active
145
180
  return search
146
181
  end
147
182
 
148
- def self.construct_url(arg_options={})
149
- return arg_options[:url] if arg_options.keys.index(:url) #todo use has_key? #a search url was specified - bypass parsing the options (trending)
150
- # self.merge!(arg_options)
151
-
152
- # options[:location] = CGI.escape(options[:location]) if options[:location]
153
-
154
- # if options[:keywords].class == String
155
- # options[:keywords] = options[:keywords].split(",")
156
- # options[:keywords].each { |k| k.strip! }
157
- # end
158
-
159
- # if options[:channels] != nil
160
- # channel_keys = []
161
- # options[:channels].each do |c|
162
- # c.to_sym
163
- # if self.CHANNELS.include?(c)
164
- # channel_keys << self.CHANNELS[c]
165
- # end
166
- # end
167
- # channels_a = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }
168
- # end
169
-
170
- meta_data = ""
171
- meta_data = channels_a.join("+OR+") if channels_a
172
-
173
- meta_data += "+AND+" unless meta_data == ""
174
- if options[:start_date].class == Date
175
- options[:start_date] = URI.escape(options[:start_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
176
- end
177
-
178
- if options[:end_date].class == Date
179
- options[:end_date] = URI.escape(options[:end_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
180
- end
181
- meta_data += "meta:startDate:daterange:#{options[:start_date]}..#{options[:end_date]}"
182
-
183
- url = "#{SEARCH_URL}/search?api_key=#{options[:api_key]}&num=#{options[:num_results]}&page=#{options[:page]}&l=#{options[:location]}&f=#{options[:facet]}&v=#{options[:view]}&r=#{options[:radius]}&s=#{options[:sort]}&k=#{options[:keywords].join("+")}&m=#{meta_data}"
184
- puts url
185
- url
186
- self.end_point = url
187
- end
183
+ # def self.construct_url(arg_options={})
184
+ # return arg_options[:url] if arg_options.keys.index(:url) #todo use has_key? #a search url was specified - bypass parsing the options (trending)
185
+ # # self.merge!(arg_options)
186
+ #
187
+ # # options[:location] = CGI.escape(options[:location]) if options[:location]
188
+ #
189
+ # # if options[:keywords].class == String
190
+ # # options[:keywords] = options[:keywords].split(",")
191
+ # # options[:keywords].each { |k| k.strip! }
192
+ # # end
193
+ #
194
+ # # if options[:channels] != nil
195
+ # # channel_keys = []
196
+ # # options[:channels].each do |c|
197
+ # # c.to_sym
198
+ # # if self.CHANNELS.include?(c)
199
+ # # channel_keys << self.CHANNELS[c]
200
+ # # end
201
+ # # end
202
+ # # channels_a = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }
203
+ # # end
204
+ #
205
+ # meta_data = ""
206
+ # meta_data = channels_a.join("+OR+") if channels_a
207
+ #
208
+ # meta_data += "+AND+" unless meta_data == ""
209
+ # if options[:start_date].class == Date
210
+ # options[:start_date] = URI.escape(options[:start_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
211
+ # end
212
+ #
213
+ # if options[:end_date].class == Date
214
+ # options[:end_date] = URI.escape(options[:end_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
215
+ # end
216
+ # meta_data += "meta:startDate:daterange:#{options[:start_date]}..#{options[:end_date]}"
217
+ #
218
+ # url = "#{SEARCH_URL}/search?api_key=#{options[:api_key]}&num=#{options[:num_results]}&page=#{options[:page]}&l=#{options[:location]}&f=#{options[:facet]}&v=#{options[:view]}&r=#{options[:radius]}&s=#{options[:sort]}&k=#{options[:keywords].join("+")}&m=#{meta_data}"
219
+ # puts url
220
+ # url
221
+ # self.end_point = url
222
+ # end
188
223
 
189
224
  private
190
225
  def self.double_encode_channel str
@@ -195,7 +230,8 @@ module Active
195
230
  end
196
231
 
197
232
  end
198
-
233
+
234
+ # TODO move to a reflection service
199
235
  class Categories
200
236
  def self.CHANNELS
201
237
  {
@@ -2,6 +2,7 @@
2
2
  require File.join(File.dirname(__FILE__), %w[spec_helper])
3
3
  require File.join(File.dirname(__FILE__), %w[ .. lib services search])
4
4
  require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
5
+ require File.join(File.dirname(__FILE__), %w[ .. lib services IActivity])
5
6
 
6
7
  # No need to type Britify:: before each call
7
8
  include Active::Services
@@ -57,6 +58,7 @@ describe Activity do
57
58
  end
58
59
 
59
60
  it "should strip out html from the title" do
61
+ pending
60
62
  a = Activity.new(@valid_attributes)
61
63
  a.title.should eql("2011 Walt Disney World Marathon")
62
64
  end
@@ -74,13 +76,13 @@ describe Activity do
74
76
  it "should be a valid activity" do
75
77
  a = Activity.new(@valid_attributes)
76
78
  a.url.should eql("http://www.active.com/running/lake-buena-vista-fl/walt-disney-world-marathon-2011")
77
- a.category.should eql("action_sports")
79
+ a.categories.include?("action_sports").should be_true
78
80
  a.asset_id.should eql("3584C7D6-14FD-4FD1-BD07-C2A9B2925B6C")
79
81
 
80
82
  a.title.should_not be_nil
81
83
  a.start_date.should_not be_nil
82
84
  a.end_date.should_not be_nil
83
- a.category.should_not be_nil
85
+ a.categories.should_not be_nil
84
86
  a.desc.should_not be_nil
85
87
  a.start_time.should_not be_nil
86
88
  a.end_time.should_not be_nil
@@ -96,12 +98,90 @@ describe Activity do
96
98
  a.address[:lat].should_not be_nil
97
99
  a.address[:lng].should_not be_nil
98
100
  a.address[:name].should_not be_nil
101
+ end
102
+
103
+ describe "Activity url" do
104
+ it "should have a valid seo url: type 1" do
105
+ a = Activity.new({ :url => "http://active.com/foo.php", :meta => { :trackbackurl => "http://active.com/running/funrun", :seourl => "http://foo" } })
106
+ a.url.should == "http://active.com/running/funrun"
107
+ end
108
+ it "should have a valid seo url: type 2" do
109
+ a = Activity.new({ :url => "http://active.com/foo.php", :meta => { :trackbackurl => "http://active.com/running/funrun" } })
110
+ a.url.should == "http://active.com/running/funrun"
111
+ end
112
+ it "should have a valid seo url: type 3" do
113
+ a = Activity.new({ :url => "http://active.com/foo.php" })
114
+ a.url.should == "http://active.com/foo.php"
115
+ end
116
+ end
117
+
118
+ describe "ATS data fetch" do
119
+ it "should retrive the ats data"
120
+ it "should store the date when ats was"
121
+ end
122
+
123
+ describe "ActiveNet data fetch" do
124
+ # todo get a list of ActiveNet ids
125
+ # assetTypeId: FB27C928-54DB-4ECD-B42F-482FC3C8681F
126
+ # assetTypeName: ActiveNet
127
+ # assetId: 4C2C70F1-9D53-4ECA-A04C-68A76C3A53F4
128
+ # assetId: 34DB5609-6697-400D-8C52-0305D479C9C1
129
+ # assetId: 65B56E1A-5C3E-4D9B-8EA6-0417C07E5956
130
+
99
131
 
100
- # a.onlineDonationAvailable.should_not be_nil
101
- # a.onlineRegistrationAvailable.should_not be_nil
102
- # a.onlineMembershipAvailable.should_not be_nil
132
+ it "should retrive data from ActiveNet" do
133
+ # a = Activity.new({})
134
+ # a.should receive al call to a.get_ats_data
135
+ # a.rawdata.should be a freaking hash
136
+ pending
137
+ end
103
138
 
139
+ describe "Lazy loading of params" do
140
+ it "should call ATS when only asset_id is set" do
141
+ ATS.should_receive(:find_by_id).with("A9EF9D79-F859-4443-A9BB-91E1833DF2D5").once
142
+ a = Activity.find_by_asset_id(:asset_id => "A9EF9D79-F859-4443-A9BB-91E1833DF2D5")
143
+ end
144
+ it "should save the asset_id" do
145
+ a = Activity.find_by_asset_id(:asset_id => "A9EF9D79-F859-4443-A9BB-91E1833DF2D5")
146
+ a.asset_id.should == "A9EF9D79-F859-4443-A9BB-91E1833DF2D5"
147
+ a.title.should == "Fitness, Pilates Mat Class (16 Yrs. &amp; Up)"
148
+ end
149
+ it "should thorw an ActivityFindError if no record is found" do
150
+ lambda { Activity.find_by_asset_id( :asset_id => "666" ) }.should raise_error(ActivityFindError)
151
+ end
152
+
153
+
154
+ it "should save the asset_id and type" do
155
+ pending
156
+ # a = Activity.find_by_asset_id(:asset_id => "A9EF9D79-F859-4443-A9BB-91E1833DF2D5", :asset_type_id => "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65")
157
+ # a.asset_id.should == "A9EF9D79-F859-4443-A9BB-91E1833DF2D5"
158
+ # a.asset_type_id.should == "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65"
159
+ end
160
+ it "should obtain the asset_type_id if it wasn't provided" do
161
+ a = Activity.find_by_asset_id(:asset_id => "A9EF9D79-F859-4443-A9BB-91E1833DF2D5")
162
+ a.asset_type_id.should == "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65"
163
+ end
164
+ it "should have an event closing date" do
165
+ # a.eventCloseDate.should == "2010-09-13T00:00:00-07:00"
166
+ end
167
+ it "should return the start time" do
168
+ # mock
169
+ # a = Activity.new({})
170
+ # a.start_time.should == 11:00 am
171
+ pending
172
+ end
173
+ end
104
174
  end
105
175
 
106
176
 
107
177
  end
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
data/spec/ats_spec.rb ADDED
@@ -0,0 +1,57 @@
1
+ # Require the spec helper relative to this file
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+ require File.join(File.dirname(__FILE__), %w[custom_matchers_spec])
4
+ require File.join(File.dirname(__FILE__), %w[ .. lib services search])
5
+ require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
6
+ require File.join(File.dirname(__FILE__), %w[ .. lib services ats])
7
+ include Active::Services
8
+
9
+ describe ATS do
10
+ before(:each) do
11
+ @valid_id = "A9EF9D79-F859-4443-A9BB-91E1833DF2D5"
12
+ @reg_center_id = "D9A22F33-8A14-4175-8D5B-D11578212A98"
13
+ end
14
+ it "should set find by id" do
15
+ a = ATS.find_by_id(@valid_id)
16
+ a.asset_id.should == @valid_id
17
+ end
18
+ it "should get the asset_type_id" do
19
+ ATS.find_by_id(@valid_id).asset_id_type.should_not be_nil
20
+ end
21
+ it "should thorw an ATSError if no record is found" do
22
+ lambda { ATS.find_by_id( "666" ) }.should raise_error(ATSError)
23
+ end
24
+ it "should get the asset metadata" do
25
+ ATS.get_asset_metadata(@valid_id).should_not be_nil
26
+ end
27
+ it "should load the asset metadata into @data" do
28
+ a = ATS.find_by_id(@valid_id)
29
+ a.load_metadata
30
+ a.data["isSearchable"].should_not be_nil
31
+ end
32
+ it "should load the lazy the asset metadata" do
33
+ a = ATS.find_by_id(@valid_id)
34
+ puts a.url
35
+ a.start_date.should_not be_nil
36
+ end
37
+ it "should only load metadata once" do
38
+ a = ATS.find_by_id(@valid_id)
39
+ puts a.url
40
+ puts a.address
41
+ ATS.should_receive(:load_metadata).once
42
+ end
43
+ it "should have an address Hash" do
44
+ a = ATS.find_by_id(@valid_id)
45
+ a.address.should be_an_instance_of(Hash)
46
+ end
47
+ it "should have a startDate Date" do
48
+ a = ATS.find_by_id(@valid_id)
49
+ a.start_date.should be_an_instance_of(Date)
50
+ end
51
+ it "should have a title String" do
52
+ a = ATS.find_by_id(@valid_id)
53
+ a.title.should be_an_instance_of(String)
54
+ end
55
+
56
+
57
+ end
data/spec/reg_spec.rb ADDED
@@ -0,0 +1,53 @@
1
+ # Require the spec helper relative to this file
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+ require File.join(File.dirname(__FILE__), %w[custom_matchers_spec])
4
+ require File.join(File.dirname(__FILE__), %w[ .. lib services search])
5
+ require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
6
+ require File.join(File.dirname(__FILE__), %w[ .. lib services reg_center])
7
+ include Active::Services
8
+
9
+ describe RegCenter do
10
+ before(:each) do
11
+ @valid_id = "D9A22F33-8A14-4175-8D5B-D11578212A98"
12
+ end
13
+ it "should set find by id" do
14
+ a = RegCenter.find_by_id(@valid_id)
15
+ a.asset_id.should == @valid_id
16
+ end
17
+ it "should get the asset_type_id" do
18
+ RegCenter.find_by_id(@valid_id).asset_id_type.should_not be_nil
19
+ end
20
+ it "should thorw an RegCenterError if no record is found" do
21
+ lambda { RegCenter.find_by_id( "666" ) }.should raise_error(RegCenterError)
22
+ end
23
+ it "should get the API metadata" do
24
+ a = RegCenter.find_by_id(@valid_id)
25
+ a.data["event"].should_not be_nil
26
+ end
27
+ it "should have more details than ATS" do
28
+ a = ATS.find_by_id(@valid_id)
29
+ b = RegCenter.find_by_id(@valid_id)
30
+ a.address[:address].should be_nil
31
+ b.address[:address].should_not be_nil
32
+ end
33
+ it "should only load API metadata once" do
34
+ a = RegCenter.find_by_id(@valid_id)
35
+ puts a.url
36
+ puts a.address
37
+ RegCenter.should_receive(:get_app_api).once
38
+ end
39
+ it "should have an address Hash" do
40
+ a = RegCenter.find_by_id(@valid_id)
41
+ a.address.should be_an_instance_of(Hash)
42
+ end
43
+ it "should cleanup title" do
44
+ a = ATS.find_by_id(@valid_id)
45
+ a.title.should_not_contain("\r")
46
+ end
47
+ it "should have a title String" do
48
+ a = ATS.find_by_id(@valid_id)
49
+ a.title.should be_an_instance_of(String)
50
+ end
51
+
52
+
53
+ end
data/spec/search_spec.rb CHANGED
@@ -53,6 +53,7 @@ describe "Search URL Construction" do
53
53
  uri.query.include?("page=1").should be_true
54
54
  uri.query.should have_param("num=10")
55
55
  uri.query.should have_param("daterange:today..+")
56
+ uri.query.should_not have_param("assetId=")
56
57
  end
57
58
 
58
59
  it "should construct a valid url with location" do
@@ -122,6 +123,30 @@ describe "Search URL Construction" do
122
123
  uri.query.should have_param("r=666")
123
124
  end
124
125
 
126
+ it "should pass the given asset_id" do
127
+ s = Search.new({:asset_id => "12-34" })
128
+ s.should have(1).asset_ids
129
+ end
130
+
131
+ it "should pass the given asset_id's" do
132
+ s = Search.new({:asset_ids => ["12-34","5-67","77-7"] })
133
+ s.should have(3).asset_ids
134
+ uri = URI.parse( s.end_point )
135
+ uri.query.should_not have_param("m=+AND+")
136
+ uri.query.should have_param("meta:assetId%3D12%252d34+OR+meta:assetId%3D5%252d67+OR+meta:assetId%3D77%252d7")
137
+ end
138
+
139
+ it "should pass a query" do
140
+ uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer"}).end_point )
141
+ uri.query.should have_param("q=soccer")
142
+ end
143
+
144
+ it "should probably encode the query value" do
145
+ pending
146
+ # uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer balls"}).end_point )
147
+ # uri.query.should have_param("q=soccer+balls") What kind of encoding do we need
148
+ end
149
+
125
150
  end
126
151
 
127
152
  describe "Handle http server codes" do
@@ -145,7 +170,7 @@ describe Search do
145
170
  after(:each) do
146
171
  FakeWeb.clean_registry
147
172
  end
148
-
173
+
149
174
  it "should have some channels" do
150
175
  Categories.CHANNELS.should_not be_nil
151
176
  end
@@ -163,6 +188,7 @@ describe Search do
163
188
  s.numberOfResults.should == 3
164
189
  s.pageSize.should == 5
165
190
  s.searchTime.should == 0.600205
191
+
166
192
  end
167
193
 
168
194
  it "should raise and error during a 404" do
@@ -185,7 +211,7 @@ describe Search do
185
211
  a.title.should_not be_nil
186
212
  a.start_date.should_not be_nil
187
213
  a.end_date.should_not be_nil
188
- a.category.should_not be_nil
214
+ a.categories.should_not be_nil
189
215
  a.desc.should_not be_nil
190
216
  a.start_time.should_not be_nil
191
217
  a.end_time.should_not be_nil
@@ -199,6 +225,16 @@ describe Search do
199
225
  a.address[:lng].should_not be_nil
200
226
  end
201
227
  end
228
+
229
+ it "should handle a JSON parse error" do
230
+ # /search?api_key=&num=10&page=1&l=0&f=activities&v=json&r=50&s=trending&k=&m=meta:startDate:daterange:today..+
231
+ # FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
232
+ # :body => '{"endIndex":10,"numberOfResults":2810,"pageSize":10,"searchTime":0.86581,"_results":[{"escapedUrl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","language":"en","title":"Myrtle Beach Mini Marathon | Myrtle Beach, South Carolina \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","summary":"","meta":{"eventDate":"2010-10-24T07:00:00-07:00","location":"Myrtle Beach, South Carolina","tag":["event:10","Running:10"],"endDate":"2010-10-24","eventLongitude":"-78.92921","splitMediaType":["Event","5K","Half Marathon","Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-13 18:15:04.753","locationName":"Myrtle Beach, South Carolina","endTime":"7:00:00","google-site-verification":"","city":"Myrtle Beach","startTime":"7:00:00","eventId":"1797753","description":"","longitude":"-78.92921","substitutionUrl":"1797753","eventLatitude":"33.75043","eventState":"South Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Medieval Times","dma":"Florence - Myrtle Beach","seourl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","country":"United States","category":"Activities","market":"Florence - Myrtle Beach","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Robert Pozo","eventZip":"29579","latitude":"33.75043","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"South Carolina","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"6000","assetId":["008540A9-C2AB-4D7F-BE68-298758B324CD","008540a9-c2ab-4d7f-be68-298758b324cd"],"participationCriteria":"Adult,Men,Women","onlineDonationAvailable":"1","assetName":["Myrtle Beach Mini Marathon","Myrtle Beach Mini Marathon"],"eventURL":"http://runmyrtlebeach.com","zip":"29579","contactPhone":"1-800-733-7089","contactEmail":"info@runmyrtlebeach.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-13","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","language":"en","title":"Fans on the Field 2010 - Denver Stadium 5K/10K | Denver \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","summary":"","meta":{"startDate":"2010-10-10","eventDate":"2010-10-10T00:00:00-07:00","location":"INVESCO Field at Mile High","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-105.0265","endDate":"2010-10-10","lastModifiedDateTime":"2010-08-05 16:15:18.14","splitMediaType":["Event","10K","5K"],"locationName":"INVESCO Field at Mile High","endTime":"0:00:00","mediaType":["Event","Event\\10K","Event\\5K"],"city":"Denver","google-site-verification":"","startTime":"0:00:00","assetId":["4850BB73-3701-493D-936C-C38CC0B3FD4C","4850bb73-3701-493d-936c-c38cc0b3fd4c"],"eventId":"1869635","participationCriteria":"All","description":"","longitude":"-105.0265","onlineDonationAvailable":"false","substitutionUrl":"1869635","assetName":["Fans on the Field 2010 - Denver Stadium 5K/10K","Fans on the Field 2010 - Denver Stadium 5K/10K"],"zip":"80204","contactPhone":"303-293-5315","eventLatitude":"39.73804","eventState":"Colorado","sortDate":"2000-10-10","keywords":"Event","eventAddress":"1801 Bryant Street","contactEmail":"ahinkle@nscd.org","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-05","eventZip":"80204","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"39.73804","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","language":"en","title":"The Palm Beaches Marathon Festival | West Palm Beach \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","summary":"","meta":{"eventDate":"2010-12-05T06:00:00-08:00","location":"West Palm Beach, Florida","tag":["event:10","Running:10"],"endDate":"2010-12-05","eventLongitude":"-80.06707","splitMediaType":["Event","5K","Half Marathon","Marathon","Relay"],"lastModifiedDateTime":"2010-09-10 13:15:05.057","locationName":"West Palm Beach, Florida","endTime":"6:00:00","google-site-verification":"","city":"West Palm Beach","startTime":"6:00:00","eventId":"1815427","description":"","longitude":"-80.06707","substitutionUrl":"1815427","eventLatitude":"26.72339","eventState":"Florida","sortDate":"2000-12-05","keywords":"Event","eventAddress":"S. Flagler Drive and Evernia St.","dma":"West Palm Beach - Fort Pierce","seourl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","country":"United States","category":"Activities","market":"West Palm Beach - Fort Pierce","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Iva Grady","eventZip":"33401","latitude":"26.72339","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-12-05","state":"Florida","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","Event\\Relay"],"estParticipants":"8000","assetId":["EA86AD3C-FBBA-403A-9DDB-1D211C210225","ea86ad3c-fbba-403a-9ddb-1d211c210225"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["The Palm Beaches Marathon Festival","The Palm Beaches Marathon Festival"],"eventURL":"http://www.pbmarathon.com","zip":"33401","contactPhone":"561-833-3711 ex. 222","contactEmail":"info@marathonofthepalmbeaches.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/west-palm-beach-fl/the-palm-beaches-marathon-festival-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-10","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","language":"en","title":"2nd Annual weSPARK 10K Run \u0026amp; 5K Run Walk | Encino \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","summary":"","meta":{"eventDate":"2010-11-14T08:00:00-08:00","location":"Balboa Park/Lake Balboa","tag":["event:10","Running:10"],"endDate":"2010-11-14","eventLongitude":"-118.4924","splitMediaType":["Event","10K","5K"],"lastModifiedDateTime":"2010-08-23 13:16:00.843","locationName":"Balboa Park/Lake Balboa","endTime":"8:00:00","google-site-verification":"","city":"Encino","startTime":"8:00:00","eventId":"1847738","description":"","longitude":"-118.4924","substitutionUrl":"1847738","eventLatitude":"34.19933","eventState":"California","sortDate":"2000-11-14","keywords":"Event","eventAddress":"6335 Woodley Avenue","dma":"Los Angeles","seourl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","country":"United States","category":"Activities","market":"Los Angeles","contactName":"Lilliane Ballesteros","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"91406","latitude":"34.19933","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-14","state":"California","mediaType":["Event","Event\\10K","Event\\5K"],"estParticipants":"1400","assetId":["D9A22F33-8A14-4175-8D5B-D11578212A98","d9a22f33-8a14-4175-8d5b-d11578212a98"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["2nd Annual weSPARK 10K Run \u0026 5K Run Walk","2nd Annual weSPARK 10K Run \u0026 5K Run Walk"],"eventURL":"http://www.wespark.org","zip":"91406","contactPhone":"818-906-3022","contactEmail":"lilliane@wespark.org","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/encino-ca/2nd-annual-wespark-10k-run-and-5k-run-walk-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-08-23","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","language":"en","title":"Heroes of Hope Race for Research | Los Angeles, Playa Del \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","summary":"","meta":{"eventDate":"2010-11-07T08:00:00-08:00","location":"Dockweiler State Beach","tag":["event:10","Running:10"],"endDate":"2010-11-07","eventLongitude":"-118.4392","splitMediaType":["Event","10K","5K"],"lastModifiedDateTime":"2010-09-09 07:15:48.193","locationName":"Dockweiler State Beach","endTime":"8:00:00","google-site-verification":"","city":"Los Angeles, Playa Del Rey","startTime":"8:00:00","eventId":"1858905","description":"","longitude":"-118.4392","substitutionUrl":"1858905","eventLatitude":"33.9495","eventState":"California","sortDate":"2000-11-07","keywords":"Event","eventAddress":"8255 Vista Del Mar Blvd","dma":"Los Angeles","seourl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","country":"United States","category":"Activities","market":"Los Angeles","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Lisa Kaminsky-Millar","eventZip":"90293","latitude":"33.9495","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-07","state":"California","mediaType":["Event","Event\\10K","Event\\5K"],"estParticipants":"1000","assetId":["0D92AB40-ED0B-4657-B00B-480B38062F1C","0d92ab40-ed0b-4657-b00b-480b38062f1c"],"participationCriteria":"All","onlineDonationAvailable":"1","assetName":["Heroes of Hope Race for Research","Heroes of Hope Race for Research"],"eventURL":"http://www.heroesofhoperace.org","zip":"90293","contactPhone":"1-866-48-4CURE","contactEmail":"heroesofhoperace@gmail.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/los-angeles-playa-del-rey-ca/heroes-of-hope-race-for-research-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-09","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language":"en","title":"Calabasas Classic 2010 - 5k 10k Runs | Calabasas, California \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary":"","meta":{"eventDate":"2010-11-14T08:00:00-08:00","location":"Calabasas Park Centre","tag":["event:10","Green:10","Running:10"],"endDate":"2010-11-14","eventLongitude":"-118.6789","splitMediaType":["Event","1 mile","10K","5K"],"lastModifiedDateTime":"2010-09-14 21:02:55.007","locationName":"Calabasas Park Centre","endTime":"8:00:00","google-site-verification":"","city":"Calabasas","startTime":"8:00:00","eventId":"1810531","description":"","longitude":"-118.6789","substitutionUrl":"1810531","eventLatitude":"34.12794","eventState":"California","sortDate":"2000-11-14","keywords":"Event","eventAddress":"23975 Park Sorrento","dma":"Los Angeles","seourl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","country":"United States","category":"Activities","market":"Los Angeles","contactName":"Julie Talbert","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"91302","latitude":"34.12794","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-11-14","state":"California","mediaType":["Event","Event\\1 mile","Event\\10K","Event\\5K"],"estParticipants":"2500","assetId":["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD","11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Calabasas Classic 2010 - 5k 10k Runs","Calabasas Classic 2010 - 5k 10k Runs"],"eventURL":"http://www.calabasasclassic.com","zip":"91302","contactPhone":"818-715-0428","contactEmail":"rot10kd@yahoo.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-14","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","language":"en","title":"IRONMAN 70.3 MIAMI | Miami, Florida 33132 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","summary":"","meta":{"startDate":"2010-10-30","eventDate":"2010-10-30T07:00:00-07:00","location":"Bayfront Park - Downtown Miami","tag":["event:10","Triathlon:10"],"state":"Florida","eventLongitude":"-80.18975","endDate":"2010-10-30","lastModifiedDateTime":"2010-05-10 11:16:04.46","splitMediaType":["Event","Ironman","Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"locationName":"Bayfront Park - Downtown Miami","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"city":"Miami","google-site-verification":"","startTime":"7:00:00","assetId":["72FAE9F7-5C68-4DF8-B01C-B63AC188A06A","72fae9f7-5c68-4df8-b01c-b63ac188a06a"],"eventId":"1800302","participationCriteria":"Adult,Family,Men,Women","description":"","longitude":"-80.18975","onlineDonationAvailable":"false","substitutionUrl":"1800302","assetName":["IRONMAN 70.3 MIAMI","IRONMAN 70.3 MIAMI"],"zip":"33132","contactPhone":"3053072285","eventLatitude":"25.78649","eventState":"Florida","sortDate":"2000-10-30","keywords":"Event","eventAddress":"301 N. Biscayne Blvd.","contactEmail":"jennifer@miamitrievents.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-05-10","eventZip":"33132","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"25.78649","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","language":"en","title":"2011 Ironman 70.3 San Juan | San Juan, 00901 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","summary":"","meta":{"startDate":"2011-03-19","eventDate":"2011-03-19T07:00:00-07:00","location":"Los Rosales Street, San Geronimo Grounds","tag":["event:10","Triathlon:10"],"state":"N/A","endDate":"2011-03-19","eventLongitude":"-66.10572","lastModifiedDateTime":"2010-06-15 14:15:08.557","splitMediaType":["Event","Ironman","\u003ddifficulty:Advanced"],"locationName":"Los Rosales Street, San Geronimo Grounds","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","\u003ddifficulty:Advanced"],"city":"San Juan","google-site-verification":"","startTime":"7:00:00","assetId":["F6B819B9-9CC1-4E67-A87D-11518B05D4F3","f6b819b9-9cc1-4e67-a87d-11518b05d4f3"],"eventId":"1841595","participationCriteria":"Adult","description":"","longitude":"-66.10572","onlineDonationAvailable":"false","substitutionUrl":"1841595","assetName":["2011 Ironman 70.3 San Juan","2011 Ironman 70.3 San Juan"],"zip":"00901","contactPhone":"813-868-5940","eventLatitude":"18.46633","sortDate":"2001-03-19","keywords":"Event","contactEmail":"info@bnsportsllc.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/san-juan-na/ironman-703-san-juan-2011-ig329","country":"Puerto Rico","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-06-15","eventZip":"00901","latitude":"18.46633","UpdateDateTime":"9/1/2010 6:09:21 PM","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","language":"en","title":"2011 Ford Ironman St. George | St. George, Utah 84737 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","summary":"","meta":{"startDate":"2011-05-07","eventDate":"2011-05-07T07:00:00-07:00","location":"Sand Hollow State Park,","tag":["event:10","Triathlon:10"],"state":"Utah","eventLongitude":"-113.1508","endDate":"2011-05-07","lastModifiedDateTime":"2010-07-22 11:15:08.46","splitMediaType":["Event","Ironman","Long Course"],"locationName":"Sand Hollow State Park,","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course"],"city":"St. George","google-site-verification":"","startTime":"7:00:00","assetId":["A10B5BC1-BD95-4AFE-A1F6-35F6099E3636","a10b5bc1-bd95-4afe-a1f6-35f6099e3636"],"eventId":"1848350","participationCriteria":"All","description":"","longitude":"-113.1508","onlineDonationAvailable":"false","substitutionUrl":"1848350","assetName":["2011 Ford Ironman St. George","2011 Ford Ironman St. George"],"zip":"84737","contactPhone":"813-868-5940","eventLatitude":"37.15574","eventState":"Utah","sortDate":"2001-05-07","keywords":"Event","eventAddress":"4405 West 3600 South","contactEmail":"stgeorge@ironman.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/st-george-ut/ford-ironman-st-george-2011","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6","lastModifiedDate":"2010-07-22","eventZip":"84737","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"37.15574","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","language":"en","title":"2011 Memorial Hermann Ironman 70.3 Texas \u0026amp; Lonestar \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","summary":"","meta":{"startDate":"2011-04-09","eventDate":"2011-04-09T07:00:00-07:00","location":"Moody Gardens","state":"Texas","endDate":"2011-04-10","eventLongitude":"-94.90395","lastModifiedDateTime":"2010-05-12 09:16:41.91","splitMediaType":["Event","Ironman","Long Course","Sprint"],"locationName":"Moody Gardens","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","Event\\Sprint"],"city":"Galveston","google-site-verification":"","startTime":"7:00:00","assetId":["A40CC533-D502-4953-8157-DBB64D7FC4C2","a40cc533-d502-4953-8157-dbb64d7fc4c2"],"eventId":"1859810","participationCriteria":"All","description":"","longitude":"-94.90395","onlineDonationAvailable":"false","substitutionUrl":"1859810","assetName":["2011 Memorial Hermann Ironman 70.3 Texas \u0026 Lonestar Sprint Triathlon","2011 Memorial Hermann Ironman 70.3 Texas \u0026 Lonestar Sprint Triathlon"],"zip":"77554","contactPhone":"813-868-5940","eventLatitude":"29.24699","eventState":"Texas","sortDate":"2001-04-09","keywords":"Event","contactEmail":"texas70.3@ironman.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/galveston-tx/memorial-hermann-ironman-703-texas-and-lonestar-sprint-triathlon-2011","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6","lastModifiedDate":"2010-05-12","eventZip":"77554","latitude":"29.24699","UpdateDateTime":"9/1/2010 6:09:21 PM","channel":"Triathlon"}}]}',
233
+ # :status => ["200", "Found"])
234
+ # This query is throwing this error "source did not contain any JSON!" and we need to handle it
235
+ # s = Search.search( {:radius=>"50", :keywords=>"", :page=>1, :num_results=>10, :location=>"0"} )
236
+ pending
237
+ end
202
238
 
203
239
  end
204
240
 
@@ -232,6 +268,9 @@ describe "Call Live Data" do
232
268
  d >= Date.new(2010,1,1)
233
269
  }
234
270
  end
271
+ s.results.each do |a|
272
+ a.asset_id.should_not be_nil
273
+ end
235
274
  end
236
275
 
237
276
  # our model should be updated to handle multiple categories
@@ -252,6 +291,11 @@ describe "Call Live Data" do
252
291
  s = Search.search( {:channels => [:yoga]} )
253
292
  s.should have(10).results
254
293
  end
294
+
295
+ it "should not set sort to an empty string" do
296
+ s = Search.search( {:sort => ""} )
297
+ s.sort.should_not be_empty
298
+ end
255
299
 
256
300
  it "should find activities that have been recently added"
257
301
 
@@ -269,6 +313,22 @@ describe "Call Live Data" do
269
313
 
270
314
  it "should order by date DATE_DESC"
271
315
 
316
+ it "should order by the date created" do
317
+ # results = Search.search( {:channels => ['Running'], :sort => 'created_at_asc'} )
318
+ pending
319
+ end
320
+
321
+ end
322
+
323
+
324
+ describe "Parametric search" do
325
+ describe "Parametric search for running channel" do
326
+ it "should find by splitMediaType for the Running channel" do
327
+ # http://developer.active.com/docs/Activecom_Search_API_Reference
328
+ end
329
+ end
330
+ describe "Parametric search for triathlon channel" do
331
+ end
272
332
  end
273
333
 
274
334