>> pp u.facebooker_user.events.size60 => nil>> u.facebooker_user.events(:start_time => Time.now.utc.to_i).size=> 60 I only have 3 events in the future.....>> u.facebooker_user.events.select{|e| e.start_time.to_i >Time.now.utc.to_i}.size => 3 Ah and there they are. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20081209/0506815b/attachment.html>
dug around a bit...
def events(params={})
@events ||= @session.post(''facebook.events.get'', {:uid
=>
self.id}.merge(params)).map
do |event|
Event.from_hash(event)
end
end
So this looks like it''s trying to cache the results, but:
a) If you drop the "@events ||=" then this problem is fixed and
b) why would you want to cache the results?
I mean, if the params change and its cached then you get back bunk data.
That''s my 2 cents.... Am I missing something? Anyone elses''
input?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/facebooker-talk/attachments/20081209/87f23b47/attachment.html>
Yeah I had the same problem. The fix was simply using @events[params] ||instead of @events ||=. There are a couple other places where the same fix might be needed. I have a patch written but I still need to finish writing specs for it. George On Tue, Dec 9, 2008 at 7:33 PM, Josh Sharpe <josh.m.sharpe at gmail.com> wrote:> dug around a bit... > > def events(params={}) > @events ||= @session.post(''facebook.events.get'', {:uid => self.id}.merge(params)).map > do |event| > Event.from_hash(event) > end > end > > So this looks like it''s trying to cache the results, but: > > a) If you drop the "@events ||=" then this problem is fixed and > b) why would you want to cache the results? > > I mean, if the params change and its cached then you get back bunk data. > > That''s my 2 cents.... Am I missing something? Anyone elses'' input? > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20081209/b933b4c4/attachment-0001.html>
But what happens if you change params, is the result updated accordingly or is the first request cached? On Tue, Dec 9, 2008 at 10:45 PM, George Deglin <george at xapblog.com> wrote:> Yeah I had the same problem. The fix was simply using @events[params] ||> instead of @events ||=. There are a couple other places where the same fix > might be needed. > > I have a patch written but I still need to finish writing specs for it. > > George > > On Tue, Dec 9, 2008 at 7:33 PM, Josh Sharpe <josh.m.sharpe at gmail.com>wrote: > >> dug around a bit... >> >> def events(params={}) >> @events ||= @session.post(''facebook.events.get'', {:uid => self.id}.merge(params)).map >> do |event| >> Event.from_hash(event) >> end >> end >> >> So this looks like it''s trying to cache the results, but: >> >> a) If you drop the "@events ||=" then this problem is fixed and >> b) why would you want to cache the results? >> >> I mean, if the params change and its cached then you get back bunk data. >> >> That''s my 2 cents.... Am I missing something? Anyone elses'' input? >> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20081209/eaf3588c/attachment.html>
The correct fix is actually
def events(params={})
@events ||= {}
@events[params] ||= @session.post(''facebook.events.get'',
{:uid =>
self.id}.merge(params)).map do |event|
Event.from_hash(event)
end
end
If you call it a second time with different params it will return a new set
of results. Previous results will still be cached.
If the params are changed then the new results will be fetched. (But both
old and new will still be cached).
On Tue, Dec 9, 2008 at 7:49 PM, Josh Sharpe <josh.m.sharpe at gmail.com>
wrote:
> But what happens if you change params, is the result updated accordingly or
> is the first request cached?
>
>
> On Tue, Dec 9, 2008 at 10:45 PM, George Deglin <george at
xapblog.com> wrote:
>
>> Yeah I had the same problem. The fix was simply using @events[params]
||>> instead of @events ||=. There are a couple other places where the
same fix
>> might be needed.
>>
>> I have a patch written but I still need to finish writing specs for it.
>>
>> George
>>
>> On Tue, Dec 9, 2008 at 7:33 PM, Josh Sharpe <josh.m.sharpe at
gmail.com>wrote:
>>
>>> dug around a bit...
>>>
>>> def events(params={})
>>> @events ||=
@session.post(''facebook.events.get'', {:uid =>
self.id}.merge(params)).map
>>> do |event|
>>> Event.from_hash(event)
>>> end
>>> end
>>>
>>> So this looks like it''s trying to cache the results, but:
>>>
>>> a) If you drop the "@events ||=" then this problem is
fixed and
>>> b) why would you want to cache the results?
>>>
>>> I mean, if the params change and its cached then you get back bunk
data.
>>>
>>> That''s my 2 cents.... Am I missing something? Anyone
elses'' input?
>>>
>>> _______________________________________________
>>> Facebooker-talk mailing list
>>> Facebooker-talk at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/facebooker-talk/attachments/20081209/72fc9ba2/attachment.html>