Version 23.17.2: Sep 25, 2023 Fixed bug in hierarchy.

This commit is contained in:
acanas 2023-09-25 21:14:05 +02:00
parent 2c3f4ee574
commit 820dba7995
5 changed files with 72 additions and 42 deletions

View File

@ -632,10 +632,11 @@ TODO: Francisco Javier Fern
Me sale este error, no 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.17.1 (2023-09-25)"
#define Log_PLATFORM_VERSION "SWAD 23.17.2 (2023-09-25)"
#define CSS_FILE "swad23.16.1.css"
#define JS_FILE "swad22.49.js"
/*
Version 23.17.2: Sep 25, 2023 Fixed bug in hierarchy. (336673 lines)
Version 23.17.1: Sep 25, 2023 Fixed bug in hierarchy. (336654 lines)
Version 23.17: Sep 25, 2023 Code refactoring in hierarchy. (336655 lines)
Version 23.16.1: Sep 25, 2023 Fixed CSS issues. (336778 lines)

View File

@ -295,41 +295,54 @@ unsigned Cty_DB_GetNumCtysInSys (__attribute__((unused)) long SysCod)
/***************** Get number of countries with institutions *****************/
/*****************************************************************************/
unsigned Cty_DB_GetNumCtysWithInss (__attribute__((unused)) Hie_Level_t Level,
__attribute__((unused)) long HieCod)
unsigned Cty_DB_GetNumCtysWithInss (Hie_Level_t Level,long HieCod)
{
char SubQuery[128];
Hie_DB_BuildSubquery (SubQuery,Level,HieCod);
return (unsigned)
DB_QueryCOUNT ("can not get number of countries with institutions",
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
" FROM cty_countrs,"
"ins_instits"
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod");
" WHERE %s"
"cty_countrs.CtyCod=ins_instits.CtyCod",
SubQuery);
}
/*****************************************************************************/
/******************* Get number of countries with centers ********************/
/*****************************************************************************/
unsigned Cty_DB_GetNumCtysWithCtrs (__attribute__((unused)) Hie_Level_t Level,
__attribute__((unused)) long HieCod)
unsigned Cty_DB_GetNumCtysWithCtrs (Hie_Level_t Level,long HieCod)
{
char SubQuery[128];
Hie_DB_BuildSubquery (SubQuery,Level,HieCod);
return (unsigned)
DB_QueryCOUNT ("can not get number of countries with centers",
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
" FROM cty_countrs,"
"ins_instits,"
"ctr_centers"
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod"
" AND ins_instits.InsCod=ctr_centers.InsCod");
" WHERE %s"
"cty_countrs.CtyCod=ins_instits.CtyCod"
" AND ins_instits.InsCod=ctr_centers.InsCod",
SubQuery);
}
/*****************************************************************************/
/******************* Get number of countries with degrees ********************/
/*****************************************************************************/
unsigned Cty_DB_GetNumCtysWithDegs (__attribute__((unused)) Hie_Level_t Level,
__attribute__((unused)) long HieCod)
unsigned Cty_DB_GetNumCtysWithDegs (Hie_Level_t Level,long HieCod)
{
char SubQuery[128];
Hie_DB_BuildSubquery (SubQuery,Level,HieCod);
return (unsigned)
DB_QueryCOUNT ("can not get number of countries with degrees",
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
@ -337,18 +350,23 @@ unsigned Cty_DB_GetNumCtysWithDegs (__attribute__((unused)) Hie_Level_t Level,
"ins_instits,"
"ctr_centers,"
"deg_degrees"
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod"
" WHERE %s"
"cty_countrs.CtyCod=ins_instits.CtyCod"
" AND ins_instits.InsCod=ctr_centers.InsCod"
" AND ctr_centers.CtrCod=deg_degrees.CtrCod");
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
SubQuery);
}
/*****************************************************************************/
/******************* Get number of countries with courses ********************/
/*****************************************************************************/
unsigned Cty_DB_GetNumCtysWithCrss (__attribute__((unused)) Hie_Level_t Level,
__attribute__((unused)) long HieCod)
unsigned Cty_DB_GetNumCtysWithCrss (Hie_Level_t Level,long HieCod)
{
char SubQuery[128];
Hie_DB_BuildSubquery (SubQuery,Level,HieCod);
return (unsigned)
DB_QueryCOUNT ("can not get number of countries with courses",
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
@ -357,10 +375,12 @@ unsigned Cty_DB_GetNumCtysWithCrss (__attribute__((unused)) Hie_Level_t Level,
"ctr_centers,"
"deg_degrees,"
"crs_courses"
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod"
" WHERE %s"
"cty_countrs.CtyCod=ins_instits.CtyCod"
" AND ins_instits.InsCod=ctr_centers.InsCod"
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
" AND deg_degrees.DegCod=crs_courses.DegCod");
" AND deg_degrees.DegCod=crs_courses.DegCod",
SubQuery);
}
/*****************************************************************************/

