mirror of https://github.com/acanas/swad-core.git
Version 14.87.4
This commit is contained in:
parent
209092b420
commit
afcc374ecd
|
@ -10516,4 +10516,7 @@ CREATE TABLE IF NOT EXISTS usr_figures (UsrCod INT NOT NULL,FirstClickTime DATET
|
|||
|
||||
|
||||
|
||||
SELECT * FROM usr_figures WHERE NumClicks>='0' AND FirstClickTime>'0';
|
||||
|
||||
SELECT COUNT(*)+1 FROM (SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1) AS NumClicksPerDay FROM usr_figures WHERE NumClicks>='0' AND UNIX_TIMESTAMP(FirstClickTime)>'0') AS TableNumClicksPerDay WHERE NumClicksPerDay>(SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1) FROM usr_figures WHERE UsrCod='1' AND NumClicks>='0' AND UNIX_TIMESTAMP(FirstClickTime)>'0');
|
||||
|
||||
|
|
|
@ -1178,7 +1178,9 @@ CREATE TABLE IF NOT EXISTS usr_figures (
|
|||
NumClicks INT NOT NULL DEFAULT -1,
|
||||
NumForPst INT NOT NULL DEFAULT -1,
|
||||
NumMsgSnt INT NOT NULL DEFAULT -1,
|
||||
PRIMARY KEY(UsrCod));
|
||||
PRIMARY KEY(UsrCod),
|
||||
INDEX(FirstClickTime),
|
||||
INDEX(NumClicks));
|
||||
--
|
||||
-- Table usr_last: stores some variable data related to users
|
||||
--
|
||||
|
|
|
@ -103,11 +103,18 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.87.1 (2015/03/11)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.87.4 (2015/03/11)"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||
/*
|
||||
Version 14.87.4: Mar 11, 2015 Added indexes to usr_figures. (181629 lines)
|
||||
2 changes necessary in database:
|
||||
CREATE INDEX FirstClickTime ON usr_figures (FirstClickTime);
|
||||
CREATE INDEX NumClicks ON usr_figures (NumClicks);
|
||||
|
||||
Version 14.87.3: Mar 11, 2015 Fix bug comparing first click dates in user's figures. (181623 lines)
|
||||
Version 14.87.2: Mar 11, 2015 Fix bug comparing first click dates in user's figures. (181614 lines)
|
||||
Version 14.87.1: Mar 11, 2015 Fix style in CSS and record. (181613 lines)
|
||||
Version 14.87: Mar 11, 2015 Ranking according to the number of clicks. (181611 lines)
|
||||
Version 14.86: Mar 11, 2015 Show user's figures per days. (181525 lines)
|
||||
|
|
|
@ -2344,8 +2344,8 @@ mysql> DESCRIBE usr_figures;
|
|||
| Field | Type | Null | Key | Default | Extra |
|
||||
+----------------+----------+------+-----+---------+-------+
|
||||
| UsrCod | int(11) | NO | PRI | NULL | |
|
||||
| FirstClickTime | datetime | NO | | NULL | |
|
||||
| NumClicks | int(11) | NO | | -1 | |
|
||||
| FirstClickTime | datetime | NO | MUL | NULL | |
|
||||
| NumClicks | int(11) | NO | MUL | -1 | |
|
||||
| NumForPst | int(11) | NO | | -1 | |
|
||||
| NumMsgSnt | int(11) | NO | | -1 | |
|
||||
+----------------+----------+------+-----+---------+-------+
|
||||
|
@ -2357,7 +2357,7 @@ mysql> DESCRIBE usr_figures;
|
|||
"NumClicks INT NOT NULL DEFAULT -1,"
|
||||
"NumForPst INT NOT NULL DEFAULT -1,"
|
||||
"NumMsgSnt INT NOT NULL DEFAULT -1,"
|
||||
"PRIMARY KEY(UsrCod))");
|
||||
"PRIMARY KEY(UsrCod),INDEX(FirstClickTime),INDEX(NumClicks))");
|
||||
|
||||
/***** Table usr_IDs *****/
|
||||
/*
|
||||
|
|
20
swad_user.c
20
swad_user.c
|
@ -7883,10 +7883,13 @@ static unsigned long Usr_GetRankingNumClicks (long UsrCod)
|
|||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Select number of rows with number of clicks
|
||||
greater than the clicks of this user *****/
|
||||
sprintf (Query,"SELECT COUNT(*)+1 FROM usr_figures"
|
||||
" WHERE NumClicks>"
|
||||
" WHERE UsrCod<>'%ld'" // Really not necessary here
|
||||
" AND NumClicks>"
|
||||
"(SELECT NumClicks FROM usr_figures WHERE UsrCod='%ld')",
|
||||
UsrCod);
|
||||
UsrCod,UsrCod);
|
||||
return DB_QueryCOUNT (Query,"can not get ranking using number of clicks");
|
||||
}
|
||||
|
||||
|
@ -7898,6 +7901,7 @@ static unsigned long Usr_GetNumUsrsWithNumClicks (void)
|
|||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Select number of rows with values already calculated *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_figures WHERE NumClicks>='0'");
|
||||
return DB_QueryCOUNT (Query,"can not get number of users with number of clicks");
|
||||
}
|
||||
|
@ -7910,18 +7914,21 @@ static unsigned long Usr_GetRankingNumClicksPerDay (long UsrCod)
|
|||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Select number of rows with number of clicks per day
|
||||
greater than the clicks per day of this user *****/
|
||||
sprintf (Query,"SELECT COUNT(*)+1 FROM"
|
||||
" (SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1)"
|
||||
" AS NumClicksPerDay"
|
||||
" FROM usr_figures"
|
||||
" WHERE NumClicks>='0' AND FirstClickTime>'0')"
|
||||
" WHERE UsrCod<>'%ld'" // Necessary because the following comparison is not exact in floating point
|
||||
" AND NumClicks>='0' AND UNIX_TIMESTAMP(FirstClickTime)>'0')"
|
||||
" AS TableNumClicksPerDay"
|
||||
" WHERE NumClicksPerDay>"
|
||||
"(SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1)"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod='%ld'"
|
||||
" AND NumClicks>='0' AND FirstClickTime>'0');",
|
||||
UsrCod);
|
||||
" AND NumClicks>='0' AND UNIX_TIMESTAMP(FirstClickTime)>'0')",
|
||||
UsrCod,UsrCod);
|
||||
return DB_QueryCOUNT (Query,"can not get ranking using number of clicks per day");
|
||||
}
|
||||
|
||||
|
@ -7933,8 +7940,9 @@ static unsigned long Usr_GetNumUsrsWithNumClicksPerDay (void)
|
|||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Select number of rows with values already calculated *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_figures"
|
||||
" WHERE NumClicks>='0' AND FirstClickTime>'0'");
|
||||
" WHERE NumClicks>='0' AND UNIX_TIMESTAMP(FirstClickTime)>'0'");
|
||||
return DB_QueryCOUNT (Query,"can not get number of users with number of clicks per day");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue