コード例 #1
0
ファイル: parse.py プロジェクト: maocis/ybk
def parse():
    nav = 'parse'
    url = request.args.get('url')
    num_parsed = Announcement.count({
        'parsed': True,
        'type_': {
            '$in': ['offer', 'result']
        }
    })
    num_total = Announcement.count({'type_': {'$in': ['offer', 'result']}})
    if url:
        announcement = Announcement.query_one({'url': url})
        colls = list(Collection.query({'from_url': url}))
        for coll in colls:
            if coll.offers_at:
                coll.offers_at2 = coll.offers_at.strftime('%Y%m%d')
            if coll.offer_cash_ratio:
                coll.offer_cash_ratio = '{:2.0f}%'.format(
                    coll.offer_cash_ratio * 100)
            if coll.offer_price:
                coll.offer_price = str(coll.offer_price)
                if coll.offer_price.endswith('.0'):
                    coll.offer_price = coll.offer_price[:-2]
    all_done = num_parsed == num_total
    return render_template('admin/parse.html', **locals())
コード例 #2
0
def announcement():
    locals()['type_to_cn'] = type_to_cn
    nav = 'announcement'
    tab = 'raw'
    type_ = request.args.get('type', '')
    typecn = type_to_cn(type_)
    exchange = request.args.get('exchange', '')
    page = int(request.args.get('page', 1) or 1)

    limit = 50
    skip = limit * (page - 1)

    cond = {}
    if type_:
        cond['type_'] = type_
    if exchange:
        cond['exchange'] = exchange

    total = Announcement.count(cond)
    pagination = Pagination(page, limit, total)
    exchanges = list(sorted(list(e.abbr for e in Exchange.query())))
    types = ['offer', 'result', 'stock']
    announcements = list(
        Announcement.query(cond,
                           sort=[('updated_at', -1)],
                           skip=skip, limit=limit))
    for a in announcements:
        a.typecn = type_to_cn(a.type_)

    ex = Exchange.query_one(sort=[('updated_at', -1)])
    updated_at = None if not ex else ex.updated_at

    return render_template('frontend/announcement.html', **locals())
コード例 #3
0
ファイル: parse.py プロジェクト: sopnic/ybk
def parse():
    nav = "parse"
    url = request.args.get("url")
    num_parsed = Announcement.count({"parsed": True, "type_": {"$in": ["offer", "result"]}})
    num_total = Announcement.count({"type_": {"$in": ["offer", "result"]}})
    if url:
        announcement = Announcement.query_one({"url": url})
        colls = list(Collection.query({"from_url": url}))
        for coll in colls:
            if coll.offers_at:
                coll.offers_at2 = coll.offers_at.strftime("%Y%m%d")
            if coll.offer_cash_ratio:
                coll.offer_cash_ratio = "{:2.0f}%".format(coll.offer_cash_ratio * 100)
            if coll.offer_price:
                coll.offer_price = str(coll.offer_price)
                if coll.offer_price.endswith(".0"):
                    coll.offer_price = coll.offer_price[:-2]
    all_done = num_parsed == num_total
    return render_template("admin/parse.html", **locals())