View File

@ -52,14 +52,10 @@ void Cty_DB_GetCountryName (long CtyCod,Lan_Language_t Language,
unsigned Cty_DB_GetNumCtysInSys (__attribute__((unused)) long SysCod);
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_GetNumCtysWithInss (Hie_Level_t Level,long HieCod);
unsigned Cty_DB_GetNumCtysWithCtrs (Hie_Level_t Level,long HieCod);
unsigned Cty_DB_GetNumCtysWithDegs (Hie_Level_t Level,long HieCod);
unsigned Cty_DB_GetNumCtysWithCrss (Hie_Level_t Level,long HieCod);
unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,
Hie_Level_t Level,long Cod);

View File

@ -80,7 +80,7 @@ static Hie_StatusTxt_t Hie_GetStatusTxtFromStatusBits (Hie_Status_t Status);
static Hie_Status_t Hie_GetStatusBitsFromStatusTxt (Hie_StatusTxt_t StatusTxt);
static void Hie_WriteHeadHierarchy (void);
static void Hie_GetAndShowHierarchyWith (Hie_Level_t LevelGrandChildren);
static void Hie_GetAndShowHierarchyWithNodes (Hie_Level_t HavingNodesOfLevel);
static void Hie_GetAndShowHierarchyWithUsrs (Rol_Role_t Role);
static void Hie_GetAndShowHierarchyTotal (void);
static void Hie_ShowHierarchyRow (const char *Text1,const char *Text2,
@ -979,6 +979,7 @@ void Hie_GetAndShowHierarchyStats (void)
{
extern const char *Hlp_ANALYTICS_Figures_hierarchy;
extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
Hie_Level_t HavingNodesOfLevel;
Rol_Role_t Role;
/***** Begin box and table *****/
@ -986,15 +987,22 @@ void Hie_GetAndShowHierarchyStats (void)
NULL,NULL,
Hlp_ANALYTICS_Figures_hierarchy,Box_NOT_CLOSABLE,2);
/* Head row */
Hie_WriteHeadHierarchy ();
Hie_GetAndShowHierarchyWith (Hie_INS);
Hie_GetAndShowHierarchyWith (Hie_CTR);
Hie_GetAndShowHierarchyWith (Hie_DEG);
Hie_GetAndShowHierarchyWith (Hie_CRS);
/* Rows with number of nodes having nodes of each level */
for (HavingNodesOfLevel = Hie_INS;
HavingNodesOfLevel <= Hie_CRS;
HavingNodesOfLevel++)
Hie_GetAndShowHierarchyWithNodes (HavingNodesOfLevel);
/* Rows with number of nodes having users of each role */
for (Role = Rol_TCH;
Role >= Rol_STD;
Role--)
Hie_GetAndShowHierarchyWithUsrs (Role);
/* Row with total nodes */
Hie_GetAndShowHierarchyTotal ();
/***** End table and box *****/
@ -1059,7 +1067,7 @@ static void Hie_WriteHeadHierarchy (void)
/********* Get and show number of elements in hierarchy with nodes ***********/
/*****************************************************************************/
static void Hie_GetAndShowHierarchyWith (Hie_Level_t LevelGrandChildren)
static void Hie_GetAndShowHierarchyWithNodes (Hie_Level_t HavingNodesOfLevel)
{
extern const char *Txt_With_;
extern const char *Txt_institutions;
@ -1081,17 +1089,18 @@ static void Hie_GetAndShowHierarchyWith (Hie_Level_t LevelGrandChildren)
for (LevelChildren = Hie_CTY;
LevelChildren <= Hie_CRS;
LevelChildren++)
if (LevelChildren >= LevelGrandChildren) // Example: don't show number of centers with institutions
if (LevelChildren >= HavingNodesOfLevel) // Example: don't show number of centers with institutions
NumNodes[LevelChildren] = -1;
else if (LevelChildren < Gbl.Scope.Current) // Example: if scope is center (4) =>
NumNodes[LevelChildren] = 1; // number of countries/instit./centers in center is 1
else if (LevelChildren < Gbl.Scope.Current && // Example: if scope is center (4)
HavingNodesOfLevel <= Gbl.Scope.Current) // number of nodes with instit./countries/centers
NumNodes[LevelChildren] = 1; // in current center is 1
else
NumNodes[LevelChildren] = (int) Hie_GetCachedNumNodesInHieLvlWith (LevelChildren, // Child
NumNodes[LevelChildren] = (int) Hie_GetCachedNumNodesInHieLvlWith (LevelChildren, // Child
Gbl.Scope.Current, // Parent
LevelGrandChildren);// Grand child
HavingNodesOfLevel);// Grand child
/***** Write number of elements with courses *****/
Hie_ShowHierarchyRow (Txt_With_,*Txt[LevelGrandChildren],"DAT",NumNodes);
Hie_ShowHierarchyRow (Txt_With_,*Txt[HavingNodesOfLevel],"DAT",NumNodes);
}
/*****************************************************************************/
@ -1207,13 +1216,17 @@ unsigned Hie_GetNumNodesInHieLvl (Hie_Level_t LevelChildren,
}
/*****************************************************************************/
/***** Get number of children nodes in parent node with children nodes *********************/
/**** Get number of children nodes in parent node having nodes of a level ****/
/*****************************************************************************/
unsigned Hie_GetCachedNumNodesInHieLvlWith (Hie_Level_t LevelChildren,
Hie_Level_t LevelParent,
Hie_Level_t LevelGrandChildren)
Hie_Level_t HavingNodesOfLevel)
{
// Example: number of centers with courses in current institution
// LevelChildren = center
// LevelParent = institution
// HavingNodesOfLevel = course
static FigCch_FigureCached_t Figure[Hie_NUM_LEVELS][Hie_NUM_LEVELS] =
{
// Child / Grandchild
@ -1251,13 +1264,13 @@ unsigned Hie_GetCachedNumNodesInHieLvlWith (Hie_Level_t LevelChildren,
unsigned NumNodes;
/***** Get number of centers with degrees from cache *****/
if (!FigCch_GetFigureFromCache (Figure[LevelChildren][LevelGrandChildren],
if (!FigCch_GetFigureFromCache (Figure[LevelChildren][HavingNodesOfLevel],
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],
NumNodes = FunctionGetFigure[LevelChildren][HavingNodesOfLevel] (LevelParent,Gbl.Hierarchy.Node[LevelParent].HieCod);
FigCch_UpdateFigureIntoCache (Figure[LevelChildren][HavingNodesOfLevel],
LevelParent,Gbl.Hierarchy.Node[LevelParent].HieCod,
FigCch_UNSIGNED,&NumNodes);
}

View File

@ -80,7 +80,7 @@ unsigned Hie_GetNumNodesInHieLvl (Hie_Level_t LevelChildren,
unsigned Hie_GetCachedNumNodesInHieLvlWith (Hie_Level_t LevelChildren,
Hie_Level_t LevelParent,
Hie_Level_t LevelGrandChildren);
Hie_Level_t HavingNodesOfLevel);
void Hie_FlushCacheNumUsrsWhoClaimToBelongTo (Hie_Level_t Level);
unsigned Hie_GetCachedNumUsrsWhoClaimToBelongTo (Hie_Level_t Level,