events cluster updated with PageInfo

This commit is contained in:
2025-02-03 20:53:31 +03:00
parent f0613e96e8
commit b67090087a
51 changed files with 1041 additions and 286 deletions

View File

@@ -1,4 +1,4 @@
from ApiLayers.AllConfigs.Redis.configs import RedisCategoryKeys
from ApiLayers.AllConfigs.Redis.configs import RedisCategoryKeys, RedisCategoryPageInfoKeysAction
class PrepareRedisItems:
@@ -13,6 +13,8 @@ class PrepareRedisItems:
METHOD_FUNCTION_CODES_VALUE: dict = {}
ENDPOINT2CLASS_KEY: str = RedisCategoryKeys.ENDPOINT2CLASS
ENDPOINT2CLASS_VALUE: dict = {}
PAGE_INFO_KEY: str = RedisCategoryPageInfoKeysAction.page_index
PAGE_INFO_VALUE: dict = {}
@property
def as_dict(self):
@@ -22,6 +24,7 @@ class PrepareRedisItems:
self.CLUSTER_FUNCTION_CODES_KEY: self.CLUSTER_FUNCTION_CODES_VALUE,
self.METHOD_FUNCTION_CODES_KEY: self.METHOD_FUNCTION_CODES_VALUE,
self.ENDPOINT2CLASS_KEY: self.ENDPOINT2CLASS_VALUE,
self.PAGE_INFO_KEY: self.PAGE_INFO_VALUE,
}

View File

@@ -4,7 +4,7 @@ from ApiLayers.ApiServices.Cluster.create_router import (
CreateRouterFromCluster,
CreateEndpointFromCluster,
)
from ApiLayers.AllConfigs.Redis.configs import RedisCategoryKeys
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
@@ -75,6 +75,18 @@ class PrepareEvents(DecoratorModule):
self.cluster_controller_group = cluster_controller_group
self.valid_redis_items: PrepareRedisItems = PrepareRedisItems()
self.prepare_needs()
self.prepare_page_info()
def prepare_page_info(self):
"""
[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
})
def prepare_needs(self):
# @Pages iterate(ClusterToMethod)
@@ -137,6 +149,15 @@ class SetItems2Redis:
continue
RedisActions.delete(list_keys=[f"{redis_values_to_delete}*"])
for (
redis_values_to_delete,
redis_key_type,
) in RedisCategoryPageInfoKeys.__annotations__.items():
if isinstance(redis_key_type, str):
continue
RedisActions.delete(list_keys=[f"{redis_values_to_delete}*"]
)
# Save MENU_FIRST_LAYER to Redis
redis_list = RedisList(redis_key=RedisCategoryKeys.MENU_FIRST_LAYER)
RedisActions.set_json(
@@ -193,3 +214,11 @@ class SetItems2Redis:
f"{RedisCategoryKeys.ENDPOINT2CLASS}": True,
},
)
for redis_key, redis_value in dict_prep.get(
PrepareRedisItems.PAGE_INFO_KEY
).items():
redis_list = RedisList(redis_key=redis_key)
RedisActions.set_json(
list_keys=redis_list.to_list(), value=redis_value
)