Version 14.98.3

This commit is contained in:
Antonio Cañas Vargas 2015-03-19 19:10:43 +01:00
parent 72c369010e
commit 08438a8d06
4 changed files with 42 additions and 9 deletions

View File

@ -103,11 +103,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 14.98.2 (2015/03/19)"
#define Log_PLATFORM_VERSION "SWAD 14.98.3 (2015/03/19)"
// 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.98.3: Mar 19, 2015 Changes in user's profile to speedup page generation. (183397 lines)
Version 14.98.2: Mar 19, 2015 Fixed bug in record related to follow/unfollow. (183366 lines)
Version 14.98.1: Mar 19, 2015 Changes in lists of following and followers. (183360 lines)
Version 14.98: Mar 19, 2015 Show lists of following and followers. (183300 lines)

View File

@ -323,10 +323,18 @@ static void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
unsigned NumTchs;
unsigned NumFiles;
unsigned NumPublicFiles;
// char StrTimeGenerationInMicroseconds[64];
/***** Start table *****/
fprintf (Gbl.F.Out,"<table class=\"TABLE10 CELLS_PAD_2\">");
/*
if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM)
{
Sta_ComputeTimeToGeneratePage ();
Sta_WriteTime (StrTimeGenerationInMicroseconds,Gbl.TimeGenerationInMicroseconds);
fprintf (Gbl.F.Out,"<tr><td>%s</td></tr>",StrTimeGenerationInMicroseconds);
}
*/
/***** Number of courses in which the user is teacher or student *****/
if ((NumCrssUsrIsTeacher = Usr_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Rol_ROLE_TEACHER)))
{

View File

@ -744,17 +744,40 @@ unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role)
/******* Get number of users with different role in courses of a user ********/
/*****************************************************************************/
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,Rol_Role_t OthersRole)
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
Rol_Role_t OthersRole)
{
char Query[256];
// This query can be made in a unique, but slower, query
// The temporary table achieves speedup from ~2s to few ms
/***** Remove temporary table if exists *****/
sprintf (Query,"DROP TABLE IF EXISTS my_courses_tmp");
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary tables");
/***** Create temporary table with all my courses for a role *****/
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS my_courses_tmp"
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
" ENGINE=MEMORY"
" SELECT CrsCod FROM crs_usr"
" WHERE UsrCod='%ld' AND Role='%u'",
UsrCod,(unsigned) UsrRole);
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not create temporary table");
/***** Get the number of teachers in a course from database ******/
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
" WHERE CrsCod IN"
" (SELECT CrsCod FROM crs_usr WHERE UsrCod='%ld' AND Role='%u')"
" AND Role='%u'",
UsrCod,(unsigned) UsrRole,(unsigned) OthersRole);
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
" FROM crs_usr,my_courses_tmp"
" WHERE crs_usr.CrsCod=my_courses_tmp.CrsCod"
" AND crs_usr.Role='%u'",
(unsigned) OthersRole);
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users");
/***** Remove temporary table *****/
sprintf (Query,"DROP TABLE IF EXISTS my_courses_tmp");
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary tables");
}
/*****************************************************************************/

View File

@ -211,7 +211,8 @@ void Usr_RestrictLengthAndWriteName (const struct UsrData *UsrDat,unsigned MaxCh
bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod);
bool Usr_CheckIfUsrIsSuperuser (long UsrCod);
unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role);
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,Rol_Role_t OthersRole);
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
Rol_Role_t OthersRole);
bool Usr_CheckIfUsrSharesAnyOfMyCrs (long UsrCod);
bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod);
void Usr_GetMyInstitutions (void);