def rm_reduplicate():
    a = set()
    for i in Notice.where('cid in (%s, %s)' % (CID_NOTICE_WALL, CID_NOTICE_WALL_REPLY)).where(STATE_GTE_APPLY).order_by('id desc'):
        t = (i.from_id, i.to_id, i.cid, i.rid)
        if t not in a:
            if notice_id_count(*t):
                a.add(t)

    for from_id, to_id, cid, rid in a:
        for seq, i in enumerate(Notice.where(from_id=from_id, to_id=to_id, cid=cid, rid=rid).where(STATE_GTE_APPLY).order_by('id desc')):
            if seq:
                i.rm(to_id)
def rm_reduplicate():
    a = set()
    for i in Notice.where(
            'cid in (%s, %s)' %
        (CID_NOTICE_WALL,
         CID_NOTICE_WALL_REPLY)).where(STATE_GTE_APPLY).order_by('id desc'):
        t = (i.from_id, i.to_id, i.cid, i.rid)
        if t not in a:
            if notice_id_count(*t):
                a.add(t)

    for from_id, to_id, cid, rid in a:
        for seq, i in enumerate(
                Notice.where(
                    from_id=from_id, to_id=to_id, cid=cid,
                    rid=rid).where(STATE_GTE_APPLY).order_by('id desc')):
            if seq:
                i.rm(to_id)
示例#3
0
def notice_day():
    prev_pos = kv_int.get(KV_NOTICE_POS)
    c = Notice.raw_sql('select max(id) from notice where create_time<%s',
                       today_seconds())
    pos = c.fetchone()[0]
    if pos > prev_pos:
        d = defaultdict(OrderedSet)

        for i in Notice.where(state=STATE_APPLY).where('id>%s and id<=%s',
                                                       prev_pos, pos):
            cid = i.cid
            to_id = i.to_id
            if cid in NOTICE_MAIL_DAY and mail_notice_state(
                    to_id, CID_MAIL_DAY):
                d[to_id].add((i.from_id, cid, i.rid))

        for to_id, li in d.iteritems():
            notice_mail_day(to_id, li)
            sleep(0.1)

        kv_int.set(KV_NOTICE_POS, pos)
def notice_day():
    prev_pos = kv_int.get(KV_NOTICE_POS)
    c = Notice.raw_sql(
        'select max(id) from notice where create_time<%s', today_seconds()
    )
    pos = c.fetchone()[0]
    if pos > prev_pos:
        d = defaultdict(OrderedSet)

        for i in Notice.where(state=STATE_APPLY).where(
            'id>%s and id<=%s', prev_pos, pos
        ):
            cid = i.cid
            to_id = i.to_id
            if cid in NOTICE_MAIL_DAY and mail_notice_state(to_id, CID_MAIL_DAY):
                d[to_id].add((i.from_id, cid, i.rid))

        for to_id, li in d.iteritems():
            notice_mail_day(to_id, li)
            sleep(0.1)

        kv_int.set(KV_NOTICE_POS, pos)