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
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)
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
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