Logo Search packages:      
Sourcecode: zeitgeist-extensions version File versions  Download package

def geolocation::Geolocation::find_events_for_locations (   self,
  longitude,
  latitude,
  radius,
  time_range,
  event_templates,
  storage_state,
  max_events,
  order 
)

Accepts 'event_templates' as either a real list of Events or as
a list of tuples (event_data, subject_data) as we do in the
DBus API.

Return modes:
 - 0: IDs.
 - 1: Events.

Definition at line 114 of file geolocation.py.

                                                                      :
        """
        Accepts 'event_templates' as either a real list of Events or as
        a list of tuples (event_data, subject_data) as we do in the
        DBus API.
        
        Return modes:
         - 0: IDs.
         - 1: Events.
        """
        
        where = self._engine._build_sql_event_filter(time_range, event_templates,
            storage_state)
        
        if not where.may_have_results():
            return []
        
        sql = "SELECT * FROM event_view"
        
        if order == ResultType.LeastRecentActor:
            sql += """
                NATURAL JOIN (
                    SELECT actor, min(timestamp) AS timestamp
                    FROM event_view
                    GROUP BY actor)
                """
        sql += " INNER JOIN %s locations ON (locations.id = event_view.id)" % DATABASE_TABLE_NAME
        
        where.add("min_longitude >= ?", longitude - radius)
        where.add("max_longitude <= ?", longitude + radius)
        where.add("min_latitude >= ?", latitude - radius)
        where.add("max_latitude <= ?", latitude + radius)
        sql += " WHERE " + where.sql
        
        sql += (" ORDER BY timestamp DESC",
            " ORDER BY timestamp ASC",
            " GROUP BY subj_uri ORDER BY timestamp DESC",
            " GROUP BY subj_uri ORDER BY timestamp ASC",
            " GROUP BY subj_uri ORDER BY COUNT(event_view.id) DESC, timestamp DESC",
            " GROUP BY subj_uri ORDER BY COUNT(event_view.id) ASC, timestamp ASC",
            " GROUP BY actor ORDER BY COUNT(event_view.id) DESC, timestamp DESC",
            " GROUP BY actor ORDER BY COUNT(event_view.id) ASC, timestamp ASC",
            " GROUP BY actor", # implicit: ORDER BY max(timestamp) DESC
            " ORDER BY timestamp ASC")[order]
        
        if max_events > 0:
            sql += " LIMIT %d" % max_events
        
        result = self._cursor.execute(sql, where.arguments).fetchall()
        
        return self._get_events(result)
    
    # PUBLIC
    def find_locations_for_events(self, event_ids):


Generated by  Doxygen 1.6.0   Back to index