Beispiel #1
0
def migrate_note_recent():
    recent_list = dbutil.prefix_iter("note_recent", include_key=True)
    for key, item in recent_list:
        dbutil.delete(key)

    for item in dbutil.prefix_iter("note_tiny"):
        if item.type != "group":
            dbutil.zadd("note_recent:%s" % item.creator, item.mtime, item.id)
        if item.is_public:
            dbutil.zadd("note_recent:public", item.mtime, item.id)
    return "迁移完成!"
Beispiel #2
0
def kv_put_note(note_id, note):
    priority = note.priority
    mtime = note.mtime
    creator = note.creator
    atime = note.atime
    dbutil.put("note_full:%s" % note_id, note)

    score = "%02d:%s" % (priority, mtime)
    if note.is_deleted:
        dbutil.zrem("note_recent:%s" % creator, note_id)
        dbutil.zrem("note_visit:%s" % creator, note_id)
    else:
        dbutil.zadd("note_recent:%s" % creator, score, note_id)
        dbutil.zadd("note_visit:%s" % creator, atime, note_id)

    del note['content']
    del note['data']
    dbutil.put("note_tiny:%s:%020d" % (note.creator, int(note_id)), note)
Beispiel #3
0
def create_note(note_dict):
    content = note_dict["content"]
    data = note_dict["data"]
    creator = note_dict["creator"]
    priority = note_dict["priority"]
    mtime = note_dict["mtime"]

    if xconfig.DB_ENGINE == "sqlite":
        db = xtables.get_file_table()
        id = db.insert(**note_dict)
        update_note_content(id, content, data)
        return id
    else:
        id = dbutil.timeseq()
        key = "note_full:%s" % id
        note_dict["id"] = id
        dbutil.put(key, note_dict)
        score = "%02d:%s" % (priority, mtime)
        dbutil.zadd("note_recent:%s" % creator, score, id)
        update_children_count(note_dict["parent_id"])
        return id
Beispiel #4
0
def update_note_rank(note):
    mtime = note.mtime
    atime = note.atime
    creator = note.creator
    note_id = note.id

    if note.is_deleted:
        dbutil.zrem("note_recent:%s" % creator, note_id)
        dbutil.zrem("note_visit:%s" % creator, note_id)
        dbutil.zrem("note_recent:public", note_id)
    elif note.type != "group":
        # 分组不需要记录
        dbutil.zadd("note_recent:%s" % creator, mtime, note_id)
        dbutil.zadd("note_visit:%s" % creator, atime, note_id)
        if note.is_public:
            dbutil.zadd("note_recent:public", mtime, note_id)