Beispiel #1
0
def fetch_page_of_provider_prospects(cursor_key=None,
                                     page_size=50,
                                     search_keyword=None):
    ''' 
        Returns three values: prospects, next_curs, prev_curs
        
        Search uses a workaround to imitate LIKE:
        http://stackoverflow.com/questions/47786/google-app-engine-is-it-possible-to-do-a-gql-like-query
    
    '''
    cursor = Cursor(urlsafe=cursor_key)
    if search_keyword:
        limit = search_keyword + u"\ufffd"
        query = ProviderProspect.query(
            ProviderProspect.last_name >= search_keyword,
            ProviderProspect.last_name < limit)

        query = query.order(ProviderProspect.last_name)
    else:
        query = ProviderProspect.query()
    # forward and back
    forward_query = query.order(ProviderProspect.category,
                                ProviderProspect.last_name,
                                ProviderProspect.key)
    backward_query = query.order(-ProviderProspect.category,
                                 -ProviderProspect.last_name,
                                 -ProviderProspect.key)
    # fetch next
    prospects, next_curs, more = forward_query.fetch_page(page_size,
                                                          start_cursor=cursor)
    logging.info('next_curs: %s  more: %s' % (next_curs, more))
    # fetch prev (just to get cursor position)
    if cursor_key:
        reversed_cursor = cursor.reversed()
        prev_prospects, prev_curs, prev_more = backward_query.fetch_page(
            page_size, start_cursor=reversed_cursor)
        # reverse the cursor (GAE docs is wrong on this)
        if prev_curs:
            prev_curs = prev_curs.reversed()
    else:
        prev_curs = None
        prev_more = None

    if not more:
        next_curs = None

    #if not prev_more:
    #    prev_curs = None
    return prospects, next_curs, prev_curs
Beispiel #2
0
def fetch_page_of_provider_prospects(cursor_key=None, page_size=50, search_keyword=None):
    ''' 
        Returns three values: prospects, next_curs, prev_curs
        
        Search uses a workaround to imitate LIKE:
        http://stackoverflow.com/questions/47786/google-app-engine-is-it-possible-to-do-a-gql-like-query
    
    '''
    cursor = Cursor(urlsafe=cursor_key)
    if search_keyword:
        limit = search_keyword + u"\ufffd"
        query = ProviderProspect.query(ProviderProspect.last_name >= search_keyword, ProviderProspect.last_name < limit)
        
        query = query.order(ProviderProspect.last_name)
    else:
        query = ProviderProspect.query()
    # forward and back
    forward_query = query.order(ProviderProspect.category, ProviderProspect.last_name, ProviderProspect.key)
    backward_query = query.order(-ProviderProspect.category, -ProviderProspect.last_name, -ProviderProspect.key)
    # fetch next
    prospects, next_curs, more = forward_query.fetch_page(page_size, start_cursor=cursor)
    logging.info('next_curs: %s  more: %s' % (next_curs, more))
    # fetch prev (just to get cursor position)
    if cursor_key:
        reversed_cursor = cursor.reversed()
        prev_prospects, prev_curs, prev_more = backward_query.fetch_page(page_size, start_cursor=reversed_cursor)
        # reverse the cursor (GAE docs is wrong on this)
        if prev_curs:
            prev_curs = prev_curs.reversed()
    else:
        prev_curs = None
        prev_more = None
    
    if not more:
        next_curs = None

    #if not prev_more:
    #    prev_curs = None
    return prospects, next_curs, prev_curs
Beispiel #3
0
def get_prospect_from_prospect_id(prospect_id):
    if prospect_id:
        return ProviderProspect.query(
            ProviderProspect.prospect_id == prospect_id).get()
    else:
        return None
Beispiel #4
0
def get_provider_prospect_from_email(email):
    prospect = ProviderProspect.query(ProviderProspect.email == email).get()
    logging.debug('ProviderProspect for email %s is %s' % (email, prospect))
    return prospect
Beispiel #5
0
def fetch_prospects():
    return ProviderProspect.query().order(ProviderProspect.last_name,
                                          ProviderProspect.first_name)
Beispiel #6
0
def fetch_prospects():
    return ProviderProspect.query().order(ProviderProspect.last_name, ProviderProspect.first_name)
Beispiel #7
0
def get_prospect_from_prospect_id(prospect_id):
    if prospect_id:
        return ProviderProspect.query(ProviderProspect.prospect_id == prospect_id).get()
    else:
        return None  
Beispiel #8
0
def get_provider_prospect_from_email(email):
    prospect = ProviderProspect.query(ProviderProspect.email == email).get()
    logging.debug('ProviderProspect for email %s is %s' % (email, prospect))
    return prospect