Support history data service remove same data

This commit is contained in:
xtaodada 2024-06-04 19:32:11 +08:00
parent 56e4b4295d
commit 2092f0274e
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 16 additions and 2 deletions

View File

@ -35,7 +35,8 @@ class HistoryDataAbyssServices(BaseService, HistoryDataBaseServices):
@staticmethod
def exists_data(data: HistoryData, old_data: List[HistoryData]) -> bool:
return any(d.data == data.data for d in old_data)
floor = data.data.get("floors")
return any(d.data.get("floors") == floor for d in old_data)
@staticmethod
def create(user_id: int, abyss_data: SpiralAbyss, character_data: Dict[int, int]):

@ -1 +1 @@
Subproject commit 481770502884afbce7d6b38f0448fec9e749885e
Subproject commit b1399182760c135ed8fe2479e329abb3084c7abb

View File

@ -101,6 +101,19 @@ class RefreshHistoryJob(Plugin):
notice_text = NOTICE_TEXT % ("旅行札记历史记录", now, uid, "旅行札记历史记录")
await self.send_notice(context, user_id, notice_text)
@handler.command(command="remove_same_history", block=False, admin=True)
async def remove_same_history(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE"):
user = update.effective_user
logger.info("用户 %s[%s] remove_same_history 命令请求", user.full_name, user.id)
message = update.effective_message
reply = await message.reply_text("正在执行移除相同数据历史记录任务,请稍后...")
text = "移除相同数据历史记录任务完成\n"
num1 = await self.history_data_abyss.remove_same_data()
text += f"深渊数据移除数量:{num1}\n"
num2 = await self.history_data_ledger.remove_same_data()
text += f"旅行札记数据移除数量:{num2}\n"
await reply.edit_text(text)
@handler.command(command="refresh_all_history", block=False, admin=True)
async def refresh_all_history(self, update: "Update", context: "ContextTypes.DEFAULT_TYPE"):
user = update.effective_user