mirror of https://github.com/acanas/swad-core.git
Version19.112.10
This commit is contained in:
parent
e9bd881967
commit
1758567767
|
@ -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.9 (2020-01-05)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112.10 (2020-01-06)"
|
||||
#define CSS_FILE "swad19.112.css"
|
||||
#define JS_FILE "swad19.91.1.js"
|
||||
/*
|
||||
|
@ -501,8 +501,8 @@ 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.
|
||||
// TODO: ¿ Cachear Usr_GetNumUsrsInCrssOfDeg ?
|
||||
|
||||
Version 19.112.10:Jan 06, 2020 Optimization in number of users in courses of a degree. (278468 lines)
|
||||
Version 19.112.9: Jan 05, 2020 Optimization in number of users in a course. (278419 lines)
|
||||
Version 19.112.8: Jan 05, 2020 Optimization in number of courses in a degree. (278396 lines)
|
||||
Version 19.112.7: Jan 05, 2020 Optimization in number of degrees in a centre. (278384 lines)
|
||||
|
|
|
@ -1514,6 +1514,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
|||
|
||||
/***** Flush caches *****/
|
||||
Crs_FlushCacheNumCrssInDeg ();
|
||||
Usr_FlushCacheNumUsrsInCrssOfDeg ();
|
||||
|
||||
/***** Delete all the degrees in sta_degrees table not present in degrees table *****/
|
||||
Pho_RemoveObsoleteStatDegrees ();
|
||||
|
|
|
@ -417,6 +417,8 @@ void Gbl_InitializeGlobals (void)
|
|||
Crs_FlushCacheNumCrssInDeg ();
|
||||
Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr ();
|
||||
Usr_FlushCacheNumUsrsInCrssOfCtr ();
|
||||
Usr_FlushCacheNumUsrsInCrssOfDeg ();
|
||||
Usr_FlushCacheNumUsrsInCrs ();
|
||||
Usr_FlushCacheUsrIsSuperuser ();
|
||||
Usr_FlushCacheUsrBelongsToIns ();
|
||||
Usr_FlushCacheUsrBelongsToCtr ();
|
||||
|
|
|
@ -797,6 +797,11 @@ struct Globals
|
|||
long CtrCod;
|
||||
unsigned NumUsrs;
|
||||
} NumUsrsInCrssOfCtr[Rol_NUM_ROLES];
|
||||
struct
|
||||
{
|
||||
long DegCod;
|
||||
unsigned NumUsrs;
|
||||
} NumUsrsInCrssOfDeg[Rol_NUM_ROLES];
|
||||
struct
|
||||
{
|
||||
long CrsCod;
|
||||
|
|
65
swad_user.c
65
swad_user.c
|
@ -4223,18 +4223,63 @@ unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod)
|
|||
/*********** Count how many users with a role belong to a degree *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Usr_FlushCacheNumUsrsInCrssOfDeg (void)
|
||||
{
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_UNK].DegCod =
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_STD].DegCod =
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_NET].DegCod =
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_TCH].DegCod = -1L;
|
||||
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_UNK].NumUsrs =
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_STD].NumUsrs =
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_NET].NumUsrs =
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_TCH].NumUsrs = 0;
|
||||
}
|
||||
|
||||
unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod)
|
||||
{
|
||||
/***** Get the number of users in courses of a degree from database ******/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of users"
|
||||
" in courses of a degree",
|
||||
"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
DegCod,(unsigned) Role);
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (DegCod <= 0)
|
||||
return 0;
|
||||
|
||||
/***** 2. Fast check: Trivial case *****/
|
||||
switch (Role)
|
||||
{
|
||||
case Rol_UNK: // Here Rol_UNK means all
|
||||
case Rol_STD:
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***** 3. Fast check: If cached... *****/
|
||||
if (DegCod == Gbl.Cache.NumUsrsInCrssOfDeg[Role].DegCod)
|
||||
return Gbl.Cache.NumUsrsInCrssOfDeg[Role].NumUsrs;
|
||||
|
||||
/***** 4. Slow: number of users in courses of a degree from database *****/
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Role].DegCod = DegCod;
|
||||
if (Role == Rol_UNK)
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Rol_UNK].NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of users"
|
||||
" in courses of a degree",
|
||||
"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||
DegCod);
|
||||
else
|
||||
Gbl.Cache.NumUsrsInCrssOfDeg[Role].NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of users"
|
||||
" in courses of a degree",
|
||||
"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role=%u",
|
||||
DegCod,(unsigned) Role);
|
||||
return Gbl.Cache.NumUsrsInCrssOfDeg[Role].NumUsrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -409,6 +409,7 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
|
|||
|
||||
void Usr_FlushCacheNumUsrsInCrs (void);
|
||||
unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod);
|
||||
void Usr_FlushCacheNumUsrsInCrssOfDeg (void);
|
||||
unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);
|
||||
void Usr_FlushCacheNumUsrsInCrssOfCtr (void);
|
||||
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod);
|
||||
|
|
Loading…
Reference in New Issue