⬆️ auto update by pre-commit hooks (#521)

* ⬆️ auto update by pre-commit hooks

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.3.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.0...v0.3.5)
- [github.com/psf/black: 24.1.1 → 24.3.0](https://github.com/psf/black/compare/24.1.1...24.3.0)
- [github.com/pre-commit/mirrors-eslint: v9.0.0-beta.1 → v9.0.0-rc.0](https://github.com/pre-commit/mirrors-eslint/compare/v9.0.0-beta.1...v9.0.0-rc.0)

* 💄 auto fix by pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot]
2024-04-02 15:07:29 +08:00
committed by GitHub
parent 230fe8f4a3
commit ddc5e0eed7
4 changed files with 65 additions and 47 deletions
+30 -22
View File
@@ -99,27 +99,33 @@ class Config(metaclass=Singleton):
# update
assert not isinstance(user_data, list)
subs: list = user_data.get("subs", [])
subs.append({
"target": target,
"target_type": target_type,
"target_name": target_name,
"cats": cats,
"tags": tags,
})
self.user_target.update({"subs": subs}, query)
else:
# insert
self.user_target.insert({
"user": user,
"user_type": user_type,
"subs": [{
subs.append(
{
"target": target,
"target_type": target_type,
"target_name": target_name,
"cats": cats,
"tags": tags,
}],
})
}
)
self.user_target.update({"subs": subs}, query)
else:
# insert
self.user_target.insert(
{
"user": user,
"user_type": user_type,
"subs": [
{
"target": target,
"target_type": target_type,
"target_name": target_name,
"cats": cats,
"tags": tags,
}
],
}
)
self.update_send_cache()
def list_subscribe(self, user, user_type) -> list[SubscribeContent]:
@@ -180,12 +186,14 @@ class Config(metaclass=Singleton):
for user in self.user_target.all():
for sub in user.get("subs", []):
if sub.get("target_type") not in supported_target_type:
to_del.append({
"user": user["user"],
"user_type": user["user_type"],
"target": sub["target"],
"target_type": sub["target_type"],
})
to_del.append(
{
"user": user["user"],
"user_type": user["user_type"],
"target": sub["target"],
"target_type": sub["target_type"],
}
)
continue
res[sub["target_type"]][sub["target"]].append(User(user["user"], user["user_type"]))
cat_res[sub["target_type"]][sub["target"]]["{}-{}".format(user["user_type"], user["user"])] = sub[