Exemplo n.º 1
0
def first_way():
    start_time = time.time()
    all_locations = pharmacy_data['location']
    result = collection.find(all_locations,
                             {'id': "a5bad7a6-7111-4bfb-9c9d-29363db57731"})
    if result is not None:
        print(result['service'])
    print("Time Required : ", (time.time() - start_time))
Exemplo n.º 2
0
def send_email_receipt(response, formOptions, email_template_id=None):
    # Use the confirmationEmailInfo corresponding to email_template_id, falling back to formOptions.confirmationEmailInfo if none specified / found
    confirmationEmailInfo = None
    if email_template_id and formOptions.confirmationEmailTemplates:
        matchingConfirmationEmailTemplate = find(
            formOptions.confirmationEmailTemplates,
            lambda x: x.get("id") == email_template_id,
        )
        if matchingConfirmationEmailTemplate:
            confirmationEmailInfo = matchingConfirmationEmailTemplate.get(
                "confirmationEmailInfo")
    if not confirmationEmailInfo:
        confirmationEmailInfo = formOptions.confirmationEmailInfo
    if confirmationEmailInfo:
        email_sent = send_confirmation_email(response, confirmationEmailInfo)
Exemplo n.º 3
0
def getMovieFromDB(movieID):
	movies = [
				{	'title' : 'Turbo Horny',
					'ID' : 1
				},
				{
				'title' : 'Last holidays with two sisters',
				'ID' : 2
				},
				{
				'title' : 'My mum seen my when I watching X videos',
				'ID' : 3
				}
			]
			
	return find(movies, {'ID' : movieID})
Exemplo n.º 4
0
    def request_list(self, data, order, configKey):
        dictionary = {}
        query = {"$and": []}

        data_order = order.pop('sort_by', 'id')
        order_direction = order.pop('direction',
                                    '-').replace('asc',
                                                 '+').replace('desc', '-')
        search_filter = data.pop('filter', {})
        config_value = TableConfig.get_by_key(configKey, None).value

        pagination = find(config_value.pagination,
                          lambda item: item.name == data['namespace']) or find(
                              config_value.pagination,
                              lambda item: item.name == 'default')
        search_keys = []
        if "multi_search" in search_filter and len(
                search_filter["multi_search"]) > 0:
            print('test---------------', search_filter["multi_search"])

            columns = self._get_columns(configKey)
            for col in search_filter["multi_search"]:
                column = list(
                    filter(lambda x: x.order_by == col['column'], columns))
                if len(column) > 0:
                    column = column[0]
                    if not column.is_ref and self._generate_query(
                            column, col['value']) is not None:
                        search_keys.append(
                            self._generate_query(column, col['value']))
                    elif column.is_ref and self._generate_reference_query(
                            column, col['value']) is not None:
                        search_keys.append(
                            self._generate_reference_query(
                                column, col['value']))
                else:
                    search_keys.append({col['column']['name']: col['value']})

        if "search_all" in search_filter and search_filter["search_all"] != "":
            search_keys = []
            columns = list(
                filter(lambda x: x.is_global_searchable,
                       self._get_columns(configKey)))
            search_values = search_filter["search_all"].split(' ')
            for column in columns:
                for k in search_values:
                    if not column.is_ref and self._generate_query(
                            column, k) is not None:
                        search_keys.append(self._generate_query(column, k))
                    elif column.is_ref and self._generate_reference_query(
                            column, k) is not None:
                        search_keys.append(
                            self._generate_reference_query(column, k))

        search_keys, p_fields = self.split_properties_fields(search_keys)

        if search_keys:
            query["$and"].append({'$or': search_keys})
        # query["$and"] += self._handle_access(kwargs)
        page = self._model.objects(
            __raw__=query) if len(query['$and']) > 0 else self._model.objects
        offset = (data["page"]) * pagination['page_size']
        dictionary["length"] = page.count()
        if dictionary["length"] < offset:
            offset = 0
        page = page.skip(offset).limit(pagination['page_size']).order_by(
            '{}{}'.format(order_direction, data_order))
        if p_fields:
            page = self.filter_by_properties(p_fields, page)
        dictionary["list"] = self._model_serializer(page, many=True).data
        return dictionary
Exemplo n.º 5
0
def parseProBuild(matchData, timeLines, proSummoner, logger):
    region = platformToRegion(matchData['platformId'])

    logger.debug('Parsing Pro Build')
    proBuild = {}
    participantId = find(
        matchData['participantIdentities'], lambda identity: identity['player']
        ['accountId'] == proSummoner.accountId or identity['player'][
            'currentAccountId'] == proSummoner.accountId)['participantId']
    participantData = find(
        matchData['participants'],
        lambda participant: participant['participantId'] == participantId)

    proBuild['gameId'] = URID.generate(region, matchData['gameId'])
    proBuild['seasonId'] = matchData['seasonId']
    proBuild['queueId'] = matchData['queueId']
    proBuild['gameVersion'] = matchData['gameVersion']
    proBuild['gameDuration'] = matchData['gameDuration']
    proBuild['platformId'] = matchData['platformId']
    proBuild['gameMode'] = matchData['gameMode']
    proBuild['mapId'] = matchData['mapId']
    proBuild['gameType'] = matchData['gameType']
    proBuild['gameDuration'] = matchData['gameDuration']
    proBuild['gameCreation'] = matchData['gameCreation']
    proBuild['spell1Id'] = participantData['spell1Id']
    proBuild['spell2Id'] = participantData['spell2Id']
    proBuild['championId'] = participantData['championId']
    proBuild['highestAchievedSeasonTier'] = participantData[
        'highestAchievedSeasonTier']
    proBuild['masteries'] = participantData['masteries']
    proBuild['runes'] = participantData['runes']
    proBuild['stats'] = participantData['stats']
    proBuild['proSummonerId'] = proSummoner.id

    frames = timeLines['frames']
    frames = [frame for frame in frames if 'events' in frame]
    events = []

    for frame in frames:
        for event in frame['events']:
            if 'participantId' in event and event[
                    'participantId'] == participantId:
                events.append(event)

    itemsOrder = []
    skillsOrder = []

    for event in events:
        eventType = event['type']

        if eventType == 'ITEM_PURCHASED':
            itemsOrder.append({
                "itemId": event['itemId'],
                "timestamp": event['timestamp']
            })

        if eventType == 'ITEM_UNDO':
            itemBefore = event['beforeId']

            drop_right_while(itemsOrder,
                             lambda item: item['itemId'] == itemBefore)

        if eventType == 'ITEM_SOLD':
            drop_right_while(itemsOrder,
                             lambda item: item['itemId'] == event['itemId'])

        if eventType == 'SKILL_LEVEL_UP':
            skillsOrder.append({
                "skillSlot": event['skillSlot'],
                "levelUpType": event['levelUpType'],
                "timestamp": event['timestamp'],
            })

    proBuild['itemsOrder'] = itemsOrder
    proBuild['skillsOrder'] = skillsOrder

    logger.debug('Pro Build parsed success')

    return proBuild