mirror of https://github.com/acanas/swad-core.git
Version 20.51.3: Mar 18, 2021 Figures database table renamed.
This commit is contained in:
parent
881849f3e7
commit
b73f4f6ccf
|
@ -571,9 +571,9 @@ CREATE TABLE IF NOT EXISTS exa_sets (
|
||||||
UNIQUE INDEX(SetCod),
|
UNIQUE INDEX(SetCod),
|
||||||
UNIQUE INDEX(ExaCod,SetInd));
|
UNIQUE INDEX(ExaCod,SetInd));
|
||||||
--
|
--
|
||||||
-- Table figures: stores cached figures for quick retrieval of figures (i.e. number of students in the platform)
|
-- Table fig_figures: stores cached figures for quick retrieval of figures (i.e. number of students in the platform)
|
||||||
--
|
--
|
||||||
CREATE TABLE IF NOT EXISTS figures (
|
CREATE TABLE IF NOT EXISTS fig_figures (
|
||||||
Figure INT NOT NULL,
|
Figure INT NOT NULL,
|
||||||
Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',
|
Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',
|
||||||
Cod INT NOT NULL DEFAULT -1,
|
Cod INT NOT NULL DEFAULT -1,
|
||||||
|
|
|
@ -600,13 +600,17 @@ TODO: Salvador Romero Cort
|
||||||
|
|
||||||
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.51.1 (2021-03-18)"
|
#define Log_PLATFORM_VERSION "SWAD 20.51.3 (2021-03-18)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 20.51.3: Mar 18, 2021 Figures database table renamed. (307558 lines)
|
||||||
|
1 change necessary in database:
|
||||||
|
RENAME TABLE figures TO fig_figures;
|
||||||
|
|
||||||
Version 20.51.2: Mar 18, 2021 Expanded folders database table renamed. (307539 lines)
|
Version 20.51.2: Mar 18, 2021 Expanded folders database table renamed. (307539 lines)
|
||||||
1 change necessary in database:
|
1 change necessary in database:
|
||||||
RENAME TABLE expanded_folders TO brw_expanded_folders;
|
RENAME TABLE expanded_folders TO brw_expanded_folders;
|
||||||
|
|
|
@ -1255,22 +1255,22 @@ mysql> DESCRIBE exa_sets;
|
||||||
"UNIQUE INDEX(SetCod),"
|
"UNIQUE INDEX(SetCod),"
|
||||||
"UNIQUE INDEX(ExaCod,SetInd))");
|
"UNIQUE INDEX(ExaCod,SetInd))");
|
||||||
|
|
||||||
/***** Table figures *****/
|
/***** Table fig_figures *****/
|
||||||
/*
|
/*
|
||||||
mysql> DESCRIBE figures;
|
mysql> DESCRIBE fig_figures;
|
||||||
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------------------------+
|
||||||
| Field | Type | Null | Key | Default | Extra |
|
| Field | Type | Null | Key | Default | Extra |
|
||||||
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------------------------+
|
||||||
| Figure | int(11) | NO | PRI | NULL | |
|
| Figure | int | NO | PRI | NULL | |
|
||||||
| Scope | enum('Sys','Cty','Ins','Ctr','Deg','Crs') | NO | PRI | Sys | |
|
| Scope | enum('Sys','Cty','Ins','Ctr','Deg','Crs') | NO | PRI | Sys | |
|
||||||
| Cod | int(11) | NO | PRI | -1 | |
|
| Cod | int | NO | PRI | -1 | |
|
||||||
| ValueInt | int(11) | NO | | 0 | |
|
| ValueInt | int | NO | | 0 | |
|
||||||
| ValueDouble | double | NO | | 0 | |
|
| ValueDouble | double | NO | | 0 | |
|
||||||
| LastUpdate | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
| LastUpdate | timestamp | NO | | CURRENT_TIMESTAMP | DEFAULT_GENERATED on update CURRENT_TIMESTAMP |
|
||||||
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------+
|
+-------------+-------------------------------------------+------+-----+-------------------+-----------------------------------------------+
|
||||||
6 rows in set (0.00 sec)
|
6 rows in set (0.01 sec)
|
||||||
*/
|
*/
|
||||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS figures ("
|
DB_CreateTable ("CREATE TABLE IF NOT EXISTS fig_figures ("
|
||||||
"Figure INT NOT NULL,"
|
"Figure INT NOT NULL,"
|
||||||
"Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',"
|
"Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',"
|
||||||
"Cod INT NOT NULL DEFAULT -1,"
|
"Cod INT NOT NULL DEFAULT -1,"
|
||||||
|
|
|
@ -69,7 +69,7 @@ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||||
{
|
{
|
||||||
case FigCch_UNSIGNED:
|
case FigCch_UNSIGNED:
|
||||||
DB_QueryREPLACE ("can not update cached figure value",
|
DB_QueryREPLACE ("can not update cached figure value",
|
||||||
"REPLACE INTO figures"
|
"REPLACE INTO fig_figures"
|
||||||
" (Figure,Scope,Cod,ValueInt,ValueDouble)"
|
" (Figure,Scope,Cod,ValueInt,ValueDouble)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%u,'%s',%ld,%u,'0.0')",
|
" (%u,'%s',%ld,%u,'0.0')",
|
||||||
|
@ -79,7 +79,7 @@ void FigCch_UpdateFigureIntoCache (FigCch_FigureCached_t Figure,
|
||||||
case FigCch_DOUBLE:
|
case FigCch_DOUBLE:
|
||||||
Str_SetDecimalPointToUS (); // To write the decimal point as a dot
|
Str_SetDecimalPointToUS (); // To write the decimal point as a dot
|
||||||
DB_QueryREPLACE ("can not update cached figure value",
|
DB_QueryREPLACE ("can not update cached figure value",
|
||||||
"REPLACE INTO figures"
|
"REPLACE INTO fig_figures"
|
||||||
" (Figure,Scope,Cod,ValueInt,ValueDouble)"
|
" (Figure,Scope,Cod,ValueInt,ValueDouble)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%u,'%s',%ld,0,'%.15lg')",
|
" (%u,'%s',%ld,0,'%.15lg')",
|
||||||
|
@ -137,10 +137,12 @@ bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure,
|
||||||
|
|
||||||
/***** Get figure's value if cached and recent *****/
|
/***** Get figure's value if cached and recent *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get cached figure value",
|
if (DB_QuerySELECT (&mysql_res,"can not get cached figure value",
|
||||||
"SELECT %s"
|
"SELECT %s" // row[0]
|
||||||
" FROM figures"
|
" FROM fig_figures"
|
||||||
" WHERE Figure=%u AND Scope='%s' AND Cod=%ld"
|
" WHERE Figure=%u"
|
||||||
" AND LastUpdate>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
" AND Scope='%s'"
|
||||||
|
" AND Cod=%ld"
|
||||||
|
" AND LastUpdate>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||||
Field[Type],
|
Field[Type],
|
||||||
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,
|
(unsigned) Figure,Sco_GetDBStrFromScope (Scope),Cod,
|
||||||
TimeCached[Scope]))
|
TimeCached[Scope]))
|
||||||
|
|
|
@ -830,7 +830,8 @@ void Prf_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures)
|
||||||
"NumFileViews," // row[4]
|
"NumFileViews," // row[4]
|
||||||
"NumForPst," // row[5]
|
"NumForPst," // row[5]
|
||||||
"NumMsgSnt" // row[6]
|
"NumMsgSnt" // row[6]
|
||||||
" FROM usr_figures WHERE UsrCod=%ld",
|
" FROM usr_figures"
|
||||||
|
" WHERE UsrCod=%ld",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
if (NumRows)
|
if (NumRows)
|
||||||
{
|
{
|
||||||
|
@ -1074,9 +1075,10 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
|
||||||
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
||||||
DB_QueryUPDATE ("can not update user's figures",
|
DB_QueryUPDATE ("can not update user's figures",
|
||||||
"UPDATE usr_figures"
|
"UPDATE usr_figures"
|
||||||
" SET FirstClickTime=FROM_UNIXTIME(%ld)"
|
" SET FirstClickTime=FROM_UNIXTIME(%ld)"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
(long) UsrFigures.FirstClickTimeUTC,UsrCod);
|
(long) UsrFigures.FirstClickTimeUTC,
|
||||||
|
UsrCod);
|
||||||
else // User entry does not exist
|
else // User entry does not exist
|
||||||
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
||||||
}
|
}
|
||||||
|
@ -1105,9 +1107,11 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
|
||||||
/***** Update number of clicks in user's figures *****/
|
/***** Update number of clicks in user's figures *****/
|
||||||
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
||||||
DB_QueryUPDATE ("can not update user's figures",
|
DB_QueryUPDATE ("can not update user's figures",
|
||||||
"UPDATE usr_figures SET NumClicks=%ld"
|
"UPDATE usr_figures"
|
||||||
|
" SET NumClicks=%ld"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrFigures.NumClicks,UsrCod);
|
UsrFigures.NumClicks,
|
||||||
|
UsrCod);
|
||||||
else // User entry does not exist
|
else // User entry does not exist
|
||||||
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
||||||
}
|
}
|
||||||
|
@ -1132,9 +1136,11 @@ static void Prf_GetNumSocialPubsAndStoreAsUsrFigure (long UsrCod)
|
||||||
/***** Update number of forum posts in user's figures *****/
|
/***** Update number of forum posts in user's figures *****/
|
||||||
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
||||||
DB_QueryUPDATE ("can not update user's figures",
|
DB_QueryUPDATE ("can not update user's figures",
|
||||||
"UPDATE usr_figures SET NumSocPub=%ld"
|
"UPDATE usr_figures"
|
||||||
|
" SET NumSocPub=%ld"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrFigures.NumSocPub,UsrCod);
|
UsrFigures.NumSocPub,
|
||||||
|
UsrCod);
|
||||||
else // User entry does not exist
|
else // User entry does not exist
|
||||||
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
||||||
}
|
}
|
||||||
|
@ -1186,9 +1192,11 @@ static void Prf_GetNumForumPostsAndStoreAsUsrFigure (long UsrCod)
|
||||||
/***** Update number of forum posts in user's figures *****/
|
/***** Update number of forum posts in user's figures *****/
|
||||||
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
||||||
DB_QueryUPDATE ("can not update user's figures",
|
DB_QueryUPDATE ("can not update user's figures",
|
||||||
"UPDATE usr_figures SET NumForPst=%ld"
|
"UPDATE usr_figures"
|
||||||
|
" SET NumForPst=%ld"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrFigures.NumForPst,UsrCod);
|
UsrFigures.NumForPst,
|
||||||
|
UsrCod);
|
||||||
else // User entry does not exist
|
else // User entry does not exist
|
||||||
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
||||||
}
|
}
|
||||||
|
@ -1213,9 +1221,11 @@ static void Prf_GetNumMessagesSentAndStoreAsUsrFigure (long UsrCod)
|
||||||
/***** Update number of messages sent in user's figures *****/
|
/***** Update number of messages sent in user's figures *****/
|
||||||
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
if (Prf_CheckIfUsrFiguresExists (UsrCod))
|
||||||
DB_QueryUPDATE ("can not update user's figures",
|
DB_QueryUPDATE ("can not update user's figures",
|
||||||
"UPDATE usr_figures SET NumMsgSnt=%ld"
|
"UPDATE usr_figures"
|
||||||
|
" SET NumMsgSnt=%ld"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrFigures.NumMsgSnt,UsrCod);
|
UsrFigures.NumMsgSnt,
|
||||||
|
UsrCod);
|
||||||
else // User entry does not exist
|
else // User entry does not exist
|
||||||
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1307,8 @@ void Prf_RemoveUsrFigures (long UsrCod)
|
||||||
{
|
{
|
||||||
/***** Remove user's figures *****/
|
/***** Remove user's figures *****/
|
||||||
DB_QueryDELETE ("can not delete user's figures",
|
DB_QueryDELETE ("can not delete user's figures",
|
||||||
"DELETE FROM usr_figures WHERE UsrCod=%ld",
|
"DELETE FROM usr_figures"
|
||||||
|
" WHERE UsrCod=%ld",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1308,7 +1319,8 @@ void Prf_RemoveUsrFigures (long UsrCod)
|
||||||
static bool Prf_CheckIfUsrFiguresExists (long UsrCod)
|
static bool Prf_CheckIfUsrFiguresExists (long UsrCod)
|
||||||
{
|
{
|
||||||
return (DB_QueryCOUNT ("can not get user's first click",
|
return (DB_QueryCOUNT ("can not get user's first click",
|
||||||
"SELECT COUNT(*) FROM usr_figures"
|
"SELECT COUNT(*)"
|
||||||
|
" FROM usr_figures"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrCod) != 0);
|
UsrCod) != 0);
|
||||||
}
|
}
|
||||||
|
@ -1322,8 +1334,10 @@ void Prf_IncrementNumClicksUsr (long UsrCod)
|
||||||
/***** Increment number of clicks *****/
|
/***** Increment number of clicks *****/
|
||||||
// If NumClicks < 0 ==> not yet calculated, so do nothing
|
// If NumClicks < 0 ==> not yet calculated, so do nothing
|
||||||
DB_QueryINSERT ("can not increment user's clicks",
|
DB_QueryINSERT ("can not increment user's clicks",
|
||||||
"UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
|
"UPDATE IGNORE usr_figures"
|
||||||
" WHERE UsrCod=%ld AND NumClicks>=0",
|
" SET NumClicks=NumClicks+1"
|
||||||
|
" WHERE UsrCod=%ld"
|
||||||
|
" AND NumClicks>=0",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue