예제 #1
0
파일: views.py 프로젝트: naqeeb/samples
def get_analytics_for_domain(sqs, data_domain):
    # State Analytic
    if data_domain == SEARCH_DATA_DOMAIN_PEOPLE:
        states_raw = sqs.facet_counts().get('fields', {}).get('loc_state', [])
        if len(states_raw) > 5:
            states_raw = states_raw[:5]
        states = [state for state in states_raw if state[1] > 0]
        return get_state_bar_graph(states)
    # Sector Analytic
    elif data_domain == SEARCH_DATA_DOMAIN_RECORD:
        orgs_raw = sqs.facet_counts().get('fields', {}).get('sector_id', [])
        orgs = \
            [(ORG_TYPE_SECTOR_MAPPING.get(i[0], 'Unknown'), i[1]) for i in orgs_raw if i[1] > 0]
        return get_sector_analytics(orgs)
    # Not Supported
    else:
        _log.error('Search Data Domain: %s is not supported' %data_domain)
예제 #2
0
파일: forms.py 프로젝트: naqeeb/samples
def get_sector_choices():
    sector_choices = [(x, ORG_TYPE_SECTOR_MAPPING.get('%s' % x)) for x in range(1, 7)]
    sector_choices = sorted(sector_choices, key=itemgetter(1))
    return sector_choices