Version19.112.22

This commit is contained in:
Antonio Cañas Vargas 2020-01-07 16:37:46 +01:00
parent f30375e7ce
commit a8e670490f
7 changed files with 33 additions and 11 deletions

View File

@ -1828,15 +1828,31 @@ unsigned Ctr_GetNumCtrsTotal (void)
/******************* Get number of centres in a country **********************/
/*****************************************************************************/
void Ctr_FlushCacheNumCtrsInCty (void)
{
Gbl.Cache.NumCtrsInCty.CtyCod = -1L;
Gbl.Cache.NumCtrsInCty.NumCtrs = 0;
}
unsigned Ctr_GetNumCtrsInCty (long CtyCod)
{
/***** Get number of centres of a country from database *****/
return
/***** 1. Fast check: Trivial case *****/
if (CtyCod <= 0)
return 0;
/***** 2. Fast check: If cached... *****/
if (CtyCod == Gbl.Cache.NumCtrsInCty.CtyCod)
return Gbl.Cache.NumCtrsInCty.NumCtrs;
/***** 3. Slow: number of centres in a country from database *****/
Gbl.Cache.NumCtrsInCty.CtyCod = CtyCod;
Gbl.Cache.NumCtrsInCty.NumCtrs =
(unsigned) DB_QueryCOUNT ("can not get number of centres in a country",
"SELECT COUNT(*) FROM institutions,centres"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod",
CtyCod);
return Gbl.Cache.NumCtrsInCty.NumCtrs;
}
/*****************************************************************************/

View File

@ -121,6 +121,7 @@ void Ctr_RecFormReqCtr (void);
void Ctr_RecFormNewCtr (void);
unsigned Ctr_GetNumCtrsTotal (void);
void Ctr_FlushCacheNumCtrsInCty (void);
unsigned Ctr_GetNumCtrsInCty (long CtyCod);
void Ctr_FlushCacheNumCtrsInIns (void);
unsigned Ctr_GetNumCtrsInIns (long InsCod);

View File

@ -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.21 (2020-01-07)"
#define Log_PLATFORM_VERSION "SWAD 19.112.22 (2020-01-07)"
#define CSS_FILE "swad19.112.css"
#define JS_FILE "swad19.91.1.js"
/*
@ -502,6 +502,7 @@ ps2pdf source.ps destination.pdf
// TODO: Mapas más estrechos en móvil
// TODO: Quitar todos los EXTRA_DATA.
Version 19.112.22:Jan 07, 2020 Optimization in number of centres in a country. (278761 lines)
Version 19.112.21:Jan 07, 2020 Optimization in number of degrees in a country. (278741 lines)
Version 19.112.20:Jan 07, 2020 Optimization in number of courses in a country. (278724 lines)
Version 19.112.19:Jan 07, 2020 Optimization in number of users in a country. (278675 lines)

View File

@ -424,7 +424,7 @@ static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor);
HTM_Unsigned (Cty->NumCtrs);
HTM_Unsigned (Ctr_GetNumCtrsInCty (Cty->CtyCod));
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor);
@ -844,7 +844,7 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Cty->WWW[Lan][0] = '\0';
}
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
Cty->Inss.Num = Cty->NumCtrs = 0;
Cty->Inss.Num = 0;
/* Get the name of the country in current language */
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
@ -868,9 +868,6 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Cty->NumUsrsWhoClaimToBelongToCty.Valid = true;
else
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
/* Get number of centres in this country */
Cty->NumCtrs = Ctr_GetNumCtrsInCty (Cty->CtyCod);
break;
}
}
@ -997,8 +994,10 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
Cty->Name[Lan][0] = '\0';
Cty->WWW[Lan][0] = '\0';
}
Cty->Inss.Num = 0;
Cty->Inss.Lst = NULL;
Cty->Inss.SelectedOrder = Ins_ORDER_DEFAULT;
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
Cty->Inss.Num = Cty->NumCtrs = 0;
/***** Check if country code is correct *****/
if (Cty->CtyCod == 0)
@ -1373,6 +1372,7 @@ void Cty_RemoveCountry (void)
/***** Flush cache *****/
Cty_FlushCacheCountryName ();
Ins_FlushCacheNumInssInCty ();
Ctr_FlushCacheNumCtrsInCty ();
Deg_FlushCacheNumDegsInCty ();
Crs_FlushCacheNumCrssInCty ();
Usr_FlushCacheNumUsrsWhoClaimToBelongToCty ();
@ -2077,7 +2077,6 @@ static void Cty_EditingCountryConstructor (void)
Cty_EditingCty->Inss.Num = 0;
Cty_EditingCty->Inss.Lst = NULL;
Cty_EditingCty->Inss.SelectedOrder = Ins_ORDER_DEFAULT;
Cty_EditingCty->NumCtrs = 0;
Cty_EditingCty->NumUsrsWhoClaimToBelongToCty.Valid = false;
}

View File

@ -57,7 +57,6 @@ struct Country
struct Instit *Lst; // List of institutions in this country
Ins_Order_t SelectedOrder;
} Inss;
unsigned NumCtrs;
struct
{
bool Valid;

View File

@ -408,6 +408,7 @@ void Gbl_InitializeGlobals (void)
Ins_FlushCacheFullNameAndCtyOfInstitution ();
Ins_FlushCacheNumInssInCty ();
Ctr_FlushCacheNumCtrsInCty ();
Deg_FlushCacheNumDegsInCty ();
Crs_FlushCacheNumCrssInCty ();

View File

@ -783,6 +783,11 @@ struct Globals
long CtyCod;
unsigned NumInss;
} NumInssInCty;
struct
{
long CtyCod;
unsigned NumCtrs;
} NumCtrsInCty;
struct
{
long InsCod;