예제 #1
0
 def add_like(self, liker_id, article_id):
     req = database_pb2.LikeEntry(
         user_id=liker_id,
         article_id=article_id,
     )
     res = self.like.AddLike(req, self.ctx)
     self.assertNotEqual(res.result_type, general_pb2.ResultType.ERROR)
     return res
예제 #2
0
 def _add_like_to_user_model(self, user_id, article_id):
     req = db_pb.LikeEntry(
         user_id=user_id,
         article_id=article_id,
     )
     resp = self._post_recommendation_stub.UpdateModel(req)
     if resp.result_type != general_pb2.ResultType.OK:
         self._logger.error(
             "UpdateModel for post recommendation failed: %s", resp.message)
예제 #3
0
 def _add_like_to_db(self, user_id, article_id):
     req = db_pb.LikeEntry(
         user_id=user_id,
         article_id=article_id,
     )
     resp = self._db.AddLike(req)
     if resp.result_type != general_pb2.ResultType.OK:
         return resp.error
     return None
예제 #4
0
 def remove_like_from_db(self, user_id, article_id):
     req = dbpb.LikeEntry(
         user_id=user_id,
         article_id=article_id,
     )
     resp = self._db.RemoveLike(req)
     if resp.result_type != general_pb2.ResultType.OK:
         self._logger.error("Error from DB: %s", resp.error)
         return False
     return True