Hi all!, could somebody get me a hand in order to improve this code, please? I'm getting a array of dicts here, every device have it last event attached in the dict...
I'm want delete the iteration over the events table, I don't think it is efficient enough maybe it could be changed doing a better query, joining the event and device tables in a sql view... on this way I can get a row.as_dict directly.... db.define_table('devices', Field('serial'), Field('brand'), Field('location'), format='%(serial)s' ) db.define_table('events', Field('device_id'), Field('date', datetime), Field('location'), format='%(device_id)s' ) @service.json events_service(): events = {} devices = db(db.devices).select() for dev in devices: event = db(db.events.device_id == dev.id).select().last() events[dev.id] = { 'name':event('name'), 'date':event('date'), 'brand':dev.brand, 'location':dev.location } return events Thanks in advance. Christian. -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.