Exemple #1
0
def get_user_activity():
    u_id = request.cookies.get('u_id')
    crawlers, crawler_total = CrawlerDao.batch_get_by_status(u_id, page=-1)
    _, done_total = CrawlerDao.batch_get_by_status(u_id, page=-1, status=Crawler_Status.DONE)
    logs, logs_total = UserLogDao.get_by_user(u_id)
    return jsonify(
        crawlers={
            'data': crawlers,
            'crawler_total': crawler_total,
            'done_total': done_total
        },
        actions={
            'data': logs,
            'action_total': logs_total
        }
    )
def get_tasks():
    page = int(request.args.get('page', 1))
    per_page = int(request.args.get('per_page', 20))
    status = request.args.get('status')
    u_id = request.cookies.get('u_id')
    if status is not None:
        status = int(status)
    crawlers, total = CrawlerDao.batch_get_by_status(u_id,
                                                     page=page,
                                                     per_page=per_page,
                                                     status=status)
    return jsonify({
        'page': page,
        "per_page": per_page,
        'total': total,
        'data': crawlers
    })