Exemplo n.º 1
0
 def requery_not_translate_comments(cls, skips=[], exps=["cn", "tw"]):
     conds = [(Comments.country_or_area != lan) for lan in exps]
     conds.append(Comments.content_trans_cn == "")
     skip_conds = [(Comments.content != content) for content in skips]
     result = db_session.query(Comments).filter(and_(
         *conds, *skip_conds)).order_by(Comments.create_timestamp,
                                        Comments.version).all()
     return result
Exemplo n.º 2
0
    def update_translate_comments(cls, mapdata):
        olds = mapdata.keys()
        conds = [(Comments.content == key) for key in olds]
        results = db_session.query(Comments).filter(*conds).all()

        for result in results:
            #mylogger.info("update_translate_comment:", result.content, "-->", mapdata[result.content])
            result.content_trans_cn = mapdata[result.content]

        db_session.commit()
Exemplo n.º 3
0
 def is_comments_exist(cls, comment_id):
     try:
         result = db_session.query(Comments).filter(
             Comments.id == comment_id).all()
         if (0 != len(result)):
             return RecordExistType.Exist
         else:
             return RecordExistType.NotExist
     except Exception as e:
         mylogger.error("Comments.is_comments_exist: {0}".format(str(e)))
         return RecordExistType.Error
Exemplo n.º 4
0
 def update_translate_comment(cls, old, tran):
     db_session.query(Comments).filter(Comments.content == old).update(
         {Comments.content_trans_cn: tran})
     db_session.commit()
Exemplo n.º 5
0
 def requry_record_after_timestamp(cls, appid, last_timestamp):
     result = db_session.query(Comments).filter(
         and_(Comments.update_timestamp > last_timestamp,
              Comments.app_id == appid)).all()
     return result