Пример #1
0
def futureJson(request):

    # init vars
    import json
    bookSvc = BookingService(Config())
    params = {
        'trend_city': None,
        'trend_region': 'England',
        'trend_locality': None,
        'trend_country': 'GB',
        'trend_factor': 0.10
    }

    # if this is a POST request process the form data
    if request.method == 'POST':
        params = request.POST

    # get trend data from booking service
    data = bookSvc.getTrendData(params)
    return HttpResponse(json.dumps(data), content_type='application/json')
Пример #2
0
# financial report: future revenue trend report

# python imports
import pprint
import json
from datetime import datetime, timedelta
import os, sys
sys.path.append(os.path.realpath("src"))
import pymongo
from config.config import Config
from booksomeplace.domain.booking import BookingService

# setting up the connection + collection
bookSvc = BookingService(Config())

# init vars
params = {
    'trend_city': None,
    'trend_stateProvince': 'England',
    'trend_locality': None,
    'trend_country': 'GB',
    'trend_postalCode': None,
}

# calculate dates for the report
date_format = '%Y-%m-%d %H:%M:%S'
factor = 0.10
today = datetime.now()
historic = timedelta(days=18 * 30)
hist_date = today - historic
today_str = today.strftime(date_format)
Пример #3
0
		_id : { "type" : "$rooms.roomType" }, 
		"count": { $sum: "$rooms.qty"}, 
		"total_sales": { $sum: "$total_by_type"}}
	}
]);
"""

# python imports
import os, sys
sys.path.append(os.path.realpath("src"))
import pymongo
from config.config import Config
from booksomeplace.domain.booking import BookingService

# setting up the connection + collection
service = BookingService(Config())

# formulate query
target_year = 2019
pipeline = [{
    '$match': {
        '$and': [{
            'bookingInfo.arrivalDate': {
                '$regex': '^' + str(target_year)
            },
            'bookingInfo.paymentStatus': 'confirmed'
        }]
    }
}, {
    '$unwind': '$rooms'
}, {
  'customer.customerName.last': 1,
  'customer.customerName.first': 1
 },
 limit: 10
}
"""

# python imports
import os, sys
sys.path.append(os.path.realpath("src"))
import pymongo
from config.config import Config
from booksomeplace.domain.booking import BookingService

# setting up the connection + collection
service = BookingService(Config())

# formulate query
total = 0
query = {'customer.customerContact.socMedia.facebook': {'$exists': True}}
proj = {
    'customer.customerContact': 1,
    'customer.customerName': 1,
    'totalPrice': 1
}
sort = [('customer.customerName.last', pymongo.ASCENDING),
        ('customer.customerName.first', pymongo.ASCENDING)]
result = service.fetch(query, proj, sort)

# display results
pattern = "{:12}\t{:40}\t{:8.2f}"