Exemplo n.º 1
0
def Main(query):

    Put(ctx, 'prefix1euo', 1)
    Put(ctx, 'prefix1e', 2)
    Put(ctx, 'prefix1__osetuh', 3)

    Put(ctx, 'blah', 'Hello Storage Find')

    result_iter = Find(ctx, query)

    items = []
    keys = []
    count = 0
    while result_iter.IterNext():
        val = result_iter.IterValue()
        items.append(val)
        keys.append(result_iter.IterKey())
        if query == 'pre' and count == 1:
            break

        count += 1

    if query == 'pref':
        return keys

    return items
Exemplo n.º 2
0
def get_all_tickets():

    context = GetContext()

    result_iter = Find(context, TICKET)

    pre = len(TICKET)

    tickets = []

    while result_iter.IterNext():

        key = result_iter.IterKey()

        val = result_iter.IterValue()

        key_length = len(key)

        ticket = deserialize_bytearray(val)

        ticket_no = substr(key, pre, key_length)

        ticket.append(ticket_no)

        rank = get_rank(ticket_no)

        ticket.append(rank)

        tickets.append(serialize_array(ticket))

    return serialize_array(tickets)
Exemplo n.º 3
0
def get_all_drawings():

    context = GetContext()

    result_iter = Find(context, OPERATOR)

    pre = len(OPERATOR)

    operators = []

    while result_iter.IterNext():

        operator = []

        key = result_iter.IterKey()

        created_at = result_iter.IterValue()

        account = substr(key, pre, 20)

        game_no = substr(key, pre + 20, len(key) - (pre + 20))

        # --- Get total entries of the game
        previous_ticket = concat(LAST_DRAWING_TICKET, game_no - 1)

        previous_ticket = Get(context, previous_ticket)

        last_ticket = concat(LAST_DRAWING_TICKET, game_no)

        last_ticket = Get(context, last_ticket)

        total_entries = last_ticket - previous_ticket

        # -- Get winning numbers

        winning_numbers_key = concat(WINNING_NUMBERS, game_no)
        winning_numbers = Get(context, winning_numbers_key)

        operator.append(game_no)

        operator.append(winning_numbers)

        operator.append(account)

        operator.append(total_entries)

        operator.append(created_at)

        operators.append(serialize_array(operator))

    data = serialize_array(operators)

    return data
Exemplo n.º 4
0
def get_all_operators_by_player(account):

    context = GetContext()

    iter_key = concat(OPERATOR, account)

    pre = len(iter_key)

    result_iter = Find(context, iter_key)

    operators = []

    while result_iter.IterNext():

        operator = []

        key = result_iter.IterKey()

        created_at = result_iter.IterValue()

        key_length = len(key)

        game_no = substr(key, pre, key_length)

        previous_ticket = concat(LAST_DRAWING_TICKET, game_no - 1)

        previous_ticket = Get(context, previous_ticket)

        last_ticket = concat(LAST_DRAWING_TICKET, game_no)

        last_ticket = Get(context, last_ticket)

        operator.append(game_no)

        operator.append(last_ticket - previous_ticket)

        operator.append(created_at)

        operators.append(serialize_array(operator))

    data = serialize_array(operators)

    return data
Exemplo n.º 5
0
def get_all_verifying():

    context = GetContext()

    result_iter = Find(context, VERIFIER)

    pre = len(VERIFIER)

    verifiers = []

    while result_iter.IterNext():

        verifier = []

        key = result_iter.IterKey()

        created_at = result_iter.IterValue()

        account = substr(key, pre, 20)

        ticket_no = substr(key, pre + 20, len(key) - (pre + 20))

        rank = get_rank(ticket_no)

        verifier.append(ticket_no)

        verifier.append(account)

        verifier.append(rank)

        verifier.append(created_at)

        verifiers.append(serialize_array(verifier))

    data = serialize_array(verifiers)

    return data
Exemplo n.º 6
0
def get_all_verifiers_by_player(account):

    context = GetContext()

    iter_key = concat(VERIFIER, account)

    pre = len(iter_key)

    result_iter = Find(context, iter_key)

    verifiers = []

    while result_iter.IterNext():

        verifier = []

        key = result_iter.IterKey()

        created_at = result_iter.IterValue()

        key_length = len(key)

        ticket_no = substr(key, pre, key_length)

        rank = get_rank(ticket_no)

        verifier.append(ticket_no)

        verifier.append(rank)

        verifier.append(created_at)

        verifiers.append(serialize_array(verifier))

    data = serialize_array(verifiers)

    return data