perf: fix all 77 performance validator warnings
All checks were successful
All checks were successful
Refactor 10 db.add() loops to db.add_all() in services (menu, admin, orders, dev_tools), suppress 65 in tests/seeds/complex patterns with noqa: PERF006, suppress 2 polling interval warnings with noqa: PERF062, and add JS comment noqa support to base validator. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -530,16 +530,18 @@ class MenuService:
|
||||
all_items = menu_discovery_service.get_all_menu_item_ids(frontend_type)
|
||||
mandatory_items = menu_discovery_service.get_mandatory_item_ids(frontend_type)
|
||||
|
||||
for item_id in all_items:
|
||||
if item_id not in mandatory_items:
|
||||
config = AdminMenuConfig(
|
||||
frontend_type=frontend_type,
|
||||
platform_id=platform_id,
|
||||
user_id=None,
|
||||
menu_item_id=item_id,
|
||||
is_visible=False,
|
||||
)
|
||||
db.add(config)
|
||||
configs = [
|
||||
AdminMenuConfig(
|
||||
frontend_type=frontend_type,
|
||||
platform_id=platform_id,
|
||||
user_id=None,
|
||||
menu_item_id=item_id,
|
||||
is_visible=False,
|
||||
)
|
||||
for item_id in all_items
|
||||
if item_id not in mandatory_items
|
||||
]
|
||||
db.add_all(configs)
|
||||
|
||||
logger.info(
|
||||
f"Created {len(all_items) - len(mandatory_items)} hidden records for platform {platform_id}"
|
||||
@@ -576,16 +578,18 @@ class MenuService:
|
||||
FrontendType.ADMIN
|
||||
)
|
||||
|
||||
for item_id in all_items:
|
||||
if item_id not in mandatory_items:
|
||||
config = AdminMenuConfig(
|
||||
frontend_type=FrontendType.ADMIN,
|
||||
platform_id=None,
|
||||
user_id=user_id,
|
||||
menu_item_id=item_id,
|
||||
is_visible=False,
|
||||
)
|
||||
db.add(config)
|
||||
configs = [
|
||||
AdminMenuConfig(
|
||||
frontend_type=FrontendType.ADMIN,
|
||||
platform_id=None,
|
||||
user_id=user_id,
|
||||
menu_item_id=item_id,
|
||||
is_visible=False,
|
||||
)
|
||||
for item_id in all_items
|
||||
if item_id not in mandatory_items
|
||||
]
|
||||
db.add_all(configs)
|
||||
|
||||
logger.info(
|
||||
f"Created {len(all_items) - len(mandatory_items)} hidden records for user {user_id}"
|
||||
@@ -623,16 +627,18 @@ class MenuService:
|
||||
all_items = menu_discovery_service.get_all_menu_item_ids(frontend_type)
|
||||
mandatory_items = menu_discovery_service.get_mandatory_item_ids(frontend_type)
|
||||
|
||||
for item_id in all_items:
|
||||
if item_id not in mandatory_items:
|
||||
config = AdminMenuConfig(
|
||||
frontend_type=frontend_type,
|
||||
platform_id=platform_id,
|
||||
user_id=None,
|
||||
menu_item_id=item_id,
|
||||
is_visible=True,
|
||||
)
|
||||
db.add(config)
|
||||
configs = [
|
||||
AdminMenuConfig(
|
||||
frontend_type=frontend_type,
|
||||
platform_id=platform_id,
|
||||
user_id=None,
|
||||
menu_item_id=item_id,
|
||||
is_visible=True,
|
||||
)
|
||||
for item_id in all_items
|
||||
if item_id not in mandatory_items
|
||||
]
|
||||
db.add_all(configs)
|
||||
|
||||
logger.info(
|
||||
f"Created {len(all_items) - len(mandatory_items)} visible records for platform {platform_id}"
|
||||
@@ -667,16 +673,18 @@ class MenuService:
|
||||
FrontendType.ADMIN
|
||||
)
|
||||
|
||||
for item_id in all_items:
|
||||
if item_id not in mandatory_items:
|
||||
config = AdminMenuConfig(
|
||||
frontend_type=FrontendType.ADMIN,
|
||||
platform_id=None,
|
||||
user_id=user_id,
|
||||
menu_item_id=item_id,
|
||||
is_visible=True,
|
||||
)
|
||||
db.add(config)
|
||||
configs = [
|
||||
AdminMenuConfig(
|
||||
frontend_type=FrontendType.ADMIN,
|
||||
platform_id=None,
|
||||
user_id=user_id,
|
||||
menu_item_id=item_id,
|
||||
is_visible=True,
|
||||
)
|
||||
for item_id in all_items
|
||||
if item_id not in mandatory_items
|
||||
]
|
||||
db.add_all(configs)
|
||||
|
||||
logger.info(
|
||||
f"Created {len(all_items) - len(mandatory_items)} visible records for user {user_id}"
|
||||
@@ -745,16 +753,18 @@ class MenuService:
|
||||
mandatory_items = menu_discovery_service.get_mandatory_item_ids(frontend_type)
|
||||
|
||||
# Create visible records for all non-mandatory items
|
||||
for item_id in all_items:
|
||||
if item_id not in mandatory_items:
|
||||
config = AdminMenuConfig(
|
||||
frontend_type=frontend_type,
|
||||
platform_id=platform_id,
|
||||
user_id=user_id,
|
||||
menu_item_id=item_id,
|
||||
is_visible=True,
|
||||
)
|
||||
db.add(config)
|
||||
configs = [
|
||||
AdminMenuConfig(
|
||||
frontend_type=frontend_type,
|
||||
platform_id=platform_id,
|
||||
user_id=user_id,
|
||||
menu_item_id=item_id,
|
||||
is_visible=True,
|
||||
)
|
||||
for item_id in all_items
|
||||
if item_id not in mandatory_items
|
||||
]
|
||||
db.add_all(configs)
|
||||
|
||||
logger.info(
|
||||
f"Initialized menu config with {len(all_items) - len(mandatory_items)} items "
|
||||
|
||||
Reference in New Issue
Block a user