def status_get():
    """Displays the latest mapping statistics"""

    status = service_status.get_status()

    if status is None:
        # We ensure we can connect to the database during the status check
        with db.DBConn() as conn:
            try:
                number_of_mappings = db.query_db(conn, '''
                            SELECT COUNT(*) FROM projects
                            ''', one=True)['count']
            except psycopg2.errors.UndefinedTable:
                safe_fail_request(500, "DB uninitialized")

            current_rate = db.get_latest_rate(conn)

        status = {
            'status': 'ok',
            'project_count': number_of_mappings,
            'rate': current_rate
        }

        service_status.set_status(status)
    return status
示例#2
0
def status_get():
    """Displays the latest mapping statistics"""

    status = cache.get_status()

    if status is None:
        # We ensure we can connect to the database during the status check
        db1 = db.get_db()

        number_of_mappings = db.query_db(db1,
                                         '''
                    SELECT COUNT(*) FROM projects
                    ''',
                                         one=True)['count']

        current_rate = db.get_latest_rate(db1)

        status = {
            'status': 'ok',
            'project_count': number_of_mappings,
            'rate': current_rate
        }

        cache.set_status(status)
    return status
示例#3
0
def projects_get():
    logger.info("Getting list of all projects")
    projects = db.query_db(get_db(),
                           'select project_id, time_added from projects')
    return ProjectList().dump(projects)
示例#4
0
def projects_get():
    logger.info("Getting list of all projects")
    with DBConn() as conn:
        projects = db.query_db(conn,
                               'select project_id, time_added from projects')
    return ProjectList().dump(projects)