Created
January 10, 2018 02:47
-
-
Save crashtech/40b929ce89dc9dc749bf7c24a7139ad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "orders"."id" AS t0_r0, | |
"orders"."customer_id" AS t0_r1, | |
"orders"."vendor_id" AS t0_r2, | |
"orders"."billing_address_id" AS t0_r3, | |
"orders"."shipping_address_id" AS t0_r4, | |
"orders"."status" AS t0_r5, | |
"orders"."partner_order_number" AS t0_r6, | |
"orders"."created_at" AS t0_r7, | |
"orders"."updated_at" AS t0_r8, | |
"orders"."description" AS t0_r9, | |
"orders"."public_id" AS t0_r10, | |
"orders"."source_id" AS t0_r11, | |
"orders"."pending" AS t0_r12, | |
"orders"."recipient_id" AS t0_r13, | |
"orders"."test_order" AS t0_r14, | |
"orders"."order_reason" AS t0_r15, | |
"orders"."legitimacy_type" AS t0_r16, | |
"orders"."pvpc_approved" AS t0_r17, | |
"orders"."billing_first_name" AS t0_r18, | |
"orders"."billing_last_name" AS t0_r19, | |
"orders"."recipient_first_name" AS t0_r20, | |
"orders"."recipient_last_name" AS t0_r21, | |
"orders"."integration_id" AS t0_r22, | |
"orders"."service_level_id" AS t0_r23, | |
"orders"."requested_start_time" AS t0_r24, | |
"orders"."requested_end_time" AS t0_r25, | |
"orders"."inventory_location_id" AS t0_r26, | |
"orders"."partner_metadata" AS t0_r27, | |
"orders"."fraud_score" AS t0_r28, | |
"affiliates"."id" AS t1_r0, | |
"affiliates"."name" AS t1_r1, | |
"affiliates"."public_id" AS t1_r2, | |
"affiliates"."shortname" AS t1_r3, | |
"affiliates"."created_at" AS t1_r4, | |
"affiliates"."updated_at" AS t1_r5, | |
"customers"."id" AS t2_r0, | |
"customers"."first_name" AS t2_r1, | |
"customers"."last_name" AS t2_r2, | |
"customers"."email" AS t2_r3, | |
"customers"."phone_number" AS t2_r4, | |
"customers"."created_at" AS t2_r5, | |
"customers"."updated_at" AS t2_r6, | |
"customers"."home_address_id" AS t2_r7, | |
"customers"."billing_address_id" AS t2_r8, | |
"customers"."encrypted_password" AS t2_r9, | |
"customers"."reset_password_token" AS t2_r10, | |
"customers"."reset_password_sent_at" AS t2_r11, | |
"customers"."remember_created_at" AS t2_r12, | |
"customers"."sign_in_count" AS t2_r13, | |
"customers"."current_sign_in_at" AS t2_r14, | |
"customers"."last_sign_in_at" AS t2_r15, | |
"customers"."current_sign_in_ip" AS t2_r16, | |
"customers"."last_sign_in_ip" AS t2_r17, | |
"customers"."authentication_token" AS t2_r18, | |
"customers"."time_zone" AS t2_r19, | |
"customers"."public_id" AS t2_r20, | |
"customers"."guest_account" AS t2_r21, | |
"customers"."accepts_marketing" AS t2_r22, | |
"customers"."confirmation_token" AS t2_r23, | |
"customers"."confirmed_at" AS t2_r24, | |
"customers"."confirmation_sent_at" AS t2_r25, | |
"customers"."shopify_id" AS t2_r26, | |
"customers"."legitimacy_type" AS t2_r27, | |
"customers"."registered_at" AS t2_r28, | |
"customers"."failed_attempts" AS t2_r29, | |
"customers"."unlock_token" AS t2_r30, | |
"customers"."locked_at" AS t2_r31, | |
"customers"."org" AS t2_r32, | |
"customers"."org_role" AS t2_r33, | |
"customers"."crm_id" AS t2_r34, | |
"customers"."carrier_type" AS t2_r35, | |
"customers"."mobile_phone_number" AS t2_r36, | |
"recipients_orders"."id" AS t3_r0, | |
"recipients_orders"."first_name" AS t3_r1, | |
"recipients_orders"."last_name" AS t3_r2, | |
"recipients_orders"."email" AS t3_r3, | |
"recipients_orders"."phone_number" AS t3_r4, | |
"recipients_orders"."created_at" AS t3_r5, | |
"recipients_orders"."updated_at" AS t3_r6, | |
"recipients_orders"."home_address_id" AS t3_r7, | |
"recipients_orders"."billing_address_id" AS t3_r8, | |
"recipients_orders"."encrypted_password" AS t3_r9, | |
"recipients_orders"."reset_password_token" AS t3_r10, | |
"recipients_orders"."reset_password_sent_at" AS t3_r11, | |
"recipients_orders"."remember_created_at" AS t3_r12, | |
"recipients_orders"."sign_in_count" AS t3_r13, | |
"recipients_orders"."current_sign_in_at" AS t3_r14, | |
"recipients_orders"."last_sign_in_at" AS t3_r15, | |
"recipients_orders"."current_sign_in_ip" AS t3_r16, | |
"recipients_orders"."last_sign_in_ip" AS t3_r17, | |
"recipients_orders"."authentication_token" AS t3_r18, | |
"recipients_orders"."time_zone" AS t3_r19, | |
"recipients_orders"."public_id" AS t3_r20, | |
"recipients_orders"."guest_account" AS t3_r21, | |
"recipients_orders"."accepts_marketing" AS t3_r22, | |
"recipients_orders"."confirmation_token" AS t3_r23, | |
"recipients_orders"."confirmed_at" AS t3_r24, | |
"recipients_orders"."confirmation_sent_at" AS t3_r25, | |
"recipients_orders"."shopify_id" AS t3_r26, | |
"recipients_orders"."legitimacy_type" AS t3_r27, | |
"recipients_orders"."registered_at" AS t3_r28, | |
"recipients_orders"."failed_attempts" AS t3_r29, | |
"recipients_orders"."unlock_token" AS t3_r30, | |
"recipients_orders"."locked_at" AS t3_r31, | |
"recipients_orders"."org" AS t3_r32, | |
"recipients_orders"."org_role" AS t3_r33, | |
"recipients_orders"."crm_id" AS t3_r34, | |
"recipients_orders"."carrier_type" AS t3_r35, | |
"recipients_orders"."mobile_phone_number" AS t3_r36, | |
"partners"."id" AS t4_r0, | |
"partners"."name" AS t4_r1, | |
"partners"."created_at" AS t4_r2, | |
"partners"."updated_at" AS t4_r3, | |
"partners"."shortname" AS t4_r4, | |
"partners"."require_pick_up_location" AS t4_r5, | |
"partners"."dashboard_url" AS t4_r6, | |
"partners"."public_id" AS t4_r7, | |
"partners"."logo_file_name" AS t4_r8, | |
"partners"."logo_content_type" AS t4_r9, | |
"partners"."logo_file_size" AS t4_r10, | |
"partners"."logo_updated_at" AS t4_r11, | |
"partners"."webhook_url" AS t4_r12, | |
"partners"."notification_email" AS t4_r13, | |
"vendors_orders"."id" AS t5_r0, | |
"vendors_orders"."name" AS t5_r1, | |
"vendors_orders"."created_at" AS t5_r2, | |
"vendors_orders"."updated_at" AS t5_r3, | |
"vendors_orders"."shortname" AS t5_r4, | |
"vendors_orders"."require_pick_up_location" AS t5_r5, | |
"vendors_orders"."dashboard_url" AS t5_r6, | |
"vendors_orders"."public_id" AS t5_r7, | |
"vendors_orders"."logo_file_name" AS t5_r8, | |
"vendors_orders"."logo_content_type" AS t5_r9, | |
"vendors_orders"."logo_file_size" AS t5_r10, | |
"vendors_orders"."logo_updated_at" AS t5_r11, | |
"vendors_orders"."webhook_url" AS t5_r12, | |
"vendors_orders"."notification_email" AS t5_r13, | |
"quality_checks"."id" AS t6_r0, | |
"quality_checks"."order_id" AS t6_r1, | |
"quality_checks"."reservation_id" AS t6_r2, | |
"quality_checks"."public_id" AS t6_r3, | |
"quality_checks"."created_at" AS t6_r4, | |
"quality_checks"."updated_at" AS t6_r5, | |
"order_items"."id" AS t7_r0, | |
"order_items"."product_spec_id" AS t7_r1, | |
"order_items"."order_id" AS t7_r2, | |
"order_items"."sku" AS t7_r3, | |
"order_items"."serial_number" AS t7_r4, | |
"order_items"."imei" AS t7_r5, | |
"order_items"."created_at" AS t7_r6, | |
"order_items"."updated_at" AS t7_r7, | |
"order_items"."pick_up_location_id" AS t7_r8, | |
"order_items"."status" AS t7_r9, | |
"order_items"."requires_delivery" AS t7_r10, | |
"order_items"."product_details" AS t7_r11, | |
"order_items"."pickup_id" AS t7_r12, | |
"order_items"."public_id" AS t7_r13, | |
"order_items"."pickup_notification_sent_at" AS t7_r14, | |
"order_items"."purchased" AS t7_r15, | |
"order_items"."order_item_bundle_id" AS t7_r16, | |
"order_items"."partner_metadata" AS t7_r17, | |
"order_items"."in_visit_attachment" AS t7_r18, | |
"relays"."id" AS t8_r0, | |
"relays"."meeting_address_id" AS t8_r1, | |
"relays"."carrier_id" AS t8_r2, | |
"relays"."created_at" AS t8_r3, | |
"relays"."updated_at" AS t8_r4, | |
"relays"."notes" AS t8_r5, | |
"relays"."event_type" AS t8_r6, | |
"inventory_transfers"."id" AS t9_r0, | |
"inventory_transfers"."travel_time_id" AS t9_r1, | |
"inventory_transfers"."expert_id" AS t9_r2, | |
"inventory_transfers"."created_at" AS t9_r3, | |
"inventory_transfers"."updated_at" AS t9_r4, | |
"inventory_transfers"."contact_name" AS t9_r5, | |
"inventory_transfers"."contact_phone_number" AS t9_r6, | |
"inventory_transfers"."notes" AS t9_r7, | |
"inventory_transfers"."inventory_location_id" AS t9_r8, | |
"inventory_transfers"."inventory_location_type" AS t9_r9, | |
"inventory_transfers"."fixed" AS t9_r10, | |
"calendar_blocks"."id" AS t10_r0, | |
"calendar_blocks"."start_time" AS t10_r1, | |
"calendar_blocks"."end_time" AS t10_r2, | |
"calendar_blocks"."created_at" AS t10_r3, | |
"calendar_blocks"."updated_at" AS t10_r4, | |
"calendar_blocks"."enabled" AS t10_r5, | |
"calendar_blocks"."event_id" AS t10_r6, | |
"calendar_blocks"."event_type" AS t10_r7, | |
"calendar_blocks"."placeholder" AS t10_r8, | |
"product_specs"."id" AS t11_r0, | |
"product_specs"."product_id" AS t11_r1, | |
"product_specs"."sku" AS t11_r2, | |
"product_specs"."color" AS t11_r3, | |
"product_specs"."size" AS t11_r4, | |
"product_specs"."service_plan" AS t11_r5, | |
"product_specs"."description" AS t11_r6, | |
"product_specs"."created_at" AS t11_r7, | |
"product_specs"."updated_at" AS t11_r8, | |
"product_specs"."main_product_image_file_name" AS t11_r9, | |
"product_specs"."main_product_image_content_type" AS t11_r10, | |
"product_specs"."main_product_image_file_size" AS t11_r11, | |
"product_specs"."main_product_image_updated_at" AS t11_r12, | |
"product_specs"."addon_image_file_name" AS t11_r13, | |
"product_specs"."addon_image_content_type" AS t11_r14, | |
"product_specs"."addon_image_file_size" AS t11_r15, | |
"product_specs"."addon_image_updated_at" AS t11_r16, | |
"product_specs"."pvpc_relevant" AS t11_r17, | |
"product_specs"."gear" AS t11_r18, | |
"product_specs"."demo" AS t11_r19, | |
"product_specs"."additional_info" AS t11_r20, | |
"product_specs"."burden_score" AS t11_r21, | |
"product_specs"."vendor_id" AS t11_r22, | |
"product_specs"."upc" AS t11_r23, | |
"product_specs"."financial_model" AS t11_r24, | |
"products"."id" AS t12_r0, | |
"products"."model" AS t12_r1, | |
"products"."brand" AS t12_r2, | |
"products"."description" AS t12_r3, | |
"products"."created_at" AS t12_r4, | |
"products"."updated_at" AS t12_r5, | |
"products"."default_experience_id" AS t12_r6, | |
"products"."hero_product" AS t12_r7, | |
"products"."category" AS t12_r8, | |
"products"."survey_id" AS t12_r9, | |
"products"."follow_up_experience_id" AS t12_r10, | |
"products"."product_brand_id" AS t12_r11, | |
"inventory_transfer_order_items_order_items"."id" AS t13_r0, | |
"inventory_transfer_order_items_order_items"."event_type" AS t13_r1, | |
"inventory_transfer_order_items_order_items"."inventory_transfer_id" AS t13_r2, | |
"inventory_transfer_order_items_order_items"."order_item_id" AS t13_r3, | |
"inventory_transfer_order_items_order_items"."created_at" AS t13_r4, | |
"inventory_transfer_order_items_order_items"."updated_at" AS t13_r5, | |
"inventory_transfer_order_items_order_items"."protected" AS t13_r6, | |
"inventory_transfer_order_items_order_items"."serial_number" AS t13_r7, | |
"inventory_transfer_order_items_order_items"."completed_at" AS t13_r8, | |
"inventory_transfers_inventory_transfer_order_items"."id" AS t14_r0, | |
"inventory_transfers_inventory_transfer_order_items"."travel_time_id" AS t14_r1, | |
"inventory_transfers_inventory_transfer_order_items"."expert_id" AS t14_r2, | |
"inventory_transfers_inventory_transfer_order_items"."created_at" AS t14_r3, | |
"inventory_transfers_inventory_transfer_order_items"."updated_at" AS t14_r4, | |
"inventory_transfers_inventory_transfer_order_items"."contact_name" AS t14_r5, | |
"inventory_transfers_inventory_transfer_order_items"."contact_phone_number" AS t14_r6, | |
"inventory_transfers_inventory_transfer_order_items"."notes" AS t14_r7, | |
"inventory_transfers_inventory_transfer_order_items"."inventory_location_id" AS t14_r8, | |
"inventory_transfers_inventory_transfer_order_items"."inventory_location_type" AS t14_r9, | |
"inventory_transfers_inventory_transfer_order_items"."fixed" AS t14_r10, | |
"calendar_blocks_inventory_transfers"."id" AS t15_r0, | |
"calendar_blocks_inventory_transfers"."start_time" AS t15_r1, | |
"calendar_blocks_inventory_transfers"."end_time" AS t15_r2, | |
"calendar_blocks_inventory_transfers"."created_at" AS t15_r3, | |
"calendar_blocks_inventory_transfers"."updated_at" AS t15_r4, | |
"calendar_blocks_inventory_transfers"."enabled" AS t15_r5, | |
"calendar_blocks_inventory_transfers"."event_id" AS t15_r6, | |
"calendar_blocks_inventory_transfers"."event_type" AS t15_r7, | |
"calendar_blocks_inventory_transfers"."placeholder" AS t15_r8, | |
"pick_up_locations"."id" AS t16_r0, | |
"pick_up_locations"."address_id" AS t16_r1, | |
"pick_up_locations"."name" AS t16_r2, | |
"pick_up_locations"."partner_location_number" AS t16_r3, | |
"pick_up_locations"."created_at" AS t16_r4, | |
"pick_up_locations"."updated_at" AS t16_r5, | |
"pick_up_locations"."emails" AS t16_r6, | |
"pick_up_locations"."note" AS t16_r7, | |
"pick_up_locations"."market" AS t16_r8, | |
"pick_up_locations"."enabled" AS t16_r9, | |
"addresses"."id" AS t17_r0, | |
"addresses"."street_address" AS t17_r1, | |
"addresses"."street_address_2" AS t17_r2, | |
"addresses"."city" AS t17_r3, | |
"addresses"."state" AS t17_r4, | |
"addresses"."country" AS t17_r5, | |
"addresses"."zip" AS t17_r6, | |
"addresses"."created_at" AS t17_r7, | |
"addresses"."updated_at" AS t17_r8, | |
"addresses"."time_zone" AS t17_r9, | |
"addresses"."public_id" AS t17_r10, | |
"addresses"."lat" AS t17_r11, | |
"addresses"."lng" AS t17_r12, | |
"addresses"."type" AS t17_r13, | |
"addresses"."locality_1" AS t17_r14, | |
"addresses"."locality_2" AS t17_r15, | |
"visits"."id" AS t18_r0, | |
"visits"."order_id" AS t18_r1, | |
"visits"."customer_id" AS t18_r2, | |
"visits"."expert_id" AS t18_r3, | |
"visits"."meeting_address_id" AS t18_r4, | |
"visits"."status" AS t18_r5, | |
"visits"."preferred_start_time" AS t18_r6, | |
"visits"."sms_notifications" AS t18_r7, | |
"visits"."created_at" AS t18_r8, | |
"visits"."updated_at" AS t18_r9, | |
"visits"."travel_time_id" AS t18_r10, | |
"visits"."public_id" AS t18_r11, | |
"visits"."reminder_sent_at" AS t18_r12, | |
"visits"."created_by_id" AS t18_r13, | |
"visits"."created_by_type" AS t18_r14, | |
"visits"."scheduler_inventory_location_id" AS t18_r15, | |
"visits"."inventory_location_id" AS t18_r16, | |
"visits"."inventory_location_type" AS t18_r17, | |
"visits"."previsit_text_sent_at" AS t18_r18, | |
"visits"."customer_signed_off_at" AS t18_r19, | |
"visits"."dropped_off_at" AS t18_r20, | |
"visits"."crm_message_id" AS t18_r21, | |
"visits"."on_my_way_text_sent_at" AS t18_r22, | |
"visits"."crm_new_message_count" AS t18_r23, | |
"visits"."customer_signature_file_name" AS t18_r24, | |
"visits"."customer_signature_content_type" AS t18_r25, | |
"visits"."customer_signature_file_size" AS t18_r26, | |
"visits"."customer_signature_updated_at" AS t18_r27, | |
"visits"."post_visit_sms_ticket_created_at" AS t18_r28, | |
"visits"."post_visit_email_ticket_created_at" AS t18_r29, | |
"visits"."post_visit_communication_survey_complete" AS t18_r30, | |
"visits"."seen_by_expert" AS t18_r31, | |
"calendar_blocks_visits"."id" AS t19_r0, | |
"calendar_blocks_visits"."start_time" AS t19_r1, | |
"calendar_blocks_visits"."end_time" AS t19_r2, | |
"calendar_blocks_visits"."created_at" AS t19_r3, | |
"calendar_blocks_visits"."updated_at" AS t19_r4, | |
"calendar_blocks_visits"."enabled" AS t19_r5, | |
"calendar_blocks_visits"."event_id" AS t19_r6, | |
"calendar_blocks_visits"."event_type" AS t19_r7, | |
"calendar_blocks_visits"."placeholder" AS t19_r8, | |
"customers_visits"."id" AS t20_r0, | |
"customers_visits"."first_name" AS t20_r1, | |
"customers_visits"."last_name" AS t20_r2, | |
"customers_visits"."email" AS t20_r3, | |
"customers_visits"."phone_number" AS t20_r4, | |
"customers_visits"."created_at" AS t20_r5, | |
"customers_visits"."updated_at" AS t20_r6, | |
"customers_visits"."home_address_id" AS t20_r7, | |
"customers_visits"."billing_address_id" AS t20_r8, | |
"customers_visits"."encrypted_password" AS t20_r9, | |
"customers_visits"."reset_password_token" AS t20_r10, | |
"customers_visits"."reset_password_sent_at" AS t20_r11, | |
"customers_visits"."remember_created_at" AS t20_r12, | |
"customers_visits"."sign_in_count" AS t20_r13, | |
"customers_visits"."current_sign_in_at" AS t20_r14, | |
"customers_visits"."last_sign_in_at" AS t20_r15, | |
"customers_visits"."current_sign_in_ip" AS t20_r16, | |
"customers_visits"."last_sign_in_ip" AS t20_r17, | |
"customers_visits"."authentication_token" AS t20_r18, | |
"customers_visits"."time_zone" AS t20_r19, | |
"customers_visits"."public_id" AS t20_r20, | |
"customers_visits"."guest_account" AS t20_r21, | |
"customers_visits"."accepts_marketing" AS t20_r22, | |
"customers_visits"."confirmation_token" AS t20_r23, | |
"customers_visits"."confirmed_at" AS t20_r24, | |
"customers_visits"."confirmation_sent_at" AS t20_r25, | |
"customers_visits"."shopify_id" AS t20_r26, | |
"customers_visits"."legitimacy_type" AS t20_r27, | |
"customers_visits"."registered_at" AS t20_r28, | |
"customers_visits"."failed_attempts" AS t20_r29, | |
"customers_visits"."unlock_token" AS t20_r30, | |
"customers_visits"."locked_at" AS t20_r31, | |
"customers_visits"."org" AS t20_r32, | |
"customers_visits"."org_role" AS t20_r33, | |
"customers_visits"."crm_id" AS t20_r34, | |
"customers_visits"."carrier_type" AS t20_r35, | |
"customers_visits"."mobile_phone_number" AS t20_r36, | |
"ride_alongs"."id" AS t21_r0, | |
"ride_alongs"."ride_type" AS t21_r1, | |
"ride_alongs"."visit_id" AS t21_r2, | |
"ride_alongs"."meeting_address_id" AS t21_r3, | |
"ride_alongs"."notes" AS t21_r4, | |
"ride_alongs"."created_at" AS t21_r5, | |
"ride_alongs"."updated_at" AS t21_r6, | |
"ride_alongs"."travel_time_id" AS t21_r7, | |
"calendar_blocks_ride_alongs"."id" AS t22_r0, | |
"calendar_blocks_ride_alongs"."start_time" AS t22_r1, | |
"calendar_blocks_ride_alongs"."end_time" AS t22_r2, | |
"calendar_blocks_ride_alongs"."created_at" AS t22_r3, | |
"calendar_blocks_ride_alongs"."updated_at" AS t22_r4, | |
"calendar_blocks_ride_alongs"."enabled" AS t22_r5, | |
"calendar_blocks_ride_alongs"."event_id" AS t22_r6, | |
"calendar_blocks_ride_alongs"."event_type" AS t22_r7, | |
"calendar_blocks_ride_alongs"."placeholder" AS t22_r8, | |
"meeting_addresses_visits"."id" AS t23_r0, | |
"meeting_addresses_visits"."street_address" AS t23_r1, | |
"meeting_addresses_visits"."street_address_2" AS t23_r2, | |
"meeting_addresses_visits"."city" AS t23_r3, | |
"meeting_addresses_visits"."state" AS t23_r4, | |
"meeting_addresses_visits"."country" AS t23_r5, | |
"meeting_addresses_visits"."zip" AS t23_r6, | |
"meeting_addresses_visits"."created_at" AS t23_r7, | |
"meeting_addresses_visits"."updated_at" AS t23_r8, | |
"meeting_addresses_visits"."time_zone" AS t23_r9, | |
"meeting_addresses_visits"."public_id" AS t23_r10, | |
"meeting_addresses_visits"."lat" AS t23_r11, | |
"meeting_addresses_visits"."lng" AS t23_r12, | |
"meeting_addresses_visits"."type" AS t23_r13, | |
"meeting_addresses_visits"."locality_1" AS t23_r14, | |
"meeting_addresses_visits"."locality_2" AS t23_r15, | |
"zip_codes"."id" AS t24_r0, | |
"zip_codes"."zip" AS t24_r1, | |
"zip_codes"."coverage_area_id" AS t24_r2, | |
"zip_codes"."created_at" AS t24_r3, | |
"zip_codes"."updated_at" AS t24_r4, | |
"zip_codes"."high_risk" AS t24_r5, | |
"coverage_areas"."id" AS t25_r0, | |
"coverage_areas"."name" AS t25_r1, | |
"coverage_areas"."enjoyment_center_id" AS t25_r2, | |
"coverage_areas"."created_at" AS t25_r3, | |
"coverage_areas"."updated_at" AS t25_r4, | |
"coverage_areas"."updated_zip_code_travel_times_at" AS t25_r5, | |
"coverage_areas"."coverage_zone_id" AS t25_r6, | |
"coverage_areas"."parking_buffer_minutes" AS t25_r7, | |
"experts"."id" AS t26_r0, | |
"experts"."created_at" AS t26_r1, | |
"experts"."updated_at" AS t26_r2, | |
"experts"."employee_id" AS t26_r3, | |
"experts"."enjoyment_center_id" AS t26_r4, | |
"experts"."phone_number" AS t26_r5, | |
"experts"."email_avatar_file_name" AS t26_r6, | |
"experts"."email_avatar_content_type" AS t26_r7, | |
"experts"."email_avatar_file_size" AS t26_r8, | |
"experts"."email_avatar_updated_at" AS t26_r9, | |
"experts"."avatar_file_name" AS t26_r10, | |
"experts"."avatar_content_type" AS t26_r11, | |
"experts"."avatar_file_size" AS t26_r12, | |
"experts"."avatar_updated_at" AS t26_r13, | |
"experts"."primary_transit_mode" AS t26_r14, | |
"experts"."public_id" AS t26_r15, | |
"experts"."secret_hash" AS t26_r16, | |
"experts"."primary_address_id" AS t26_r17, | |
"experts"."crm_id" AS t26_r18, | |
"experts"."bio_url" AS t26_r19, | |
"experts"."notification_publish_id" AS t26_r20, | |
"experts"."default_coverage_zone_id" AS t26_r21, | |
"experts"."mobile_container_strategy" AS t26_r22, | |
"experts"."shift_group_id" AS t26_r23, | |
"employees"."id" AS t27_r0, | |
"employees"."email" AS t27_r1, | |
"employees"."first_name" AS t27_r2, | |
"employees"."last_name" AS t27_r3, | |
"employees"."time_zone" AS t27_r4, | |
"employees"."remember_created_at" AS t27_r5, | |
"employees"."sign_in_count" AS t27_r6, | |
"employees"."current_sign_in_at" AS t27_r7, | |
"employees"."last_sign_in_at" AS t27_r8, | |
"employees"."current_sign_in_ip" AS t27_r9, | |
"employees"."last_sign_in_ip" AS t27_r10, | |
"employees"."created_at" AS t27_r11, | |
"employees"."updated_at" AS t27_r12, | |
"employees"."remember_token" AS t27_r13, | |
"employees"."enabled" AS t27_r14, | |
"employees"."hr_id" AS t27_r15 | |
FROM "orders" | |
LEFT OUTER JOIN "affiliate_orders" | |
ON "affiliate_orders"."order_id" = "orders"."id" | |
LEFT OUTER JOIN "affiliates" | |
ON "affiliates"."id" = "affiliate_orders"."affiliate_id" | |
LEFT OUTER JOIN "customers" | |
ON "customers"."id" = "orders"."customer_id" | |
LEFT OUTER JOIN "customers" "recipients_orders" | |
ON "recipients_orders"."id" = "orders"."recipient_id" | |
LEFT OUTER JOIN "partners" | |
ON "partners"."id" = "orders"."source_id" | |
LEFT OUTER JOIN "partners" "vendors_orders" | |
ON "vendors_orders"."id" = "orders"."vendor_id" | |
LEFT OUTER JOIN "quality_checks" | |
ON "quality_checks"."order_id" = "orders"."id" | |
LEFT OUTER JOIN "order_items" | |
ON "order_items"."order_id" = "orders"."id" | |
LEFT OUTER JOIN "order_item_relays" | |
ON "order_item_relays"."order_item_id" = "order_items"."id" | |
LEFT OUTER JOIN "relays" | |
ON "relays"."id" = "order_item_relays"."relay_id" | |
AND "relays"."event_type" = 'relay' | |
LEFT OUTER JOIN "inventory_transfer_order_items" | |
ON "inventory_transfer_order_items"."order_item_id" = "order_items"."id" | |
AND "inventory_transfer_order_items"."event_type" = 0 | |
LEFT OUTER JOIN "inventory_transfers" | |
ON "inventory_transfers"."id" = "inventory_transfer_order_items"."inventory_transfer_id" | |
LEFT OUTER JOIN "calendar_blocks" | |
ON "calendar_blocks"."event_id" = "inventory_transfers"."id" | |
AND "calendar_blocks"."event_type" = 'InventoryTransfer' | |
LEFT OUTER JOIN "product_specs" | |
ON "product_specs"."id" = "order_items"."product_spec_id" | |
LEFT OUTER JOIN "products" | |
ON "products"."id" = "product_specs"."product_id" | |
LEFT OUTER JOIN "inventory_transfer_order_items" "inventory_transfer_order_items_order_items" | |
ON "inventory_transfer_order_items_order_items"."order_item_id" = "order_items"."id" | |
LEFT OUTER JOIN "inventory_transfers" "inventory_transfers_inventory_transfer_order_items" | |
ON "inventory_transfers_inventory_transfer_order_items"."id" = "inventory_transfer_order_items_order_items"."inventory_transfer_id" | |
LEFT OUTER JOIN "calendar_blocks" "calendar_blocks_inventory_transfers" | |
ON "calendar_blocks_inventory_transfers"."event_id" = "inventory_transfers_inventory_transfer_order_items"."id" | |
AND "calendar_blocks_inventory_transfers"."event_type" = 'InventoryTransfer' | |
LEFT OUTER JOIN "pick_up_locations" | |
ON "pick_up_locations"."id" = "order_items"."pick_up_location_id" | |
LEFT OUTER JOIN "addresses" | |
ON "addresses"."id" = "pick_up_locations"."address_id" | |
LEFT OUTER JOIN "visits" | |
ON "visits"."order_id" = "orders"."id" | |
LEFT OUTER JOIN "calendar_blocks" "calendar_blocks_visits" | |
ON "calendar_blocks_visits"."event_id" = "visits"."id" | |
AND "calendar_blocks_visits"."event_type" = 'Visit' | |
LEFT OUTER JOIN "customers" "customers_visits" | |
ON "customers_visits"."id" = "visits"."customer_id" | |
LEFT OUTER JOIN "ride_alongs" | |
ON "ride_alongs"."visit_id" = "visits"."id" | |
LEFT OUTER JOIN "calendar_blocks" "calendar_blocks_ride_alongs" | |
ON "calendar_blocks_ride_alongs"."event_id" = "ride_alongs"."id" | |
AND "calendar_blocks_ride_alongs"."event_type" = 'RideAlong' | |
LEFT OUTER JOIN "addresses" "meeting_addresses_visits" | |
ON "meeting_addresses_visits"."id" = "visits"."meeting_address_id" | |
LEFT OUTER JOIN "zip_codes" | |
ON "zip_codes"."zip" = "meeting_addresses_visits"."zip" | |
LEFT OUTER JOIN "coverage_areas" | |
ON "coverage_areas"."id" = "zip_codes"."coverage_area_id" | |
LEFT OUTER JOIN "experts" | |
ON "experts"."id" = "visits"."expert_id" | |
LEFT OUTER JOIN "employees" | |
ON "employees"."id" = "experts"."employee_id" | |
WHERE "orders"."status" IN ( 'scheduled', 'ready_for_pick_up', 'with_logistics' ) | |
AND ( "visits"."status" != 'canceled' ) | |
ORDER BY calendar_blocks_visits.start_time, | |
orders.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment