instructions and validations tested
This commit is contained in:
@@ -53,6 +53,7 @@ class PageInfo:
|
||||
"/create?site=AccountCluster": ["/accounts/create"],
|
||||
},
|
||||
"""
|
||||
|
||||
NAME: str
|
||||
PAGE_URL: str
|
||||
PAGEINFO: Dict[str, Any]
|
||||
@@ -262,7 +263,7 @@ class CategoryCluster:
|
||||
|
||||
TAGS: list
|
||||
PREFIX: str
|
||||
PAGEINFO: Optional[Dict['str', PageInfo]]
|
||||
PAGEINFO: Optional[Dict["str", PageInfo]]
|
||||
DESCRIPTION: str
|
||||
ENDPOINTS: dict[str, MethodToEvent] # {"MethodToEvent": MethodToEvent, ...}
|
||||
SUBCATEGORY: Optional[List["CategoryCluster"]] # [CategoryCluster, ...]
|
||||
@@ -277,7 +278,7 @@ class CategoryCluster:
|
||||
description: str,
|
||||
endpoints: dict[str, MethodToEvent],
|
||||
sub_category: list,
|
||||
pageinfo: Optional[Dict['str', PageInfo]] = None,
|
||||
pageinfo: Optional[Dict["str", PageInfo]] = None,
|
||||
include_in_schema: Optional[bool] = True,
|
||||
is_client: Optional[bool] = False,
|
||||
):
|
||||
@@ -344,9 +345,9 @@ class CategoryCluster:
|
||||
page_infos = {}
|
||||
if isinstance(self.PAGEINFO, dict):
|
||||
for page_key, page_info in dict(self.PAGEINFO).items():
|
||||
if page_info_dict := getattr(page_info, 'as_dict', None):
|
||||
if page_info_dict := getattr(page_info, "as_dict", None):
|
||||
page_infos[page_key] = page_info_dict
|
||||
return {"prefix": self.PREFIX, **page_infos}
|
||||
if hasattr(self.PAGEINFO, 'as_dict'):
|
||||
if hasattr(self.PAGEINFO, "as_dict"):
|
||||
return {"prefix": self.PREFIX, **self.PAGEINFO.as_dict}
|
||||
return
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
from ApiLayers.AllConfigs.Redis.configs import RedisCategoryKeys, RedisCategoryPageInfoKeysAction
|
||||
from ApiLayers.AllConfigs.Redis.configs import (
|
||||
RedisCategoryKeys,
|
||||
RedisCategoryPageInfoKeysAction,
|
||||
)
|
||||
|
||||
|
||||
class PrepareRedisItems:
|
||||
|
||||
@@ -4,7 +4,10 @@ from ApiLayers.ApiServices.Cluster.create_router import (
|
||||
CreateRouterFromCluster,
|
||||
CreateEndpointFromCluster,
|
||||
)
|
||||
from ApiLayers.AllConfigs.Redis.configs import RedisCategoryKeys, RedisCategoryPageInfoKeys
|
||||
from ApiLayers.AllConfigs.Redis.configs import (
|
||||
RedisCategoryKeys,
|
||||
RedisCategoryPageInfoKeys,
|
||||
)
|
||||
from Events.Engine.abstract_class import CategoryCluster
|
||||
from Services.Redis.Actions.actions import RedisActions
|
||||
from Services.Redis.Models.cluster import RedisList
|
||||
@@ -79,14 +82,16 @@ class PrepareEvents(DecoratorModule):
|
||||
|
||||
def prepare_page_info(self):
|
||||
"""
|
||||
[SAVE]REDIS => PAGE_MENU_INDEX:PAGE_URL= {...PageInfo}
|
||||
[SAVE]REDIS => PAGE_MENU_INDEX:PAGE_URL= {...PageInfo}
|
||||
"""
|
||||
for cluster_control in self.cluster_controller_group.imports:
|
||||
cluster = cluster_control.category_cluster
|
||||
if retrieve_page_info := cluster.retrieve_page_info():
|
||||
self.valid_redis_items.PAGE_INFO_VALUE.update({
|
||||
f"{self.valid_redis_items.PAGE_INFO_KEY}:{cluster.name}": retrieve_page_info
|
||||
})
|
||||
self.valid_redis_items.PAGE_INFO_VALUE.update(
|
||||
{
|
||||
f"{self.valid_redis_items.PAGE_INFO_KEY}:{cluster.name}": retrieve_page_info
|
||||
}
|
||||
)
|
||||
|
||||
def prepare_needs(self):
|
||||
# @Pages iterate(ClusterToMethod)
|
||||
@@ -155,8 +160,7 @@ class SetItems2Redis:
|
||||
) in RedisCategoryPageInfoKeys.__annotations__.items():
|
||||
if isinstance(redis_key_type, str):
|
||||
continue
|
||||
RedisActions.delete(list_keys=[f"{redis_values_to_delete}*"]
|
||||
)
|
||||
RedisActions.delete(list_keys=[f"{redis_values_to_delete}*"])
|
||||
|
||||
# Save MENU_FIRST_LAYER to Redis
|
||||
redis_list = RedisList(redis_key=RedisCategoryKeys.MENU_FIRST_LAYER)
|
||||
@@ -219,6 +223,4 @@ class SetItems2Redis:
|
||||
PrepareRedisItems.PAGE_INFO_KEY
|
||||
).items():
|
||||
redis_list = RedisList(redis_key=redis_key)
|
||||
RedisActions.set_json(
|
||||
list_keys=redis_list.to_list(), value=redis_value
|
||||
)
|
||||
RedisActions.set_json(list_keys=redis_list.to_list(), value=redis_value)
|
||||
|
||||
Reference in New Issue
Block a user