def delete(self, email): try: user_dal = UserDAL() user = user_dal.get(email) if not user: raise NotFoundError("User:{} Not Found".format(email)) user_dal.delete(email) except Exception as e: raise e
def update(self, email, payload): try: user_dal = UserDAL() user = user_dal.get(email) if not user: raise NotFoundError("User:{} Not Found".format(email)) user_dal.update(email, payload) except Exception as e: raise e
def add(self, email, payload): try: user_dal = UserDAL() if not user_dal.get(email): raise NotFoundError("User:{} does not exists".format(email)) follow_dal = FollowingConnectionDAL() follow_dal.add(email, payload) # TODO: Background task to run dijkstra's algorithm to be done here except Exception as e: raise e
def add(self, payload): try: user_dal = UserDAL() if user_dal.get(payload["email"]): raise ConflictError( "User:{} Already Exists".format( payload["email"])) user_dal.add(payload) except Exception as e: raise e
def delete(self, email, follow_email): try: user_dal = UserDAL() user = user_dal.get(email) if not user: raise NotFoundError("User:{} Not Found".format(email)) conn_dal = FollowingConnectionDAL() conn_dal.delete(email, follow_email) # TODO: Background task to run dijkstra's algorithm to be done here except Exception as e: raise e
def get(self, email): try: user_dal = UserDAL() result = user_dal.get(email) if not result: raise NotFoundError("User:{} Not Found".format(email)) conn_dal = FollowingConnectionDAL() following_users = [ user["following_user_email"] for user in conn_dal.get(email) ] return {"following_users": following_users} except Exception as e: raise e
def get(self, email): try: user_dal = UserDAL() result = user_dal.get(email) if not result: raise NotFoundError("User:{} Not Found".format(email)) conn_dal = FollowingConnectionDAL() following_users = [] for user in conn_dal.get(email): following_users.append({ "following_user_email": user["following_user_email"], "created_at": user["created_at"] }) result["following_users"] = following_users return result except Exception as e: raise e
def get_all(self): try: user_dal = UserDAL() return user_dal.list() except Exception as e: raise e