mirror of https://github.com/acanas/swad-core.git
Version 23.14: Sep 21, 2023 Code refactoring in hierarchy and cache.
This commit is contained in:
parent
9c64a7f973
commit
979d5fa168
|
@ -353,7 +353,8 @@ static void Ctr_ListOneCenterForSeeing (struct Hie_Node *Ctr,unsigned NumCtr)
|
||||||
/***** Number of users who claim to belong to this center *****/
|
/***** Number of users who claim to belong to this center *****/
|
||||||
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
||||||
TxtClassNormal,The_GetSuffix (),BgColor);
|
TxtClassNormal,The_GetSuffix (),BgColor);
|
||||||
HTM_Unsigned (Ctr_GetCachedNumUsrsWhoClaimToBelongToCtr (Ctr));
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_CTR,
|
||||||
|
Ctr));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Place *****/
|
/***** Place *****/
|
||||||
|
@ -759,8 +760,10 @@ static void Ctr_ListCentersForEdition (const struct Plc_Places *Places)
|
||||||
Ctr = &Gbl.Hierarchy.List[HieLvl_INS].Lst[NumCtr];
|
Ctr = &Gbl.Hierarchy.List[HieLvl_INS].Lst[NumCtr];
|
||||||
|
|
||||||
ICanEdit = Ctr_CheckIfICanEditACenter (Ctr);
|
ICanEdit = Ctr_CheckIfICanEditACenter (Ctr);
|
||||||
NumDegs = Hie_GetNumNodesInHieLvl (HieLvl_DEG,HieLvl_CTR,Ctr->HieCod);
|
NumDegs = Hie_GetNumNodesInHieLvl (HieLvl_DEG, // Number of degrees...
|
||||||
NumUsrsCtr = Ctr_GetNumUsrsWhoClaimToBelongToCtr (Ctr);
|
HieLvl_CTR, // ...in center
|
||||||
|
Ctr->HieCod);
|
||||||
|
NumUsrsCtr = Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_CTR,Ctr);
|
||||||
NumUsrsInCrssOfCtr = Enr_GetNumUsrsInCrss (HieLvl_CTR,Ctr->HieCod,
|
NumUsrsInCrssOfCtr = Enr_GetNumUsrsInCrss (HieLvl_CTR,Ctr->HieCod,
|
||||||
1 << Rol_STD |
|
1 << Rol_STD |
|
||||||
1 << Rol_NET |
|
1 << Rol_NET |
|
||||||
|
@ -960,10 +963,12 @@ void Ctr_RemoveCenter (void)
|
||||||
Ctr_GetCenterDataByCod (Ctr_EditingCtr);
|
Ctr_GetCenterDataByCod (Ctr_EditingCtr);
|
||||||
|
|
||||||
/***** Check if this center has teachers *****/
|
/***** Check if this center has teachers *****/
|
||||||
if (Hie_GetNumNodesInHieLvl (HieLvl_DEG,HieLvl_CTR,Ctr_EditingCtr->HieCod)) // Center has degrees
|
if (Hie_GetNumNodesInHieLvl (HieLvl_DEG, // Number of degrees...
|
||||||
|
HieLvl_CTR, // ...in center
|
||||||
|
Ctr_EditingCtr->HieCod)) // Center has degrees
|
||||||
Ale_ShowAlert (Ale_WARNING,
|
Ale_ShowAlert (Ale_WARNING,
|
||||||
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
||||||
else if (Ctr_GetNumUsrsWhoClaimToBelongToCtr (Ctr_EditingCtr)) // Center has users who claim to belong to it
|
else if (Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_CTR,Ctr_EditingCtr)) // Center has users who claim to belong to it
|
||||||
Ale_ShowAlert (Ale_WARNING,
|
Ale_ShowAlert (Ale_WARNING,
|
||||||
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
||||||
else if (Enr_GetNumUsrsInCrss (HieLvl_CTR,Ctr_EditingCtr->HieCod,
|
else if (Enr_GetNumUsrsInCrss (HieLvl_CTR,Ctr_EditingCtr->HieCod,
|
||||||
|
@ -1002,7 +1007,7 @@ void Ctr_RemoveCenter (void)
|
||||||
/***** Flush caches *****/
|
/***** Flush caches *****/
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_DEG,HieLvl_CTR); // Number of degrees in center
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_DEG,HieLvl_CTR); // Number of degrees in center
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CRS,HieLvl_CTR); // Number of courses in center
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CRS,HieLvl_CTR); // Number of courses in center
|
||||||
Ctr_FlushCacheNumUsrsWhoClaimToBelongToCtr ();
|
Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_CTR);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -1881,57 +1886,6 @@ bool Ctr_CheckIfIBelongToCtr (long CtrCod)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*********** Get number of users who claim to belong to a center *************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Ctr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void)
|
|
||||||
{
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.HieCod = -1L;
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Ctr_GetNumUsrsWhoClaimToBelongToCtr (struct Hie_Node *Ctr)
|
|
||||||
{
|
|
||||||
/***** 1. Fast check: Trivial case *****/
|
|
||||||
if (Ctr->HieCod <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/***** 2. Fast check: If already got... *****/
|
|
||||||
if (Ctr->NumUsrsWhoClaimToBelong.Valid)
|
|
||||||
return Ctr->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
|
|
||||||
/***** 3. Fast check: If cached... *****/
|
|
||||||
if (Ctr->HieCod == Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.HieCod)
|
|
||||||
{
|
|
||||||
Ctr->NumUsrsWhoClaimToBelong.NumUsrs = Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
|
||||||
Ctr->NumUsrsWhoClaimToBelong.Valid = true;
|
|
||||||
return Ctr->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** 4. Slow: number of users who claim to belong to a center
|
|
||||||
from database *****/
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.HieCod = Ctr->HieCod;
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs =
|
|
||||||
Ctr->NumUsrsWhoClaimToBelong.NumUsrs = Ctr_DB_GetNumUsrsWhoClaimToBelongToCtr (Ctr->HieCod);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTR,HieLvl_CTR,Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.HieCod,
|
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs);
|
|
||||||
return Ctr->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Ctr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Hie_Node *Ctr)
|
|
||||||
{
|
|
||||||
unsigned NumUsrsCtr;
|
|
||||||
|
|
||||||
/***** Get number of users who claim to belong to center from cache *****/
|
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTR,HieLvl_CTR,Ctr->HieCod,
|
|
||||||
FigCch_UNSIGNED,&NumUsrsCtr))
|
|
||||||
/***** Get current number of users who claim to belong to center from database and update cache *****/
|
|
||||||
NumUsrsCtr = Ctr_GetNumUsrsWhoClaimToBelongToCtr (Ctr);
|
|
||||||
|
|
||||||
return NumUsrsCtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Write parameter with code of center ********************/
|
/******************** Write parameter with code of center ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -85,8 +85,4 @@ void Ctr_GetMyCenters (void);
|
||||||
void Ctr_FreeMyCenters (void);
|
void Ctr_FreeMyCenters (void);
|
||||||
bool Ctr_CheckIfIBelongToCtr (long CtrCod);
|
bool Ctr_CheckIfIBelongToCtr (long CtrCod);
|
||||||
|
|
||||||
void Ctr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void);
|
|
||||||
unsigned Ctr_GetNumUsrsWhoClaimToBelongToCtr (struct Hie_Node *Ctr);
|
|
||||||
unsigned Ctr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Hie_Node *Ctr);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -744,7 +744,8 @@ static void CtrCfg_NumUsrs (void)
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
|
||||||
HTM_Unsigned (Ctr_GetCachedNumUsrsWhoClaimToBelongToCtr (&Gbl.Hierarchy.Node[HieLvl_CTR]));
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_CTR,
|
||||||
|
&Gbl.Hierarchy.Node[HieLvl_CTR]));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
|
@ -632,10 +632,11 @@ 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í?
|
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')
|
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 23.13.1 (2023-09-20)"
|
#define Log_PLATFORM_VERSION "SWAD 23.14 (2023-09-21)"
|
||||||
#define CSS_FILE "swad22.120.4.css"
|
#define CSS_FILE "swad22.120.4.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 23.14: Sep 21, 2023 Code refactoring in hierarchy and cache. (336904 lines)
|
||||||
Version 23.13.1: Sep 20, 2023 Fixed bug in browser. Reported by Eva Martínez Ortigosa. (336953 lines)
|
Version 23.13.1: Sep 20, 2023 Fixed bug in browser. Reported by Eva Martínez Ortigosa. (336953 lines)
|
||||||
Version 23.13: Sep 20, 2023 Code refactoring in hierarchy and cache. (336951 lines)
|
Version 23.13: Sep 20, 2023 Code refactoring in hierarchy and cache. (336951 lines)
|
||||||
Version 23.12: Sep 20, 2023 Code refactoring in hierarchy and cache. (336919 lines)
|
Version 23.12: Sep 20, 2023 Code refactoring in hierarchy and cache. (336919 lines)
|
||||||
|
|
123
swad_country.c
123
swad_country.c
|
@ -436,7 +436,7 @@ static void Cty_ListOneCountryForSeeing (struct Hie_Node *Cty,unsigned NumCty)
|
||||||
/***** Number of users who claim to belong to this country *****/
|
/***** Number of users who claim to belong to this country *****/
|
||||||
HTM_TD_Begin ("class=\"RM DAT_%s %s\"",
|
HTM_TD_Begin ("class=\"RM DAT_%s %s\"",
|
||||||
The_GetSuffix (),BgColor);
|
The_GetSuffix (),BgColor);
|
||||||
HTM_Unsigned (Cty_GetCachedNumUsrsWhoClaimToBelongToCty (Cty));
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_CTY,Cty));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Number of institutions *****/
|
/***** Number of institutions *****/
|
||||||
|
@ -636,7 +636,8 @@ void Cty_WriteScriptGoogleGeochart (void)
|
||||||
NumCty < Gbl.Hierarchy.List[HieLvl_SYS].Num;
|
NumCty < Gbl.Hierarchy.List[HieLvl_SYS].Num;
|
||||||
NumCty++)
|
NumCty++)
|
||||||
{
|
{
|
||||||
NumUsrsCty = Cty_GetCachedNumUsrsWhoClaimToBelongToCty (&Gbl.Hierarchy.List[HieLvl_SYS].Lst[NumCty]);
|
NumUsrsCty = Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_CTY,
|
||||||
|
&Gbl.Hierarchy.List[HieLvl_SYS].Lst[NumCty]);
|
||||||
if (NumUsrsCty)
|
if (NumUsrsCty)
|
||||||
{
|
{
|
||||||
NumInss = Hie_GetCachedNumNodesInHieLvl (HieLvl_INS, // Number of institutions...
|
NumInss = Hie_GetCachedNumNodesInHieLvl (HieLvl_INS, // Number of institutions...
|
||||||
|
@ -1073,8 +1074,10 @@ static void Cty_ListCountriesForEdition (void)
|
||||||
NumCty++)
|
NumCty++)
|
||||||
{
|
{
|
||||||
Cty = &Gbl.Hierarchy.List[HieLvl_SYS].Lst[NumCty];
|
Cty = &Gbl.Hierarchy.List[HieLvl_SYS].Lst[NumCty];
|
||||||
NumInss = Hie_GetNumNodesInHieLvl (HieLvl_INS,HieLvl_CTY,Cty->HieCod);
|
NumInss = Hie_GetNumNodesInHieLvl (HieLvl_INS, // Number of institutions...
|
||||||
NumUsrsCty = Cty_GetNumUsrsWhoClaimToBelongToCty (Cty);
|
HieLvl_CTY, // ...in country
|
||||||
|
Cty->HieCod);
|
||||||
|
NumUsrsCty = Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_CTY,Cty);
|
||||||
|
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
|
||||||
|
@ -1199,10 +1202,12 @@ void Cty_RemoveCountry (void)
|
||||||
Cty_GetBasicCountryDataByCod (Cty_EditingCty);
|
Cty_GetBasicCountryDataByCod (Cty_EditingCty);
|
||||||
|
|
||||||
/***** Check if this country has users *****/
|
/***** Check if this country has users *****/
|
||||||
if (Hie_GetNumNodesInHieLvl (HieLvl_INS,HieLvl_CTY,Cty_EditingCty->HieCod)) // Country has institutions ==> don't remove
|
if (Hie_GetNumNodesInHieLvl (HieLvl_INS, // Number of institutions...
|
||||||
|
HieLvl_CTY, // ...in country
|
||||||
|
Cty_EditingCty->HieCod)) // Country has institutions ==> don't remove
|
||||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||||
Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
||||||
else if (Cty_GetNumUsrsWhoClaimToBelongToCty (Cty_EditingCty)) // Country has users ==> don't remove
|
else if (Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_CTY,Cty_EditingCty)) // Country has users ==> don't remove
|
||||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||||
Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
||||||
else if (Enr_GetNumUsrsInCrss (HieLvl_CTY,Cty_EditingCty->HieCod,
|
else if (Enr_GetNumUsrsInCrss (HieLvl_CTY,Cty_EditingCty->HieCod,
|
||||||
|
@ -1225,7 +1230,7 @@ void Cty_RemoveCountry (void)
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CTR,HieLvl_CTY); // Number of centers in country
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CTR,HieLvl_CTY); // Number of centers in country
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_DEG,HieLvl_CTY); // Number of degrees in country
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_DEG,HieLvl_CTY); // Number of degrees in country
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CRS,HieLvl_CTY); // Number of courses in country
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CRS,HieLvl_CTY); // Number of courses in country
|
||||||
Cty_FlushCacheNumUsrsWhoClaimToBelongToCty ();
|
Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_CTY);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -1943,6 +1948,19 @@ void Cty_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
||||||
Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.Valid = false;
|
Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.Valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Cty_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
||||||
|
{
|
||||||
|
unsigned NumUsrs;
|
||||||
|
|
||||||
|
/***** Get number of user who don't claim to belong to any country from cache *****/
|
||||||
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,HieLvl_CTY,-1L,
|
||||||
|
FigCch_UNSIGNED,&NumUsrs))
|
||||||
|
/***** Get current number of user who don't claim to belong to any country from database and update cache *****/
|
||||||
|
NumUsrs = Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty ();
|
||||||
|
|
||||||
|
return NumUsrs;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
unsigned Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
||||||
{
|
{
|
||||||
/***** 1. Fast check: If cached... *****/
|
/***** 1. Fast check: If cached... *****/
|
||||||
|
@ -1958,19 +1976,6 @@ unsigned Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
||||||
return Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs;
|
return Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Cty_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
|
||||||
{
|
|
||||||
unsigned NumUsrs;
|
|
||||||
|
|
||||||
/***** Get number of user who don't claim to belong to any country from cache *****/
|
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,HieLvl_CTY,-1L,
|
|
||||||
FigCch_UNSIGNED,&NumUsrs))
|
|
||||||
/***** Get current number of user who don't claim to belong to any country from database and update cache *****/
|
|
||||||
NumUsrs = Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty ();
|
|
||||||
|
|
||||||
return NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******** Get number of users who claim to belong to another country *********/
|
/******** Get number of users who claim to belong to another country *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1980,6 +1985,19 @@ void Cty_FlushCacheNumUsrsWhoClaimToBelongToAnotherCty (void)
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.Valid = false;
|
Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.Valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void)
|
||||||
|
{
|
||||||
|
unsigned NumUsrsCty;
|
||||||
|
|
||||||
|
/***** Get number of users who claim to belong to another country form cache *****/
|
||||||
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,HieLvl_CTY,0,
|
||||||
|
FigCch_UNSIGNED,&NumUsrsCty))
|
||||||
|
/***** Get current number of users who claim to belong to another country from database and update cache *****/
|
||||||
|
NumUsrsCty = Cty_GetNumUsrsWhoClaimToBelongToAnotherCty ();
|
||||||
|
|
||||||
|
return NumUsrsCty;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned Cty_GetNumUsrsWhoClaimToBelongToAnotherCty (void)
|
unsigned Cty_GetNumUsrsWhoClaimToBelongToAnotherCty (void)
|
||||||
{
|
{
|
||||||
/***** 1. Fast check: If cached... *****/
|
/***** 1. Fast check: If cached... *****/
|
||||||
|
@ -1994,68 +2012,3 @@ unsigned Cty_GetNumUsrsWhoClaimToBelongToAnotherCty (void)
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs);
|
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs);
|
||||||
return Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs;
|
return Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void)
|
|
||||||
{
|
|
||||||
unsigned NumUsrsCty;
|
|
||||||
|
|
||||||
/***** Get number of users who claim to belong to another country form cache *****/
|
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,HieLvl_CTY,0,
|
|
||||||
FigCch_UNSIGNED,&NumUsrsCty))
|
|
||||||
/***** Get current number of users who claim to belong to another country from database and update cache *****/
|
|
||||||
NumUsrsCty = Cty_GetNumUsrsWhoClaimToBelongToAnotherCty ();
|
|
||||||
|
|
||||||
return NumUsrsCty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/*********** Get number of users who claim to belong to a country ************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Cty_FlushCacheNumUsrsWhoClaimToBelongToCty (void)
|
|
||||||
{
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCty.HieCod = -1L;
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (struct Hie_Node *Cty)
|
|
||||||
{
|
|
||||||
/***** 1. Fast check: Trivial case *****/
|
|
||||||
if (Cty->HieCod <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/***** 2. Fast check: If already got... *****/
|
|
||||||
if (Cty->NumUsrsWhoClaimToBelong.Valid)
|
|
||||||
return Cty->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
|
|
||||||
/***** 3. Fast check: If cached... *****/
|
|
||||||
if (Cty->HieCod == Gbl.Cache.NumUsrsWhoClaimToBelongToCty.HieCod)
|
|
||||||
{
|
|
||||||
Cty->NumUsrsWhoClaimToBelong.NumUsrs = Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs;
|
|
||||||
Cty->NumUsrsWhoClaimToBelong.Valid = true;
|
|
||||||
return Cty->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** 4. Slow: number of users who claim to belong to an institution
|
|
||||||
from database *****/
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCty.HieCod = Cty->HieCod;
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs =
|
|
||||||
Cty->NumUsrsWhoClaimToBelong.NumUsrs = Cty_DB_GetNumUsrsWhoClaimToBelongToCty (Cty->HieCod);
|
|
||||||
Cty->NumUsrsWhoClaimToBelong.Valid = true;
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,HieLvl_CTY,Gbl.Cache.NumUsrsWhoClaimToBelongToCty.HieCod,
|
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs);
|
|
||||||
return Cty->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToCty (struct Hie_Node *Cty)
|
|
||||||
{
|
|
||||||
unsigned NumUsrsCty;
|
|
||||||
|
|
||||||
/***** Get number of users who claim to belong to country from cache ******/
|
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_CTY,HieLvl_CTY,Cty->HieCod,
|
|
||||||
FigCch_UNSIGNED,&NumUsrsCty))
|
|
||||||
/***** Get current number of users who claim to belong to country from database and update cache ******/
|
|
||||||
NumUsrsCty = Cty_GetNumUsrsWhoClaimToBelongToCty (Cty);
|
|
||||||
|
|
||||||
return NumUsrsCty;
|
|
||||||
}
|
|
||||||
|
|
|
@ -96,15 +96,11 @@ void Cty_FreeMyCountrs (void);
|
||||||
bool Cty_CheckIfIBelongToCty (long CtyCod);
|
bool Cty_CheckIfIBelongToCty (long CtyCod);
|
||||||
|
|
||||||
void Cty_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
void Cty_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
||||||
unsigned Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
|
||||||
unsigned Cty_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
unsigned Cty_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
||||||
|
unsigned Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
||||||
|
|
||||||
void Cty_FlushCacheNumUsrsWhoClaimToBelongToAnotherCty (void);
|
void Cty_FlushCacheNumUsrsWhoClaimToBelongToAnotherCty (void);
|
||||||
unsigned Cty_GetNumUsrsWhoClaimToBelongToAnotherCty (void);
|
|
||||||
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void);
|
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void);
|
||||||
|
unsigned Cty_GetNumUsrsWhoClaimToBelongToAnotherCty (void);
|
||||||
void Cty_FlushCacheNumUsrsWhoClaimToBelongToCty (void);
|
|
||||||
unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (struct Hie_Node *Cty);
|
|
||||||
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToCty (struct Hie_Node *Cty);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -460,7 +460,8 @@ static void CtyCfg_NumUsrs (void)
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
|
||||||
HTM_Unsigned (Cty_GetCachedNumUsrsWhoClaimToBelongToCty (&Gbl.Hierarchy.Node[HieLvl_CTY]));
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_CTY,
|
||||||
|
&Gbl.Hierarchy.Node[HieLvl_CTY]));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
|
@ -344,7 +344,9 @@ static void Deg_ListDegreesForEdition (const struct DegTyp_DegTypes *DegTypes)
|
||||||
DegInLst = &(Gbl.Hierarchy.List[HieLvl_CTR].Lst[NumDeg]);
|
DegInLst = &(Gbl.Hierarchy.List[HieLvl_CTR].Lst[NumDeg]);
|
||||||
|
|
||||||
ICanEdit = Deg_CheckIfICanEditADegree (DegInLst);
|
ICanEdit = Deg_CheckIfICanEditADegree (DegInLst);
|
||||||
NumCrss = Hie_GetNumNodesInHieLvl (HieLvl_CRS,HieLvl_DEG,DegInLst->HieCod);
|
NumCrss = Hie_GetNumNodesInHieLvl (HieLvl_CRS, // Number of courses...
|
||||||
|
HieLvl_DEG, // ...in degree
|
||||||
|
DegInLst->HieCod);
|
||||||
NumUsrsInCrssOfDeg = Enr_GetNumUsrsInCrss (HieLvl_DEG,DegInLst->HieCod,
|
NumUsrsInCrssOfDeg = Enr_GetNumUsrsInCrss (HieLvl_DEG,DegInLst->HieCod,
|
||||||
1 << Rol_STD |
|
1 << Rol_STD |
|
||||||
1 << Rol_NET |
|
1 << Rol_NET |
|
||||||
|
@ -1138,7 +1140,9 @@ void Deg_RemoveDegree (void)
|
||||||
Deg_GetDegreeDataByCod (Deg_EditingDeg);
|
Deg_GetDegreeDataByCod (Deg_EditingDeg);
|
||||||
|
|
||||||
/***** Check if this degree has courses *****/
|
/***** Check if this degree has courses *****/
|
||||||
if (Hie_GetNumNodesInHieLvl (HieLvl_CRS,HieLvl_DEG,Deg_EditingDeg->HieCod)) // Degree has courses ==> don't remove
|
if (Hie_GetNumNodesInHieLvl (HieLvl_CRS, // Number of courses...
|
||||||
|
HieLvl_DEG, // ...in degree
|
||||||
|
Deg_EditingDeg->HieCod)) // Degree has courses ==> don't remove
|
||||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||||
Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree);
|
Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree);
|
||||||
else // Degree has no courses ==> remove it
|
else // Degree has no courses ==> remove it
|
||||||
|
|
|
@ -237,9 +237,9 @@ void Gbl_InitializeGlobals (void)
|
||||||
|
|
||||||
Cty_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty ();
|
Cty_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty ();
|
||||||
Cty_FlushCacheNumUsrsWhoClaimToBelongToAnotherCty ();
|
Cty_FlushCacheNumUsrsWhoClaimToBelongToAnotherCty ();
|
||||||
Cty_FlushCacheNumUsrsWhoClaimToBelongToCty ();
|
Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_CTY);
|
||||||
Ins_FlushCacheNumUsrsWhoClaimToBelongToIns ();
|
Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_INS);
|
||||||
Ctr_FlushCacheNumUsrsWhoClaimToBelongToCtr ();
|
Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_CTR);
|
||||||
Usr_FlushCacheUsrIsSuperuser ();
|
Usr_FlushCacheUsrIsSuperuser ();
|
||||||
Hie_FlushCacheUsrBelongsTo (HieLvl_INS);
|
Hie_FlushCacheUsrBelongsTo (HieLvl_INS);
|
||||||
Hie_FlushCacheUsrBelongsTo (HieLvl_CTR);
|
Hie_FlushCacheUsrBelongsTo (HieLvl_CTR);
|
||||||
|
|
|
@ -324,19 +324,10 @@ struct Globals
|
||||||
} NumUsrsWhoClaimToBelongToAnotherCty;
|
} NumUsrsWhoClaimToBelongToAnotherCty;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
bool Valid;
|
||||||
long HieCod;
|
long HieCod;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
} NumUsrsWhoClaimToBelongToCty;
|
} NumUsrsWhoClaimToBelongTo[HieLvl_NUM_LEVELS];
|
||||||
struct
|
|
||||||
{
|
|
||||||
long HieCod;
|
|
||||||
unsigned NumUsrs;
|
|
||||||
} NumUsrsWhoClaimToBelongToIns;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
long HieCod;
|
|
||||||
unsigned NumUsrs;
|
|
||||||
} NumUsrsWhoClaimToBelongToCtr;
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "swad_alert.h"
|
#include "swad_alert.h"
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
#include "swad_center_database.h"
|
#include "swad_center_database.h"
|
||||||
|
#include "swad_country_database.h"
|
||||||
#include "swad_course_database.h"
|
#include "swad_course_database.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_degree_database.h"
|
#include "swad_degree_database.h"
|
||||||
|
@ -1433,6 +1434,81 @@ unsigned Hie_GetNumNodesInHieLvl (HieLvl_Level_t LevelChildren,
|
||||||
return Gbl.Cache.NumNodesInHieLvl[LevelChildren][LevelParent].Num;
|
return Gbl.Cache.NumNodesInHieLvl[LevelChildren][LevelParent].Num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******** Get number of users who claim to belong to a hierarchy node ********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_Level_t Level)
|
||||||
|
{
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].Valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_Level_t Level,
|
||||||
|
struct Hie_Node *Node)
|
||||||
|
{
|
||||||
|
static FigCch_FigureCached_t Figure[HieLvl_NUM_LEVELS] =
|
||||||
|
{
|
||||||
|
[HieLvl_CTY] = FigCch_NUM_USRS_BELONG_CTY,
|
||||||
|
[HieLvl_INS] = FigCch_NUM_USRS_BELONG_INS,
|
||||||
|
[HieLvl_CTR] = FigCch_NUM_USRS_BELONG_CTR,
|
||||||
|
};
|
||||||
|
unsigned NumUsrs;
|
||||||
|
|
||||||
|
/***** Get number of users who claim to belong to hierarchy node from cache *****/
|
||||||
|
if (!FigCch_GetFigureFromCache (Figure[Level],Level,Node->HieCod,
|
||||||
|
FigCch_UNSIGNED,&NumUsrs))
|
||||||
|
/***** Get current number of users who claim to belong to hierarchy node
|
||||||
|
from database and update cache *****/
|
||||||
|
NumUsrs = Hie_GetNumUsrsWhoClaimToBelongTo (Level,Node);
|
||||||
|
|
||||||
|
return NumUsrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_Level_t Level,
|
||||||
|
struct Hie_Node *Node)
|
||||||
|
{
|
||||||
|
static FigCch_FigureCached_t Figure[HieLvl_NUM_LEVELS] =
|
||||||
|
{
|
||||||
|
[HieLvl_CTY] = FigCch_NUM_USRS_BELONG_CTY,
|
||||||
|
[HieLvl_INS] = FigCch_NUM_USRS_BELONG_INS,
|
||||||
|
[HieLvl_CTR] = FigCch_NUM_USRS_BELONG_CTR,
|
||||||
|
};
|
||||||
|
static unsigned (*FunctionToGetNumUsrsWhoClaimToBelongToFromDB[HieLvl_NUM_LEVELS]) (long HieCod) =
|
||||||
|
{
|
||||||
|
[HieLvl_CTY] = Cty_DB_GetNumUsrsWhoClaimToBelongToCty,
|
||||||
|
[HieLvl_INS] = Ins_DB_GetNumUsrsWhoClaimToBelongToIns,
|
||||||
|
[HieLvl_CTR] = Ctr_DB_GetNumUsrsWhoClaimToBelongToCtr,
|
||||||
|
};
|
||||||
|
|
||||||
|
/***** 1. Fast check: Trivial case *****/
|
||||||
|
if (Node->HieCod <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/***** 2. Fast check: If already got... *****/
|
||||||
|
if (Node->NumUsrsWhoClaimToBelong.Valid)
|
||||||
|
return Node->NumUsrsWhoClaimToBelong.NumUsrs;
|
||||||
|
|
||||||
|
/***** 3. Fast check: If cached... *****/
|
||||||
|
if (Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].Valid &&
|
||||||
|
Node->HieCod == Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].HieCod)
|
||||||
|
{
|
||||||
|
Node->NumUsrsWhoClaimToBelong.NumUsrs = Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].NumUsrs;
|
||||||
|
Node->NumUsrsWhoClaimToBelong.Valid = true;
|
||||||
|
return Node->NumUsrsWhoClaimToBelong.NumUsrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** 4. Slow: number of users who claim to belong to a hierarchy node
|
||||||
|
from database *****/
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].HieCod = Node->HieCod;
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].NumUsrs =
|
||||||
|
Node->NumUsrsWhoClaimToBelong.NumUsrs = FunctionToGetNumUsrsWhoClaimToBelongToFromDB[Level] (Node->HieCod);
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].Valid =
|
||||||
|
Node->NumUsrsWhoClaimToBelong.Valid = true;
|
||||||
|
FigCch_UpdateFigureIntoCache (Figure[Level],Level,Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].HieCod,
|
||||||
|
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongTo[Level].NumUsrs);
|
||||||
|
return Node->NumUsrsWhoClaimToBelong.NumUsrs;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** Show row with number of elements in hierarchy ****************/
|
/************** Show row with number of elements in hierarchy ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -81,4 +81,10 @@ unsigned Hie_GetCachedNumNodesInHieLvl (HieLvl_Level_t LevelChildren,
|
||||||
unsigned Hie_GetNumNodesInHieLvl (HieLvl_Level_t LevelChildren,
|
unsigned Hie_GetNumNodesInHieLvl (HieLvl_Level_t LevelChildren,
|
||||||
HieLvl_Level_t LevelParent,long HieCod);
|
HieLvl_Level_t LevelParent,long HieCod);
|
||||||
|
|
||||||
|
void Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_Level_t Level);
|
||||||
|
unsigned Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_Level_t Level,
|
||||||
|
struct Hie_Node *Node);
|
||||||
|
unsigned Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_Level_t Level,
|
||||||
|
struct Hie_Node *Node);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -391,7 +391,7 @@ static void Ins_ListOneInstitutionForSeeing (struct Hie_Node *Ins,unsigned NumIn
|
||||||
/***** Number of users who claim to belong to this institution *****/
|
/***** Number of users who claim to belong to this institution *****/
|
||||||
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
||||||
TxtClassNormal,The_GetSuffix (),BgColor);
|
TxtClassNormal,The_GetSuffix (),BgColor);
|
||||||
HTM_Unsigned (Ins_GetCachedNumUsrsWhoClaimToBelongToIns (Ins));
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_INS,Ins));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Other stats *****/
|
/***** Other stats *****/
|
||||||
|
@ -903,8 +903,10 @@ static void Ins_ListInstitutionsForEdition (void)
|
||||||
Ins = &Gbl.Hierarchy.List[HieLvl_CTY].Lst[NumIns];
|
Ins = &Gbl.Hierarchy.List[HieLvl_CTY].Lst[NumIns];
|
||||||
|
|
||||||
ICanEdit = Ins_CheckIfICanEdit (Ins);
|
ICanEdit = Ins_CheckIfICanEdit (Ins);
|
||||||
NumCtrs = Hie_GetNumNodesInHieLvl (HieLvl_CTR,HieLvl_INS,Ins->HieCod);
|
NumCtrs = Hie_GetNumNodesInHieLvl (HieLvl_CTR, // Number of centers...
|
||||||
NumUsrsIns = Ins_GetNumUsrsWhoClaimToBelongToIns (Ins);
|
HieLvl_INS, // ...in institution
|
||||||
|
Ins->HieCod);
|
||||||
|
NumUsrsIns = Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_INS,Ins);
|
||||||
NumUsrsInCrssOfIns = Enr_GetNumUsrsInCrss (HieLvl_INS,Ins->HieCod,
|
NumUsrsInCrssOfIns = Enr_GetNumUsrsInCrss (HieLvl_INS,Ins->HieCod,
|
||||||
1 << Rol_STD |
|
1 << Rol_STD |
|
||||||
1 << Rol_NET |
|
1 << Rol_NET |
|
||||||
|
@ -1074,7 +1076,7 @@ void Ins_RemoveInstitution (void)
|
||||||
// Institution has centers ==> don't remove
|
// Institution has centers ==> don't remove
|
||||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||||
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
||||||
else if (Ins_GetNumUsrsWhoClaimToBelongToIns (Ins_EditingIns))
|
else if (Hie_GetNumUsrsWhoClaimToBelongTo (HieLvl_INS,Ins_EditingIns))
|
||||||
// Institution has users ==> don't remove
|
// Institution has users ==> don't remove
|
||||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||||
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
||||||
|
@ -1115,7 +1117,7 @@ void Ins_RemoveInstitution (void)
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CTR,HieLvl_INS); // Number of centers in institution
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CTR,HieLvl_INS); // Number of centers in institution
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_DEG,HieLvl_INS); // Number of degrees in institution
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_DEG,HieLvl_INS); // Number of degrees in institution
|
||||||
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CRS,HieLvl_INS); // Number of courses in institution
|
Hie_FlushCachedNumNodesInHieLvl (HieLvl_CRS,HieLvl_INS); // Number of courses in institution
|
||||||
Ins_FlushCacheNumUsrsWhoClaimToBelongToIns ();
|
Hie_FlushCacheNumUsrsWhoClaimToBelongTo (HieLvl_INS);
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -1827,58 +1829,6 @@ bool Ins_CheckIfIBelongToIns (long InsCod)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/******** Get number of users who claim to belong to an institution **********/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Ins_FlushCacheNumUsrsWhoClaimToBelongToIns (void)
|
|
||||||
{
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToIns.HieCod = -1L;
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Ins_GetNumUsrsWhoClaimToBelongToIns (struct Hie_Node *Ins)
|
|
||||||
{
|
|
||||||
/***** 1. Fast check: Trivial case *****/
|
|
||||||
if (Ins->HieCod <= 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/***** 2. Fast check: If already got... *****/
|
|
||||||
if (Ins->NumUsrsWhoClaimToBelong.Valid)
|
|
||||||
return Ins->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
|
|
||||||
/***** 3. Fast check: If cached... *****/
|
|
||||||
if (Ins->HieCod == Gbl.Cache.NumUsrsWhoClaimToBelongToIns.HieCod)
|
|
||||||
{
|
|
||||||
Ins->NumUsrsWhoClaimToBelong.NumUsrs = Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs;
|
|
||||||
Ins->NumUsrsWhoClaimToBelong.Valid = true;
|
|
||||||
return Ins->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** 4. Slow: number of users who claim to belong to an institution
|
|
||||||
from database *****/
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToIns.HieCod = Ins->HieCod;
|
|
||||||
Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs =
|
|
||||||
Ins->NumUsrsWhoClaimToBelong.NumUsrs = Ins_DB_GetNumUsrsWhoClaimToBelongToIns (Ins->HieCod);
|
|
||||||
Ins->NumUsrsWhoClaimToBelong.Valid = true;
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_INS,HieLvl_INS,Gbl.Cache.NumUsrsWhoClaimToBelongToIns.HieCod,
|
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs);
|
|
||||||
return Ins->NumUsrsWhoClaimToBelong.NumUsrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Ins_GetCachedNumUsrsWhoClaimToBelongToIns (struct Hie_Node *Ins)
|
|
||||||
{
|
|
||||||
unsigned NumUsrsIns;
|
|
||||||
|
|
||||||
/***** Get number of users who claim to belong to institution from cache *****/
|
|
||||||
if (!FigCch_GetFigureFromCache (FigCch_NUM_USRS_BELONG_INS,HieLvl_INS,Ins->HieCod,
|
|
||||||
FigCch_UNSIGNED,&NumUsrsIns))
|
|
||||||
/***** Get current number of users who claim to belong to institution from database and update cache *****/
|
|
||||||
NumUsrsIns = Ins_GetNumUsrsWhoClaimToBelongToIns (Ins);
|
|
||||||
|
|
||||||
return NumUsrsIns;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Write parameter with code of institution ******************/
|
/***************** Write parameter with code of institution ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -83,10 +83,6 @@ void Ins_GetMyInstits (void);
|
||||||
void Ins_FreeMyInstits (void);
|
void Ins_FreeMyInstits (void);
|
||||||
bool Ins_CheckIfIBelongToIns (long InsCod);
|
bool Ins_CheckIfIBelongToIns (long InsCod);
|
||||||
|
|
||||||
void Ins_FlushCacheNumUsrsWhoClaimToBelongToIns (void);
|
|
||||||
unsigned Ins_GetNumUsrsWhoClaimToBelongToIns (struct Hie_Node *Ins);
|
|
||||||
unsigned Ins_GetCachedNumUsrsWhoClaimToBelongToIns (struct Hie_Node *Ins);
|
|
||||||
|
|
||||||
void Ins_PutParInsCod (void *InsCod);
|
void Ins_PutParInsCod (void *InsCod);
|
||||||
|
|
||||||
//-------------------------------- Figures ------------------------------------
|
//-------------------------------- Figures ------------------------------------
|
||||||
|
|
|
@ -428,7 +428,8 @@ static void InsCfg_NumUsrs (void)
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ());
|
||||||
HTM_Unsigned (Ins_GetCachedNumUsrsWhoClaimToBelongToIns (&Gbl.Hierarchy.Node[HieLvl_INS]));
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (HieLvl_INS,
|
||||||
|
&Gbl.Hierarchy.Node[HieLvl_INS]));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
|
@ -214,7 +214,9 @@ void Plc_SeeAllPlaces (void)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
||||||
HTM_Unsigned (Hie_GetNumNodesInHieLvl (HieLvl_CTR,HieLvl_INS,Gbl.Hierarchy.Node[HieLvl_INS].HieCod) -
|
HTM_Unsigned (Hie_GetNumNodesInHieLvl (HieLvl_CTR, // Number of centers...
|
||||||
|
HieLvl_INS, // ...in institution
|
||||||
|
Gbl.Hierarchy.Node[HieLvl_INS].HieCod) -
|
||||||
NumCtrsWithPlc);
|
NumCtrsWithPlc);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
|
|
|
@ -4036,7 +4036,9 @@ void Rec_ChgCountryOfMyInstitution (void)
|
||||||
Gbl.Usrs.Me.UsrDat.InsCtyCod = ParCod_GetAndCheckPar (ParCod_OthCty);
|
Gbl.Usrs.Me.UsrDat.InsCtyCod = ParCod_GetAndCheckPar (ParCod_OthCty);
|
||||||
|
|
||||||
/***** When country changes, the institution, center and department must be reset *****/
|
/***** When country changes, the institution, center and department must be reset *****/
|
||||||
NumInss = Hie_GetNumNodesInHieLvl (HieLvl_INS,HieLvl_CTY,Gbl.Usrs.Me.UsrDat.InsCtyCod);
|
NumInss = Hie_GetNumNodesInHieLvl (HieLvl_INS, // Number of institutions...
|
||||||
|
HieLvl_CTY, // ...in country
|
||||||
|
Gbl.Usrs.Me.UsrDat.InsCtyCod);
|
||||||
if (NumInss)
|
if (NumInss)
|
||||||
{
|
{
|
||||||
Gbl.Usrs.Me.UsrDat.InsCod = -1L;
|
Gbl.Usrs.Me.UsrDat.InsCod = -1L;
|
||||||
|
@ -4083,7 +4085,9 @@ void Rec_UpdateMyInstitution (void)
|
||||||
Gbl.Usrs.Me.UsrDat.InsCod = Ins.HieCod;
|
Gbl.Usrs.Me.UsrDat.InsCod = Ins.HieCod;
|
||||||
|
|
||||||
/***** When institution changes, the center and department must be reset *****/
|
/***** When institution changes, the center and department must be reset *****/
|
||||||
NumCtrs = Hie_GetNumNodesInHieLvl (HieLvl_CTR,HieLvl_INS,Gbl.Usrs.Me.UsrDat.InsCod);
|
NumCtrs = Hie_GetNumNodesInHieLvl (HieLvl_CTR, // Number of centers...
|
||||||
|
HieLvl_INS, // ...in institution
|
||||||
|
Gbl.Usrs.Me.UsrDat.InsCod);
|
||||||
NumDpts = Dpt_GetNumDptsInIns (Gbl.Usrs.Me.UsrDat.InsCod);
|
NumDpts = Dpt_GetNumDptsInIns (Gbl.Usrs.Me.UsrDat.InsCod);
|
||||||
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = (NumCtrs ? -1L : 0);
|
Gbl.Usrs.Me.UsrDat.Tch.CtrCod = (NumCtrs ? -1L : 0);
|
||||||
Gbl.Usrs.Me.UsrDat.Tch.DptCod = (NumDpts ? -1L : 0);
|
Gbl.Usrs.Me.UsrDat.Tch.DptCod = (NumDpts ? -1L : 0);
|
||||||
|
|
Loading…
Reference in New Issue