def get_data(self, start, limit): emergency_orders = self.get_emergency_orders(start, limit) rows = [] for emergency_order in emergency_orders: delivered_products_cost = EmergencyOrderPackage.objects.filter( order_id=emergency_order.pk, status=EmergencyOrderStatusUpdate.STATUS_DELIVERED ).aggregate(sum_cost=Sum('cost'))['sum_cost'] delivery_lead_time = '' confirmed_status = emergency_order.confirmed_status if confirmed_status: delivery_lead_time = '%.2f' % ( (confirmed_status.timestamp - emergency_order.timestamp).seconds / 60.0 ) rows.append([ helpers.format_date(emergency_order.timestamp), emergency_order.location_code, helpers.format_status(emergency_order.status), delivery_lead_time, helpers.status_date_or_empty_string(emergency_order.confirmed_status), helpers.convert_products_dict_to_list(emergency_order.products_requested), delivered_products_cost, helpers.products_requested_not_confirmed(emergency_order) ]) return rows
def get_data(self, start, limit): emergency_orders = self.get_emergency_orders(start, limit) rows = [] for emergency_order in emergency_orders: delivery_lead_time = '' delivered_status = emergency_order.delivered_status received_status = emergency_order.received_status if delivered_status and received_status: delivery_lead_time = '%.2f' % ( (delivered_status.zipline_timestamp - received_status.timestamp).seconds / 60.0 ) rows.append([ emergency_order.pk, emergency_order.requesting_phone_number, helpers.format_date(emergency_order.timestamp), emergency_order.location_code, helpers.format_status(emergency_order.status), delivery_lead_time, emergency_order.zipline_request_attempts, helpers.status_date_or_empty_string(emergency_order.received_status), helpers.status_date_or_empty_string(emergency_order.rejected_status), helpers.zipline_status_date_or_empty_string(emergency_order.cancelled_status), helpers.zipline_status_date_or_empty_string(emergency_order.approved_status), helpers.zipline_status_date_or_empty_string(emergency_order.dispatched_status), helpers.zipline_status_date_or_empty_string(emergency_order.delivered_status), helpers.products_requested(emergency_order), helpers.products_delivered(emergency_order), helpers.products_requested_not_confirmed(emergency_order) ]) return rows