Subversion Repositories SmartDukaan

Rev

Rev 5719 | Rev 6017 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5719 Rev 5964
Line 9... Line 9...
9
     DeliveryEstimate, WarehouseAllocation, \
9
     DeliveryEstimate, WarehouseAllocation, \
10
    PublicHolidays, ServiceableLocationDetails, PickupStore
10
    PublicHolidays, ServiceableLocationDetails, PickupStore
11
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException,\
11
from shop2020.thriftpy.logistics.ttypes import LogisticsServiceException,\
12
    DeliveryType
12
    DeliveryType
13
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
13
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
-
 
14
from sqlalchemy.sql import or_
14
from elixir import session
15
from elixir import session
15
import datetime, time
16
import datetime, time
16
import sys
17
import sys
17
import logging
18
import logging
18
logging.basicConfig(level=logging.DEBUG)
19
logging.basicConfig(level=logging.DEBUG)
Line 56... Line 57...
56
    for delivery_estimate in delivery_estimates:
57
    for delivery_estimate in delivery_estimates:
57
        delivery_estimate_cache[delivery_estimate.destination_pin, delivery_estimate.provider_id]\
58
        delivery_estimate_cache[delivery_estimate.destination_pin, delivery_estimate.provider_id]\
58
        =delivery_estimate.delivery_time, delivery_estimate.reliability
59
        =delivery_estimate.delivery_time, delivery_estimate.reliability
59
 
60
 
60
def __cache_serviceable_location_details_table():
61
def __cache_serviceable_location_details_table():
61
    serviceable_locations = ServiceableLocationDetails.query.all()
62
    serviceable_locations = ServiceableLocationDetails.query.filter(or_("exp!=0","cod!=0"))
62
    for serviceable_location in serviceable_locations:
63
    for serviceable_location in serviceable_locations:
63
        try:
64
        try:
64
            provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
65
            provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
65
        except:
66
        except:
66
            provider_pincodes = {}
67
            provider_pincodes = {}
67
            serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes 
68
            serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes 
68
        provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.station_type 
69
        provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.station_type
69
 
70
 
70
def __cache_warehouse_allocation_table():
71
def __cache_warehouse_allocation_table():
71
    warehouse_allocations = WarehouseAllocation.query.all()
72
    warehouse_allocations = WarehouseAllocation.query.all()
72
    for warehouse_allocation in warehouse_allocations:
73
    for warehouse_allocation in warehouse_allocations:
73
        warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
74
        warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location