Esempio n. 1
0
def get_bpd(records):
    result = []
    for record in records:
        if record['record_type'] in ['bpd', 'bpc']:
            mention_date = record.get('mention_date')
            if mention_date:
                date = helpers.format_date(mention_date)
            else:
                date = 'never'
            result.append({
                'date':
                date,
                'status':
                record['lifecycle_status'],
                'metric':
                record.get('mention_count') or 0,
                'id':
                record['name'],
                'name':
                record['name'],
                'link':
                helpers.make_blueprint_link(record['module'], record['name'])
            })

    result.sort(key=lambda x: x['metric'], reverse=True)
    utils.add_index(result)

    return result
Esempio n. 2
0
def get_bpd(records, **kwargs):
    result = []
    for record in records:
        if record["record_type"] in ["bpd", "bpc"]:
            record = vault.extend_record(record)
            mention_date = record.get("mention_date")
            if mention_date:
                date = helpers.format_date(mention_date)
            else:
                date = "never"
            result.append(
                {
                    "date": date,
                    "status": record["lifecycle_status"],
                    "metric": record.get("mention_count") or 0,
                    "id": record["name"],
                    "name": record["name"],
                    "link": helpers.make_blueprint_link(record["module"], record["name"]),
                }
            )

    result.sort(key=lambda x: x["metric"], reverse=True)
    utils.add_index(result)

    return result
Esempio n. 3
0
def get_members(records):
    response = []
    for record in records:
        nr = dict([(k, record[k]) for k in
                   ['author_name', 'date', 'company_name', 'member_uri']])
        nr['date_str'] = helpers.format_date(nr['date'])
        response.append(nr)

    response.sort(key=lambda x: x['date'], reverse=True)
    utils.add_index(response)

    return response
Esempio n. 4
0
def get_members(records, **kwargs):
    response = []
    for record in records:
        record = vault.extend_record(record)
        nr = dict([(k, record[k]) for k in ["author_name", "date", "company_name", "member_uri"]])
        nr["date_str"] = helpers.format_date(nr["date"])
        response.append(nr)

    response.sort(key=lambda x: x["date"], reverse=True)
    utils.add_index(response)

    return response
Esempio n. 5
0
def get_members(records, **kwargs):
    response = []
    for record in records:
        record = vault.extend_record(record)
        nr = dict([(k, record[k]) for k in
                   ['author_name', 'date', 'company_name', 'member_uri']])
        nr['date_str'] = helpers.format_date(nr['date'])
        response.append(nr)

    response.sort(key=lambda x: x['date'], reverse=True)
    utils.add_index(response)

    return response
Esempio n. 6
0
def get_bpd(records):
    result = []
    for record in records:
        if record['record_type'] in ['bpd', 'bpc']:
            mention_date = record.get('mention_date')
            if mention_date:
                date = helpers.format_date(mention_date)
            else:
                date = 'never'
            result.append({
                'date': date,
                'status': record['lifecycle_status'],
                'metric': record.get('mention_count') or 0,
                'id': record['name'],
                'name': record['name'],
                'link': helpers.make_blueprint_link(record['module'],
                                                    record['name'])
            })

    result.sort(key=lambda x: x['metric'], reverse=True)

    return result
Esempio n. 7
0
def get_new_companies(records, **kwargs):

    days = int(flask.request.args.get('days') or reports.DEFAULT_DAYS_COUNT)
    start_date = int(time.time()) - days * 24 * 60 * 60

    result = {}
    for record in records:
        company_name = record['company_name']
        date = record['date']

        if company_name not in result or result[company_name] > date:
            result[company_name] = date

    response = list(({'name': company_name,
                      'date': result[company_name],
                      'date_str': helpers.format_date(result[company_name])})
                    for company_name in result
                    if result[company_name] >= start_date)

    response.sort(key=lambda x: x['date'], reverse=True)
    utils.add_index(response)

    return response