Exemple #1
0
def get_companies_json(record_ids, **kwargs):
    memory_storage = vault.get_memory_storage()
    companies = memory_storage.get_index_keys_by_record_ids(
        'company_name', record_ids)
    if kwargs['_params']['company']:
        companies.add(kwargs['_params']['company'][0])

    result = [memory_storage.get_original_company_name(company)
              for company in companies]

    return [{'id': utils.safe_encode(c.lower()), 'text': c}
            for c in sorted(result)]
Exemple #2
0
def get_companies_json(records):
    query = flask.request.args.get('company_name') or ''
    options = set()
    for record in records:
        name = record['company_name']
        if name in options:
            continue
        if name.lower().find(query.lower()) >= 0:
            options.add(name)
    result = [{'id': utils.safe_encode(c.lower()), 'text': c}
              for c in sorted(options)]
    return result
Exemple #3
0
def get_companies_json(records):
    query = flask.request.args.get('company_name') or ''
    options = set()
    for record in records:
        name = record['company_name']
        if name in options:
            continue
        if name.lower().find(query.lower()) >= 0:
            options.add(name)
    result = [{'id': utils.safe_encode(c.lower()), 'text': c}
              for c in sorted(options)]
    return result
Exemple #4
0
def get_companies_json(record_ids, query_filter, **kwargs):
    memory_storage = vault.get_memory_storage()
    companies = memory_storage.get_index_keys_by_record_ids(
        'company_name', record_ids)

    result = []
    for company in companies:
        if query_filter(company):
            result.append(memory_storage.get_original_company_name(company))

    return [{'id': utils.safe_encode(c.lower()), 'text': c}
            for c in sorted(result)]
Exemple #5
0
def get_companies_json(record_ids, **kwargs):
    memory_storage = vault.get_memory_storage()
    companies = set(memory_storage.get_original_company_name(company)
                    for company in memory_storage.get_index_keys_by_record_ids(
                    'company_name', record_ids))

    if kwargs['_params']['company']:
        companies.add(memory_storage.get_original_company_name(
            kwargs['_params']['company'][0]))

    return [{'id': utils.safe_encode(c.lower()), 'text': c}
            for c in sorted(companies)]
Exemple #6
0
def make_link(title, uri=None, options=None):
    param_names = ('release', 'project_type', 'module', 'company', 'user_id',
                   'metric')
    param_values = {}
    for param_name in param_names:
        value = parameters.get_parameter({}, param_name)
        if value:
            param_values[param_name] = ','.join(value)
    if options:
        param_values.update(options)
    if param_values:
        uri += '?' + '&'.join(['%s=%s' % (n, utils.safe_encode(v))
                               for n, v in six.iteritems(param_values)])
    return '<a href="%(uri)s">%(title)s</a>' % {'uri': uri, 'title': title}
Exemple #7
0
def make_link(title, uri=None, options=None):
    param_names = ('release', 'project_type', 'module', 'company', 'user_id',
                   'metric')
    param_values = {}
    for param_name in param_names:
        v = parameters.get_parameter({}, param_name)
        if v:
            param_values[param_name] = ','.join(v)
    if options:
        param_values.update(options)
    if param_values:
        uri += '?' + '&'.join(['%s=%s' % (n, utils.safe_encode(v))
                               for n, v in six.iteritems(param_values)])
    return '<a href="%(uri)s">%(title)s</a>' % {'uri': uri, 'title': title}