remove ducjdb extension from postgres

This commit is contained in:
2025-02-18 18:39:50 +03:00
parent 3bcec2abff
commit 980da5a085
11 changed files with 142 additions and 78 deletions

View File

@@ -63,7 +63,7 @@ cluster_event.endpoint_callable = get_cluster_by_event_function_code
# Page Event
page_event = Event(
name="page_event",
key="",
key="2a43bff2-3720-4427-b226-9b2f6ef00b57",
request_validator=PagePydantic,
language_models=[],
statics=None,

View File

@@ -6,9 +6,12 @@ from typing import Dict, Any, Optional
from fastapi import Request
from ApiLayers.AllConfigs.Redis.configs import (
RedisValidationKeysAction,
RedisCategoryKeys,
RedisValidationKeysAction,
RedisCategoryPageInfoKeysAction,
)
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
from ApiLayers.ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
from Services.Redis.Actions.actions import RedisActions
from Events.base_request_model import BaseRouteModel
@@ -163,6 +166,12 @@ class RetrievePage(BaseRouteModel):
Context Token Retriever to get user information from ACCESS_TOKEN
CategoryCluster Retrieve Cluster Retrieve cluster by name
Check available instructions of page and info user with it
Args:
request: FastAPI request object
data.page: Request body containing login credentials
{
"page": "/dashboard?site=AccountCluster"
}
Returns:
NAME=cluster_name.name,
PREFIX=cluster_name.PREFIX,
@@ -174,8 +183,7 @@ class RetrievePage(BaseRouteModel):
from Events.Engine import CategoryCluster
from Events.JustEvents.events_file import retrieve_cluster_by_name
reachable_codes = []
page_name = getattr(data, "page", None)
reachable_codes, page_name = [], getattr(data, "page", None)
if cls.context_retriever.token.is_employee:
reachable_codes = (
cls.context_retriever.token.selected_company.reachable_event_codes
@@ -184,25 +192,43 @@ class RetrievePage(BaseRouteModel):
reachable_codes = (
cls.context_retriever.token.selected_occupant.reachable_event_codes
)
cluster_from_all_events = cls.get_site_cluster(page_name=page_name)
if not cluster_from_all_events:
raise ValueError(f"Cluster not found : {page_name}")
cluster_name = str(page_name).split("?")[1].split("=")[1]
print("page_name", f"{RedisCategoryPageInfoKeysAction.page_index}:{page_name}")
page_info_from_redis = RedisActions.get_json(
list_keys=[
RedisCategoryPageInfoKeysAction.page_index,
cluster_name,
]
)
page_info_all = page_info_from_redis.first
if not page_info_all:
return dict(
NAME=f"{cluster_name}",
PREFIX=f"NOT IMPLEMENTED",
URL=f"{page_name}",
MESSAGE="Cluster not found"
)
cluster_name: CategoryCluster = retrieve_cluster_by_name(cluster_from_all_events)
if not cluster_name:
raise ValueError("Cluster not found")
page_info = page_info_all.get(page_name, {})
sub_components = dict(page_info).get("SUB_COMPONENTS", {})
page_info = cluster_name.retrieve_page_info().get(page_name, None)
if not page_info:
raise ValueError("Page not found")
sub_components: dict = dict(page_info).get("SUB_COMPONENTS", {})
if not sub_components:
raise ValueError("Sub components not found")
new_page_info_dict = dict(
NAME=cluster_name.name,
PREFIX=cluster_name.PREFIX,
print("PAGE INFO : ", dict(
page_name=page_name,
page_info=page_info,
sub_components=sub_components,
NAME=cluster_name,
PREFIX=page_info_all.get("prefix", ""),
TEMPLATE_UI=dict(page_info).get("TEMPLATE_UI", ""),
URL=dict(page_info).get("URL", None),
ICON=dict(page_info).get("ICON", None),
INFO=dict(page_info).get("INFO", None),
SUB_COMPONENTS=sub_components,
# MAPPING=cluster_name.MAPPING,
))
new_page_info = dict(
NAME=cluster_name,
PREFIX=page_info_all.get("prefix", ""),
TEMPLATE_UI=dict(page_info).get("TEMPLATE_UI", ""),
URL=dict(page_info).get("URL", None),
ICON=dict(page_info).get("ICON", None),
INFO=dict(page_info).get("INFO", None),
@@ -210,10 +236,17 @@ class RetrievePage(BaseRouteModel):
# MAPPING=cluster_name.MAPPING,
)
for key, events in dict(sub_components).items():
# Meaning client can reach this endpoint [] & [] intersection
# Meaning client can reach this endpoint [] & [] intersection in reachable_codes
endpoint_event_codes = dict(events).get("ENDPOINTS", [])
new_page_info_dict["SUB_COMPONENTS"][key].pop("ENDPOINTS")
if not set(endpoint_event_codes) & set(reachable_codes):
new_page_info_dict["SUB_COMPONENTS"].pop(key)
return new_page_info_dict
if not len(list(set(endpoint_event_codes) & set(reachable_codes))) == 1:
print(f"{endpoint_event_codes} :||: Endpoint is not available for the current user")
new_page_info["SUB_COMPONENTS"].pop(key, None)
for key in new_page_info["SUB_COMPONENTS"].keys():
new_page_info["SUB_COMPONENTS"][key].pop("ENDPOINTS", None)
if len(new_page_info["SUB_COMPONENTS"]) == 0:
return dict(
NAME=cluster_name,
PREFIX=page_info_all.get("prefix", ""),
MESSAGE="This cluster is not registered or not accessible for the current user"
)
return new_page_info