Query of past events for a "like" page is not returning full list (as shown on actual page)

369 Views Asked by At

The code used to query (below) has not changed since before it was working correctly, but the page suddenly started only displaying one of the many past events. Has the functionality of the QL changed in some way or is this just a bug that I should wait and see if it passes?

SELECT name, pic, start_time, end_time, location, description, eid 
FROM event 
WHERE end_time < now() 
AND eid IN ( 
    SELECT eid 
    FROM event_member 
    WHERE uid = XXXXXXXXX ) 
ORDER BY start_time DESC
1

There are 1 best solutions below

2
On

I'm not totally sure, but FQL's documentation on event_member might be the key. Have you attempted running only the internal query (SELECT eid FROM event_member WHERE uid = XXXXXXXXX) alone without the wrapper to see what it's returning?

FQL documentation for event_member states that

If you do not specify a start_time, only events in the future will be returned.

EDIT: I take this to mean that you may, currently, need to specify start_time < now() in there, or something of the like.

(Though, if that's case, I'm not sure why you're even getting the one item returned because that would conflict with your end_time < now() statement).

My first suggestion might be to spit it into multiple queries using FQL multiquery and make sure that the event_member query is returning what you'd expect. Something like:

"event_members":"SELECT eid 
FROM event_member 
WHERE uid = XXXXXXXXX"

"events":"SELECT name, pic, start_time, end_time, location, description, eid 
FROM event 
WHERE end_time < now() 
AND eid IN (SELECT eid FROM #event_members) 
ORDER BY start_time DESC"

See that event_members holds all the entries you're hoping for - if so, find the issue in the 'events' query, if not, find the issue in the 'event_members' query.