forked from Hay1tsme/artemis
Deduplicate rating list functions
This commit is contained in:
@ -528,6 +528,7 @@ class OngekiProfileData(BaseData):
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def delete_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
|
||||
sql = delete(rival).where(rival.c.user==aime_id, rival.c.rivalUserId==rival_id)
|
||||
result = await self.execute(sql)
|
||||
@ -536,7 +537,13 @@ class OngekiProfileData(BaseData):
|
||||
else:
|
||||
return result.rowcount
|
||||
|
||||
async def _put_profile_rating(self, rating_type: str, aime_id: int, version: int, rating_data: List[Dict]):
|
||||
async def put_profile_rating(
|
||||
self,
|
||||
aime_id: int,
|
||||
version: int,
|
||||
rating_type: str,
|
||||
rating_data: List[Dict],
|
||||
):
|
||||
inserted_values = [
|
||||
{"user": aime_id, "version": version, "type": rating_type, "index": i, **x}
|
||||
for (i, x) in enumerate(rating_data)
|
||||
@ -553,51 +560,3 @@ class OngekiProfileData(BaseData):
|
||||
return
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
async def put_profile_rating_best(self, aime_id: int, version: int, rating_best_data: List[Dict]):
|
||||
return await self._put_profile_rating(
|
||||
"best",
|
||||
aime_id,
|
||||
version,
|
||||
rating_best_data,
|
||||
)
|
||||
|
||||
async def put_profile_rating_best_new(self, aime_id: int, version: int, rating_best_new_data: List[Dict]):
|
||||
return await self._put_profile_rating(
|
||||
"best_new",
|
||||
aime_id,
|
||||
version,
|
||||
rating_best_new_data,
|
||||
)
|
||||
|
||||
async def put_profile_rating_hot(self, aime_id: int, version: int, rating_hot_data: List[Dict]):
|
||||
return await self._put_profile_rating(
|
||||
"hot",
|
||||
aime_id,
|
||||
version,
|
||||
rating_hot_data,
|
||||
)
|
||||
|
||||
async def put_profile_rating_next(self, aime_id: int, version: int, rating_next_data: List[Dict]):
|
||||
return await self._put_profile_rating(
|
||||
"next",
|
||||
aime_id,
|
||||
version,
|
||||
rating_next_data,
|
||||
)
|
||||
|
||||
async def put_profile_rating_next_new(self, aime_id: int, version: int, rating_next_new_data: List[Dict]):
|
||||
return await self._put_profile_rating(
|
||||
"next_new",
|
||||
aime_id,
|
||||
version,
|
||||
rating_next_new_data,
|
||||
)
|
||||
|
||||
async def put_profile_rating_next_hot(self, aime_id: int, version: int, rating_next_hot_data: List[Dict]):
|
||||
return await self._put_profile_rating(
|
||||
"next_hot",
|
||||
aime_id,
|
||||
version,
|
||||
rating_next_hot_data,
|
||||
)
|
||||
|
Reference in New Issue
Block a user