mirror of https://github.com/acanas/swad-core.git
Version19.112.17
This commit is contained in:
parent
c1c5b80044
commit
6d0f193fd7
|
@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112.16 (2020-01-06)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112.17 (2020-01-07)"
|
||||
#define CSS_FILE "swad19.112.css"
|
||||
#define JS_FILE "swad19.91.1.js"
|
||||
/*
|
||||
|
@ -501,9 +501,9 @@ ps2pdf source.ps destination.pdf
|
|||
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
|
||||
// TODO: Mapas más estrechos en móvil
|
||||
// TODO: Quitar todos los EXTRA_DATA.
|
||||
Optimize Ins_GetNumInssInCty
|
||||
|
||||
Version 19.112.16:Jan 06, 2020 Optimization in number of centres in an institution. (? lines)
|
||||
Version 19.112.17:Jan 07, 2020 Optimization in number of institutions in a country. (278600 lines)
|
||||
Version 19.112.16:Jan 07, 2020 Optimization in number of centres in an institution. (278576 lines)
|
||||
Version 19.112.15:Jan 06, 2020 Optimization in number of degrees in an institution. (278567 lines)
|
||||
Version 19.112.14:Jan 06, 2020 Optimization in number of courses in an institution. (278555 lines)
|
||||
Version 19.112.13:Jan 06, 2020 Optimization in number of departments in an institution. (278535 lines)
|
||||
|
|
|
@ -421,7 +421,7 @@ static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty)
|
|||
HTM_TD_End ();
|
||||
|
||||
HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor);
|
||||
HTM_Unsigned (Cty->Inss.Num);
|
||||
HTM_Unsigned (Ins_GetNumInssInCty (Cty->CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor);
|
||||
|
@ -880,9 +880,6 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
|
|||
&Cty->NumUsrsWhoClaimToBelongToCty) != 1)
|
||||
Cty->NumUsrsWhoClaimToBelongToCty = 0;
|
||||
|
||||
/* Get number of institutions in this country */
|
||||
Cty->Inss.Num = Ins_GetNumInssInCty (Cty->CtyCod);
|
||||
|
||||
/* Get number of centres in this country */
|
||||
Cty->NumCtrs = Ctr_GetNumCtrsInCty (Cty->CtyCod);
|
||||
|
||||
|
@ -1140,9 +1137,6 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
|
|||
/* Get number of user in courses of this institution */
|
||||
Cty->NumUsrs = Usr_GetNumUsrsInCrssOfCty (Rol_UNK,Cty->CtyCod); // Here Rol_UNK means "all users"
|
||||
|
||||
/* Get number of institutions in this country */
|
||||
Cty->Inss.Num = Ins_GetNumInssInCty (Cty->CtyCod);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1234,6 +1228,7 @@ static void Cty_ListCountriesForEdition (void)
|
|||
extern const char *Txt_STR_LANG_NAME[1 + Lan_NUM_LANGUAGES];
|
||||
unsigned NumCty;
|
||||
struct Country *Cty;
|
||||
unsigned NumInssInCty;
|
||||
Lan_Language_t Lan;
|
||||
|
||||
/***** Write heading *****/
|
||||
|
@ -1246,14 +1241,16 @@ static void Cty_ListCountriesForEdition (void)
|
|||
NumCty++)
|
||||
{
|
||||
Cty = &Gbl.Hierarchy.Sys.Ctys.Lst[NumCty];
|
||||
NumInssInCty = Ins_GetNumInssInCty (Cty->CtyCod);
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Put icon to remove country */
|
||||
HTM_TD_Begin ("rowspan=\"%u\" class=\"BT\"",1 + Lan_NUM_LANGUAGES);
|
||||
if (Cty->Inss.Num ||
|
||||
if (NumInssInCty || // Country has institutions
|
||||
Cty->NumUsrsWhoClaimToBelongToCty ||
|
||||
Cty->NumUsrs) // Country has institutions or users ==> deletion forbidden
|
||||
Cty->NumUsrs) // Country has users
|
||||
// Deletion forbidden
|
||||
Ico_PutIconRemovalNotAllowed ();
|
||||
else
|
||||
{
|
||||
|
@ -1283,7 +1280,7 @@ static void Cty_ListCountriesForEdition (void)
|
|||
|
||||
/* Number of institutions */
|
||||
HTM_TD_Begin ("rowspan=\"%u\" class=\"DAT RT\"",1 + Lan_NUM_LANGUAGES);
|
||||
HTM_Unsigned (Cty->Inss.Num);
|
||||
HTM_Unsigned (NumInssInCty);
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
|
@ -1386,9 +1383,11 @@ void Cty_RemoveCountry (void)
|
|||
Cty_GetDataOfCountryByCod (Cty_EditingCty,Cty_GET_EXTRA_DATA);
|
||||
|
||||
/***** Check if this country has users *****/
|
||||
if (Cty_EditingCty->Inss.Num ||
|
||||
Cty_EditingCty->NumUsrsWhoClaimToBelongToCty ||
|
||||
Cty_EditingCty->NumUsrs) // Country has institutions or users ==> don't remove
|
||||
if (Ins_GetNumInssInCty (Cty_EditingCty->CtyCod)) // Country has institutions ==> don't remove
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
||||
else if (Cty_EditingCty->NumUsrsWhoClaimToBelongToCty ||
|
||||
Cty_EditingCty->NumUsrs) // Country has users ==> don't remove
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
||||
else // Country has no users ==> remove it
|
||||
|
@ -1403,6 +1402,7 @@ void Cty_RemoveCountry (void)
|
|||
|
||||
/***** Flush cache *****/
|
||||
Cty_FlushCacheCountryName ();
|
||||
Ins_FlushCacheNumInssInCty ();
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||
|
|
|
@ -406,6 +406,7 @@ void Gbl_InitializeGlobals (void)
|
|||
Cty_FlushCacheCountryName ();
|
||||
Ins_FlushCacheShortNameOfInstitution ();
|
||||
Ins_FlushCacheFullNameAndCtyOfInstitution ();
|
||||
Ins_FlushCacheNumInssInCty ();
|
||||
Dpt_FlushCacheNumDptsInIns ();
|
||||
Ctr_FlushCacheNumCtrsInIns ();
|
||||
Deg_FlushCacheNumDegsInIns ();
|
||||
|
|
|
@ -777,6 +777,12 @@ struct Globals
|
|||
long InsCod;
|
||||
unsigned NumDpts;
|
||||
} NumDptsInIns;
|
||||
struct
|
||||
{
|
||||
bool Valid;
|
||||
long CtyCod;
|
||||
unsigned NumInss;
|
||||
} NumInssInCty;
|
||||
struct
|
||||
{
|
||||
long InsCod;
|
||||
|
|
|
@ -696,7 +696,10 @@ void Ins_GetListInstitutions (long CtyCod)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gbl.Hierarchy.Cty.Inss.Num = 0;
|
||||
Gbl.Hierarchy.Cty.Inss.Lst = NULL;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -925,8 +928,8 @@ void Ins_FreeListInstitutions (void)
|
|||
{
|
||||
/***** Free memory used by the list of institutions *****/
|
||||
free (Gbl.Hierarchy.Cty.Inss.Lst);
|
||||
Gbl.Hierarchy.Cty.Inss.Lst = NULL;
|
||||
Gbl.Hierarchy.Cty.Inss.Num = 0;
|
||||
Gbl.Hierarchy.Cty.Inss.Lst = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1860,15 +1863,28 @@ unsigned Ins_GetNumInssTotal (void)
|
|||
/**************** Get number of institutions in a country ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Ins_FlushCacheNumInssInCty (void)
|
||||
{
|
||||
Gbl.Cache.NumInssInCty.Valid = false;
|
||||
}
|
||||
|
||||
unsigned Ins_GetNumInssInCty (long CtyCod)
|
||||
{
|
||||
/***** Get number of degrees of a place from database *****/
|
||||
return
|
||||
/***** 1. Fast check: If cached... *****/
|
||||
if (Gbl.Cache.NumInssInCty.Valid &&
|
||||
CtyCod == Gbl.Cache.NumInssInCty.CtyCod)
|
||||
return Gbl.Cache.NumInssInCty.NumInss;
|
||||
|
||||
/***** 2. Slow: number of institutions in a country from database *****/
|
||||
Gbl.Cache.NumInssInCty.CtyCod = CtyCod;
|
||||
Gbl.Cache.NumInssInCty.NumInss =
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of institutions"
|
||||
" in a country",
|
||||
"SELECT COUNT(*) FROM institutions"
|
||||
" WHERE CtyCod=%ld",
|
||||
CtyCod);
|
||||
Gbl.Cache.NumInssInCty.Valid = true;
|
||||
return Gbl.Cache.NumInssInCty.NumInss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -129,6 +129,7 @@ void Ins_RecFormReqIns (void);
|
|||
void Ins_RecFormNewIns (void);
|
||||
|
||||
unsigned Ins_GetNumInssTotal (void);
|
||||
void Ins_FlushCacheNumInssInCty (void);
|
||||
unsigned Ins_GetNumInssInCty (long CtyCod);
|
||||
unsigned Ins_GetNumInssWithCtrs (const char *SubQuery);
|
||||
unsigned Ins_GetNumInssWithDegs (const char *SubQuery);
|
||||
|
|
Loading…
Reference in New Issue