mirror of https://github.com/acanas/swad-core.git
Version 23.16: Sep 22, 2023 Code refactoring in hierarchy and cache.
This commit is contained in:
parent
1b59fdf2c7
commit
2f5c1d2601
|
@ -1627,50 +1627,6 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
|
|||
return NumCtrsWithMap;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of centers with degrees ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ctr_GetCachedNumCtrsWithDegs (void)
|
||||
{
|
||||
unsigned NumCtrsWithDegs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of centers with degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithDegs))
|
||||
{
|
||||
/***** Get current number of centers with degrees from database and update cache *****/
|
||||
NumCtrsWithDegs = Ctr_DB_GetNumCtrsWithDegs (Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithDegs);
|
||||
}
|
||||
|
||||
return NumCtrsWithDegs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of centers with courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ctr_GetCachedNumCtrsWithCrss (void)
|
||||
{
|
||||
unsigned NumCtrsWithCrss;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of centers with courses *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithCrss))
|
||||
{
|
||||
/***** Get number of centers with courses *****/
|
||||
NumCtrsWithCrss = Ctr_DB_GetNumCtrsWithCrss (Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithCrss);
|
||||
}
|
||||
|
||||
return NumCtrsWithCrss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of centers with users **********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1683,20 +1639,20 @@ unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role)
|
|||
[Rol_NET] = FigCch_NUM_CTRS_WITH_NETS, // Non-editing teachers
|
||||
[Rol_TCH] = FigCch_NUM_CTRS_WITH_TCHS, // Teachers
|
||||
};
|
||||
unsigned NumCtrsWithUsrs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
unsigned NumNodesWithUsrs;
|
||||
long HieCod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of centers with users from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigureCtrs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithUsrs))
|
||||
if (!FigCch_GetFigureFromCache (FigureCtrs[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumNodesWithUsrs))
|
||||
{
|
||||
/***** Get current number of centers with users from database and update cache *****/
|
||||
NumCtrsWithUsrs = Ctr_DB_GetNumCtrsWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigureCtrs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithUsrs);
|
||||
NumNodesWithUsrs = Ctr_DB_GetNumCtrsWithUsrs (Role,Gbl.Scope.Current,HieCod);
|
||||
FigCch_UpdateFigureIntoCache (FigureCtrs[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumNodesWithUsrs);
|
||||
}
|
||||
|
||||
return NumCtrsWithUsrs;
|
||||
return NumNodesWithUsrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -75,8 +75,6 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void);
|
|||
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod);
|
||||
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod);
|
||||
|
||||
unsigned Ctr_GetCachedNumCtrsWithDegs (void);
|
||||
unsigned Ctr_GetCachedNumCtrsWithCrss (void);
|
||||
unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role);
|
||||
|
||||
void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs);
|
||||
|
|
|
@ -446,11 +446,11 @@ unsigned Ctr_DB_GetNumCtrsWithMapInIns (long InsCod)
|
|||
/********************* Get number of centers with degrees ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ctr_DB_GetNumCtrsWithDegs (Hie_Level_t Level,long Cod)
|
||||
unsigned Ctr_DB_GetNumCtrsWithDegs (Hie_Level_t Level,long HieCod)
|
||||
{
|
||||
char SubQuery[128];
|
||||
|
||||
Hie_DB_BuildSubquery (SubQuery,Level,Cod);
|
||||
Hie_DB_BuildSubquery (SubQuery,Level,HieCod);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers with degrees",
|
||||
|
|
|
@ -632,11 +632,12 @@ TODO: Francisco Javier Fern
|
|||
Me sale este error, no sé si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así?
|
||||
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 23.15 (2023-09-22)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 23.16 (2023-09-22)"
|
||||
#define CSS_FILE "swad22.120.4.css"
|
||||
#define JS_FILE "swad22.49.js"
|
||||
/*
|
||||
Version 23.15: Sep 22, 2023 Code refactoring in hierarchy and cache. (336949 lines)
|
||||
Version 23.16: Sep 22, 2023 Code refactoring in hierarchy and cache. (336775 lines)
|
||||
Version 23.15: Sep 22, 2023 Code refactoring in hierarchy and cache. (336896 lines)
|
||||
Version 23.14.2: Sep 21, 2023 Code refactoring in cache. (336925 lines)
|
||||
Version 23.14.1: Sep 21, 2023 Code refactoring in hierarchy. (336898 lines)
|
||||
Version 23.14: Sep 21, 2023 Code refactoring in hierarchy and cache. (336904 lines)
|
||||
|
|
|
@ -1647,90 +1647,6 @@ void Cty_ReceiveFormNewCountry (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Get number of countries with institutions *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_GetCachedNumCtysWithInss (void)
|
||||
{
|
||||
unsigned NumCtysWithInss;
|
||||
|
||||
/***** Get number of countries with institutions from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_INSS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithInss))
|
||||
{
|
||||
/***** Get current number of countries with institutions from cache *****/
|
||||
NumCtysWithInss = Cty_DB_GetNumCtysWithInss ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_INSS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithInss);
|
||||
}
|
||||
|
||||
return NumCtysWithInss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get number of countries with centers ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_GetCachedNumCtysWithCtrs (void)
|
||||
{
|
||||
unsigned NumCtysWithCtrs;
|
||||
|
||||
/***** Get number of countries with centers from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithCtrs))
|
||||
{
|
||||
/***** Get current number of countries with centers from database and update cache *****/
|
||||
NumCtysWithCtrs = Cty_DB_GetNumCtysWithCtrs ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithCtrs);
|
||||
}
|
||||
|
||||
return NumCtysWithCtrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get number of countries with degrees ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_GetCachedNumCtysWithDegs (void)
|
||||
{
|
||||
unsigned NumCtysWithDegs;
|
||||
|
||||
/***** Get number of countries with degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithDegs))
|
||||
{
|
||||
/***** Get current number of countries with degrees from database and update cache *****/
|
||||
NumCtysWithDegs = Cty_DB_GetNumCtysWithDegs ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithDegs);
|
||||
}
|
||||
|
||||
return NumCtysWithDegs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get number of countries with courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_GetCachedNumCtysWithCrss (void)
|
||||
{
|
||||
unsigned NumCtysWithCrss;
|
||||
|
||||
/***** Get number of countries with courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithCrss))
|
||||
{
|
||||
/***** Get current number of countries with courses from database and update cache *****/
|
||||
NumCtysWithCrss = Cty_DB_GetNumCtysWithCrss ();
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithCrss);
|
||||
}
|
||||
|
||||
return NumCtysWithCrss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get number of countries with users **********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -82,11 +82,6 @@ void Cty_ChangeCtyWWW (void);
|
|||
void Cty_ContEditAfterChgCty (void);
|
||||
void Cty_ReceiveFormNewCountry (void);
|
||||
|
||||
unsigned Cty_GetCachedNumCtysWithInss (void);
|
||||
unsigned Cty_GetCachedNumCtysWithCtrs (void);
|
||||
unsigned Cty_GetCachedNumCtysWithDegs (void);
|
||||
unsigned Cty_GetCachedNumCtysWithCrss (void);
|
||||
|
||||
unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role);
|
||||
|
||||
void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys);
|
||||
|
|
|
@ -295,7 +295,8 @@ unsigned Cty_DB_GetNumCtysInSys (__attribute__((unused)) long SysCod)
|
|||
/***************** Get number of countries with institutions *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetNumCtysWithInss (void)
|
||||
unsigned Cty_DB_GetNumCtysWithInss (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with institutions",
|
||||
|
@ -309,7 +310,8 @@ unsigned Cty_DB_GetNumCtysWithInss (void)
|
|||
/******************* Get number of countries with centers ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetNumCtysWithCtrs (void)
|
||||
unsigned Cty_DB_GetNumCtysWithCtrs (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with centers",
|
||||
|
@ -325,7 +327,8 @@ unsigned Cty_DB_GetNumCtysWithCtrs (void)
|
|||
/******************* Get number of countries with degrees ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetNumCtysWithDegs (void)
|
||||
unsigned Cty_DB_GetNumCtysWithDegs (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with degrees",
|
||||
|
@ -343,7 +346,8 @@ unsigned Cty_DB_GetNumCtysWithDegs (void)
|
|||
/******************* Get number of countries with courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetNumCtysWithCrss (void)
|
||||
unsigned Cty_DB_GetNumCtysWithCrss (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with courses",
|
||||
|
|
|
@ -52,10 +52,14 @@ void Cty_DB_GetCountryName (long CtyCod,Lan_Language_t Language,
|
|||
|
||||
unsigned Cty_DB_GetNumCtysInSys (__attribute__((unused)) long SysCod);
|
||||
|
||||
unsigned Cty_DB_GetNumCtysWithInss (void);
|
||||
unsigned Cty_DB_GetNumCtysWithCtrs (void);
|
||||
unsigned Cty_DB_GetNumCtysWithDegs (void);
|
||||
unsigned Cty_DB_GetNumCtysWithCrss (void);
|
||||
unsigned Cty_DB_GetNumCtysWithInss (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod);
|
||||
unsigned Cty_DB_GetNumCtysWithCtrs (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod);
|
||||
unsigned Cty_DB_GetNumCtysWithDegs (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod);
|
||||
unsigned Cty_DB_GetNumCtysWithCrss (__attribute__((unused)) Hie_Level_t Level,
|
||||
__attribute__((unused)) long HieCod);
|
||||
unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,
|
||||
Hie_Level_t Level,long Cod);
|
||||
|
||||
|
|
|
@ -419,20 +419,20 @@ unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role)
|
|||
[Rol_NET] = FigCch_NUM_CRSS_WITH_NETS, // Non-editing teachers
|
||||
[Rol_TCH] = FigCch_NUM_CRSS_WITH_TCHS, // Teachers
|
||||
};
|
||||
unsigned NumCrssWithUsrs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
unsigned NumNodesWithUsrs;
|
||||
long HieCod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of courses with users from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigureCrss[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCrssWithUsrs))
|
||||
if (!FigCch_GetFigureFromCache (FigureCrss[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumNodesWithUsrs))
|
||||
{
|
||||
/***** Get current number of courses with users from database and update cache *****/
|
||||
NumCrssWithUsrs = Crs_DB_GetNumCrssWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigureCrss[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumCrssWithUsrs);
|
||||
NumNodesWithUsrs = Crs_DB_GetNumCrssWithUsrs (Role,Gbl.Scope.Current,HieCod);
|
||||
FigCch_UpdateFigureIntoCache (FigureCrss[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumNodesWithUsrs);
|
||||
}
|
||||
|
||||
return NumCrssWithUsrs;
|
||||
return NumNodesWithUsrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1529,28 +1529,6 @@ static void Deg_ShowAlertAndButtonToGoToDeg (void)
|
|||
Ale_ShowAlerts (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of centers with courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Deg_GetCachedNumDegsWithCrss (void)
|
||||
{
|
||||
unsigned NumDegsWithCrss;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of degrees with courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_DEGS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumDegsWithCrss))
|
||||
{
|
||||
/***** Get current number of degrees with courses from database and update cache *****/
|
||||
NumDegsWithCrss = Deg_DB_GetNumDegsWithCrss (Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumDegsWithCrss);
|
||||
}
|
||||
|
||||
return NumDegsWithCrss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of degrees with users **********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1563,20 +1541,20 @@ unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role)
|
|||
[Rol_NET] = FigCch_NUM_DEGS_WITH_NETS, // Non-editing teachers
|
||||
[Rol_TCH] = FigCch_NUM_DEGS_WITH_TCHS, // Teachers
|
||||
};
|
||||
unsigned NumDegsWithUsrs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
unsigned NumNodesWithUsrs;
|
||||
long HieCod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of degrees with users from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigureDegs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumDegsWithUsrs))
|
||||
if (!FigCch_GetFigureFromCache (FigureDegs[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumNodesWithUsrs))
|
||||
{
|
||||
/***** Get current number of degrees with users from database and update cache *****/
|
||||
NumDegsWithUsrs = Deg_DB_GetNumDegsWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigureDegs[Role],Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumDegsWithUsrs);
|
||||
NumNodesWithUsrs = Deg_DB_GetNumDegsWithUsrs (Role,Gbl.Scope.Current,HieCod);
|
||||
FigCch_UpdateFigureIntoCache (FigureDegs[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumNodesWithUsrs);
|
||||
}
|
||||
|
||||
return NumDegsWithUsrs;
|
||||
return NumNodesWithUsrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -81,7 +81,6 @@ void Deg_ChangeDegWWW (void);
|
|||
void Deg_ChangeDegStatus (void);
|
||||
void Deg_ContEditAfterChgDeg (void);
|
||||
|
||||
unsigned Deg_GetCachedNumDegsWithCrss (void);
|
||||
unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role);
|
||||
|
||||
void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumCrss);
|
||||
|
|
107
swad_hierarchy.c
107
swad_hierarchy.c
|
@ -1079,7 +1079,7 @@ static void Hie_GetAndShowHierarchyWithInss (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Hie_SYS:
|
||||
NumNodes[Hie_CTY] = (int) Cty_GetCachedNumCtysWithInss ();
|
||||
NumNodes[Hie_CTY] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTY,Hie_SYS,Hie_INS);
|
||||
break;
|
||||
case Hie_CTY:
|
||||
case Hie_INS:
|
||||
|
@ -1117,11 +1117,11 @@ static void Hie_GetAndShowHierarchyWithCtrs (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Hie_SYS:
|
||||
NumNodes[Hie_CTY] = (int) Cty_GetCachedNumCtysWithCtrs ();
|
||||
/* falls through */
|
||||
/* no break */
|
||||
NumNodes[Hie_CTY] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTY,Hie_SYS,Hie_CTR);
|
||||
NumNodes[Hie_INS] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_INS,Hie_SYS,Hie_CTR);
|
||||
break;
|
||||
case Hie_CTY:
|
||||
NumNodes[Hie_INS] = (int) Ins_GetCachedNumInssWithCtrs ();
|
||||
NumNodes[Hie_INS] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_INS,Hie_CTY,Hie_CTR);
|
||||
break;
|
||||
case Hie_INS:
|
||||
case Hie_CTR:
|
||||
|
@ -1158,15 +1158,16 @@ static void Hie_GetAndShowHierarchyWithDegs (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Hie_SYS:
|
||||
NumNodes[Hie_CTY] = (int) Cty_GetCachedNumCtysWithDegs ();
|
||||
/* falls through */
|
||||
/* no break */
|
||||
NumNodes[Hie_CTY] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTY,Hie_SYS,Hie_DEG);
|
||||
NumNodes[Hie_INS] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_INS,Hie_SYS,Hie_DEG);
|
||||
NumNodes[Hie_CTR] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTR,Hie_SYS,Hie_DEG);
|
||||
break;
|
||||
case Hie_CTY:
|
||||
NumNodes[Hie_INS] = (int) Ins_GetCachedNumInssWithDegs ();
|
||||
/* falls through */
|
||||
/* no break */
|
||||
NumNodes[Hie_INS] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_INS,Hie_CTY,Hie_DEG);
|
||||
NumNodes[Hie_CTR] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTR,Hie_CTY,Hie_DEG);
|
||||
break;
|
||||
case Hie_INS:
|
||||
NumNodes[Hie_CTR] = (int) Ctr_GetCachedNumCtrsWithDegs ();
|
||||
NumNodes[Hie_CTR] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTR,Hie_INS,Hie_DEG);
|
||||
break;
|
||||
case Hie_CTR:
|
||||
case Hie_DEG:
|
||||
|
@ -1202,19 +1203,22 @@ static void Hie_GetAndShowHierarchyWithCrss (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Hie_SYS:
|
||||
NumNodes[Hie_CTY] = (int) Cty_GetCachedNumCtysWithCrss ();
|
||||
/* falls through */
|
||||
/* no break */
|
||||
NumNodes[Hie_CTY] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTY,Hie_SYS,Hie_CRS);
|
||||
NumNodes[Hie_INS] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_INS,Hie_SYS,Hie_CRS);
|
||||
NumNodes[Hie_CTR] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTR,Hie_SYS,Hie_CRS);
|
||||
NumNodes[Hie_DEG] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_DEG,Hie_SYS,Hie_CRS);
|
||||
break;
|
||||
case Hie_CTY:
|
||||
NumNodes[Hie_INS] = (int) Ins_GetCachedNumInssWithCrss ();
|
||||
/* falls through */
|
||||
/* no break */
|
||||
NumNodes[Hie_INS] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_INS,Hie_CTY,Hie_CRS);
|
||||
NumNodes[Hie_CTR] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTR,Hie_CTY,Hie_CRS);
|
||||
NumNodes[Hie_DEG] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_DEG,Hie_CTY,Hie_CRS);
|
||||
break;
|
||||
case Hie_INS:
|
||||
NumNodes[Hie_CTR] = (int) Ctr_GetCachedNumCtrsWithCrss ();
|
||||
/* falls through */
|
||||
/* no break */
|
||||
NumNodes[Hie_CTR] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_CTR,Hie_INS,Hie_CRS);
|
||||
NumNodes[Hie_DEG] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_DEG,Hie_INS,Hie_CRS);
|
||||
break;
|
||||
case Hie_CTR:
|
||||
NumNodes[Hie_DEG] = (int) Deg_GetCachedNumDegsWithCrss ();
|
||||
NumNodes[Hie_DEG] = (int) Hie_GetCachedNumNodesInHieLvlWith (Hie_DEG,Hie_CTR,Hie_CRS);
|
||||
break;
|
||||
case Hie_DEG:
|
||||
case Hie_CRS:
|
||||
|
@ -1340,6 +1344,65 @@ unsigned Hie_GetNumNodesInHieLvl (Hie_Level_t LevelChildren,
|
|||
return Gbl.Cache.NumNodesInHieLvl[LevelChildren][LevelParent].Num;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Get number of children nodes in parent node with children nodes *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Hie_GetCachedNumNodesInHieLvlWith (Hie_Level_t LevelChildren,
|
||||
Hie_Level_t LevelParent,
|
||||
Hie_Level_t LevelGrandChildren)
|
||||
{
|
||||
static FigCch_FigureCached_t Figure[Hie_NUM_LEVELS][Hie_NUM_LEVELS] =
|
||||
{
|
||||
// Child Grandchild
|
||||
[Hie_CTY][Hie_INS] = FigCch_NUM_CTYS_WITH_INSS,
|
||||
[Hie_CTY][Hie_CTR] = FigCch_NUM_CTYS_WITH_CTRS,
|
||||
[Hie_CTY][Hie_DEG] = FigCch_NUM_CTYS_WITH_DEGS,
|
||||
[Hie_CTY][Hie_CRS] = FigCch_NUM_CTYS_WITH_CRSS,
|
||||
|
||||
[Hie_INS][Hie_CTR] = FigCch_NUM_INSS_WITH_CTRS,
|
||||
[Hie_INS][Hie_DEG] = FigCch_NUM_INSS_WITH_DEGS,
|
||||
[Hie_INS][Hie_CRS] = FigCch_NUM_INSS_WITH_CRSS,
|
||||
|
||||
[Hie_CTR][Hie_DEG] = FigCch_NUM_CTRS_WITH_DEGS,
|
||||
[Hie_CTR][Hie_CRS] = FigCch_NUM_CTRS_WITH_CRSS,
|
||||
|
||||
[Hie_DEG][Hie_CRS] = FigCch_NUM_DEGS_WITH_CRSS,
|
||||
};
|
||||
static unsigned (*FunctionGetFigure[Hie_NUM_LEVELS][Hie_NUM_LEVELS]) (Hie_Level_t Level,long HieCod) =
|
||||
{
|
||||
// Child Grandchild
|
||||
[Hie_CTY][Hie_INS] = Cty_DB_GetNumCtysWithInss,
|
||||
[Hie_CTY][Hie_CTR] = Cty_DB_GetNumCtysWithCtrs,
|
||||
[Hie_CTY][Hie_DEG] = Cty_DB_GetNumCtysWithDegs,
|
||||
[Hie_CTY][Hie_CRS] = Cty_DB_GetNumCtysWithCrss,
|
||||
|
||||
[Hie_INS][Hie_CTR] = Ins_DB_GetNumInssWithCtrs,
|
||||
[Hie_INS][Hie_DEG] = Ins_DB_GetNumInssWithDegs,
|
||||
[Hie_INS][Hie_CRS] = Ins_DB_GetNumInssWithCrss,
|
||||
|
||||
[Hie_CTR][Hie_DEG] = Ctr_DB_GetNumCtrsWithDegs,
|
||||
[Hie_CTR][Hie_CRS] = Ctr_DB_GetNumCtrsWithCrss,
|
||||
|
||||
[Hie_DEG][Hie_CRS] = Deg_DB_GetNumDegsWithCrss,
|
||||
};
|
||||
unsigned NumNodes;
|
||||
|
||||
/***** Get number of centers with degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (Figure[LevelChildren][LevelGrandChildren],
|
||||
LevelParent,Gbl.Hierarchy.Node[LevelParent].HieCod,
|
||||
FigCch_UNSIGNED,&NumNodes))
|
||||
{
|
||||
/***** Get current number of nodes with degrees from database and update cache *****/
|
||||
NumNodes = FunctionGetFigure[LevelChildren][LevelGrandChildren] (LevelParent,Gbl.Hierarchy.Node[LevelParent].HieCod);
|
||||
FigCch_UpdateFigureIntoCache (Figure[LevelChildren][LevelGrandChildren],
|
||||
LevelParent,Gbl.Hierarchy.Node[LevelParent].HieCod,
|
||||
FigCch_UNSIGNED,&NumNodes);
|
||||
}
|
||||
|
||||
return NumNodes;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Get number of users who claim to belong to a hierarchy node ********/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -78,6 +78,10 @@ unsigned Hie_GetCachedNumNodesInHieLvl (Hie_Level_t LevelChildren,
|
|||
unsigned Hie_GetNumNodesInHieLvl (Hie_Level_t LevelChildren,
|
||||
Hie_Level_t LevelParent,long HieCod);
|
||||
|
||||
unsigned Hie_GetCachedNumNodesInHieLvlWith (Hie_Level_t LevelChildren,
|
||||
Hie_Level_t LevelParent,
|
||||
Hie_Level_t LevelGrandChildren);
|
||||
|
||||
void Hie_FlushCacheNumUsrsWhoClaimToBelongTo (Hie_Level_t Level);
|
||||
unsigned Hie_GetCachedNumUsrsWhoClaimToBelongTo (Hie_Level_t Level,
|
||||
struct Hie_Node *Node);
|
||||
|
|
|
@ -1558,72 +1558,6 @@ static void Ins_ReceiveFormRequestOrCreateIns (Hie_Status_t Status)
|
|||
Ale_CreateAlertYouMustSpecifyTheShortNameAndTheFullName ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Get number of institutions with centers *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ins_GetCachedNumInssWithCtrs (void)
|
||||
{
|
||||
unsigned NumInssWithCtrs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of institutions with centers from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CTRS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithCtrs))
|
||||
{
|
||||
/***** Get current number of institutions with centers from database and update cache *****/
|
||||
NumInssWithCtrs = Ins_DB_GetNumInssWithCtrs (Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CTRS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithCtrs);
|
||||
}
|
||||
|
||||
return NumInssWithCtrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get number of institutions with degrees ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ins_GetCachedNumInssWithDegs (void)
|
||||
{
|
||||
unsigned NumInssWithDegs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of institutions with degrees from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithDegs))
|
||||
{
|
||||
/***** Get current number of institutions with degrees from database and update cache *****/
|
||||
NumInssWithDegs = Ins_DB_GetNumInssWithDegs (Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_DEGS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithDegs);
|
||||
}
|
||||
|
||||
return NumInssWithDegs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get number of institutions with courses ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ins_GetCachedNumInssWithCrss (void)
|
||||
{
|
||||
unsigned NumInssWithCrss;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of institutions with courses from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithCrss))
|
||||
{
|
||||
/***** Get current number of institutions with courses from database and update cache *****/
|
||||
NumInssWithCrss = Ins_DB_GetNumInssWithCrss (Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CRSS,Gbl.Scope.Current,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithCrss);
|
||||
}
|
||||
|
||||
return NumInssWithCrss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get number of institutions with users ********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1637,15 +1571,15 @@ unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role)
|
|||
[Rol_TCH] = FigCch_NUM_INSS_WITH_TCHS, // Teachers
|
||||
};
|
||||
unsigned NumInssWithUsrs;
|
||||
long Cod = Hie_GetCurrentCod ();
|
||||
long HieCod = Hie_GetCurrentCod ();
|
||||
|
||||
/***** Get number of institutions with users from cache *****/
|
||||
if (!FigCch_GetFigureFromCache (FigureInss[Role],Gbl.Scope.Current,Cod,
|
||||
if (!FigCch_GetFigureFromCache (FigureInss[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumInssWithUsrs))
|
||||
{
|
||||
/***** Get current number of institutions with users from database and update cache *****/
|
||||
NumInssWithUsrs = Ins_DB_GetNumInnsWithUsrs (Role,Gbl.Scope.Current,Cod);
|
||||
FigCch_UpdateFigureIntoCache (FigureInss[Role],Gbl.Scope.Current,Cod,
|
||||
NumInssWithUsrs = Ins_DB_GetNumInnsWithUsrs (Role,Gbl.Scope.Current,HieCod);
|
||||
FigCch_UpdateFigureIntoCache (FigureInss[Role],Gbl.Scope.Current,HieCod,
|
||||
FigCch_UNSIGNED,&NumInssWithUsrs);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,6 @@ void Ins_ContEditAfterChgIns (void);
|
|||
void Ins_ReceiveFormReqIns (void);
|
||||
void Ins_ReceiveFormNewIns (void);
|
||||
|
||||
unsigned Ins_GetCachedNumInssWithCtrs (void);
|
||||
unsigned Ins_GetCachedNumInssWithDegs (void);
|
||||
unsigned Ins_GetCachedNumInssWithCrss (void);
|
||||
unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role);
|
||||
|
||||
void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss);
|
||||
|
|
Loading…
Reference in New Issue