Version 15.110.9

This commit is contained in:
Antonio Cañas Vargas 2016-01-12 23:35:04 +01:00
parent 55e8dcc212
commit ffe7bb906a
2 changed files with 75 additions and 43 deletions

View File

@ -122,13 +122,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.110.8 (2016-01-12)" #define Log_PLATFORM_VERSION "SWAD 15.110.9 (2016-01-12)"
#define CSS_FILE "swad15.110.2.css" #define CSS_FILE "swad15.110.2.css"
#define JS_FILE "swad15.107.2.js" #define JS_FILE "swad15.107.2.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.110.9: Jan 12, 2016 Do not get social notes already present in timeline. (192388 lines)
Version 15.110.8: Jan 12, 2016 Insert social notes in current social timeline in database. Version 15.110.8: Jan 12, 2016 Insert social notes in current social timeline in database.
Show old social notes only if they are not already shown in timeline. (192354 lines) Show old social notes only if they are not already shown in timeline. (192354 lines)
Version 15.110.7: Jan 12, 2016 Remove unused old social timelines in database. (192320 lines) Version 15.110.7: Jan 12, 2016 Remove unused old social timelines in database. (192320 lines)

View File

@ -54,11 +54,11 @@
#define Soc_MAX_BYTES_SUMMARY 100 #define Soc_MAX_BYTES_SUMMARY 100
// Number of recent publishings got and shown the first time, before refreshing // Number of recent publishings got and shown the first time, before refreshing
#define Soc_MAX_RECENT_PUBS_TO_SHOW 10 // Publishings to show #define Soc_MAX_RECENT_PUBS_TO_SHOW 20 // Publishings to show
// #define Soc_MAX_RECENT_PUBS_TO_GET (Soc_MAX_RECENT_PUBS_TO_SHOW+1) // Publishings to get // #define Soc_MAX_RECENT_PUBS_TO_GET (Soc_MAX_RECENT_PUBS_TO_SHOW+1) // Publishings to get
// Number of old publishings got and shown when I want to see old publishings // Number of old publishings got and shown when I want to see old publishings
#define Soc_MAX_OLD_PUBS_TO_GET_AND_SHOW 10 // If you change this number, set also this constant to the new value in JavaScript #define Soc_MAX_OLD_PUBS_TO_GET_AND_SHOW 20 // If you change this number, set also this constant to the new value in JavaScript
#define Soc_MAX_LENGTH_ID (256+Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+10+1) #define Soc_MAX_LENGTH_ID (256+Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+10+1)
@ -370,35 +370,9 @@ static void Soc_BuildQueryToGetTimelineGbl (Soc_WhatToGetFromTimeline_t WhatToGe
char *Query) char *Query)
{ {
char SubQueryRangePubs[64]; char SubQueryRangePubs[64];
char SubQueryLimit[64];
long LastPubCod; long LastPubCod;
long FirstPubCod; long FirstPubCod;
/****** Build subqueries *****/
SubQueryRangePubs[0] = '\0';
SubQueryLimit[0] = '\0';
switch (WhatToGetFromTimeline)
{
case Soc_GET_RECENT_TIMELINE:
// Get some limited recent publihings
sprintf (SubQueryLimit," LIMIT %u",Soc_MAX_RECENT_PUBS_TO_SHOW);
break;
case Soc_GET_ONLY_NEW_PUBS:
// Get the publishings (without limit) newer than LastPubCod
LastPubCod = Soc_GetPubCodFromSession ("LastPubCod");
if (LastPubCod > 0)
sprintf (SubQueryRangePubs,"PubCod>'%ld' AND ",LastPubCod);
break;
case Soc_GET_ONLY_OLD_PUBS:
// Get some limited publishings older than FirstPubCod
FirstPubCod = Soc_GetPubCodFromSession ("FirstPubCod");
if (FirstPubCod > 0)
sprintf (SubQueryRangePubs,"PubCod<'%ld' AND ",FirstPubCod);
sprintf (SubQueryLimit," LIMIT %u",Soc_MAX_OLD_PUBS_TO_GET_AND_SHOW);
break;
}
/***** Remove temporary table with publishing codes *****/ /***** Remove temporary table with publishing codes *****/
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS pub_cods"); sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS pub_cods");
if (mysql_query (&Gbl.mysql,Query)) if (mysql_query (&Gbl.mysql,Query))
@ -407,8 +381,38 @@ static void Soc_BuildQueryToGetTimelineGbl (Soc_WhatToGetFromTimeline_t WhatToGe
/***** Create temporary table with publishing codes *****/ /***** Create temporary table with publishing codes *****/
// Get the maximum PubCod -more recent publishing (original, shared or commment)- // Get the maximum PubCod -more recent publishing (original, shared or commment)-
// of every set of publishings corresponding to the same note // of every set of publishings corresponding to the same note
sprintf (Query,"CREATE TEMPORARY TABLE pub_cods" switch (WhatToGetFromTimeline)
" (NewestPubForNote BIGINT NOT NULL,UNIQUE INDEX(NewestPubForNote)) ENGINE=MEMORY" {
case Soc_GET_RECENT_TIMELINE:
// Get some limited recent publishings
sprintf (Query,"CREATE TEMPORARY TABLE pub_cods "
"(NewestPubForNote BIGINT NOT NULL,"
"UNIQUE INDEX(NewestPubForNote)) ENGINE=MEMORY"
" SELECT MAX(PubCod) AS NewestPubForNote"
" FROM social_pubs"
" WHERE PublisherCod IN"
" (SELECT '%ld'"
" UNION"
" SELECT FollowedCod FROM usr_follow WHERE FollowerCod='%ld')"
" AND NotCod NOT IN"
" (SELECT NotCod FROM social_timelines WHERE SessionId='%s')"
" GROUP BY NotCod"
" ORDER BY NewestPubForNote DESC LIMIT %u",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Session.Id,
Soc_MAX_RECENT_PUBS_TO_SHOW);
break;
case Soc_GET_ONLY_NEW_PUBS:
// Get the publishings (without limit) newer than LastPubCod
LastPubCod = Soc_GetPubCodFromSession ("LastPubCod");
if (LastPubCod > 0)
sprintf (SubQueryRangePubs,"PubCod>'%ld' AND ",LastPubCod);
else
SubQueryRangePubs[0] = '\0';
sprintf (Query,"CREATE TEMPORARY TABLE pub_cods "
"(NewestPubForNote BIGINT NOT NULL,"
"UNIQUE INDEX(NewestPubForNote)) ENGINE=MEMORY"
" SELECT MAX(PubCod) AS NewestPubForNote" " SELECT MAX(PubCod) AS NewestPubForNote"
" FROM social_pubs" " FROM social_pubs"
" WHERE %sPublisherCod IN" " WHERE %sPublisherCod IN"
@ -416,11 +420,38 @@ static void Soc_BuildQueryToGetTimelineGbl (Soc_WhatToGetFromTimeline_t WhatToGe
" UNION" " UNION"
" SELECT FollowedCod FROM usr_follow WHERE FollowerCod='%ld')" " SELECT FollowedCod FROM usr_follow WHERE FollowerCod='%ld')"
" GROUP BY NotCod" " GROUP BY NotCod"
" ORDER BY NewestPubForNote DESC%s", " ORDER BY NewestPubForNote DESC",
SubQueryRangePubs,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
break;
case Soc_GET_ONLY_OLD_PUBS:
// Get some limited publishings older than FirstPubCod
FirstPubCod = Soc_GetPubCodFromSession ("FirstPubCod");
if (FirstPubCod > 0)
sprintf (SubQueryRangePubs,"PubCod<'%ld' AND ",FirstPubCod);
else
SubQueryRangePubs[0] = '\0';
sprintf (Query,"CREATE TEMPORARY TABLE pub_cods "
"(NewestPubForNote BIGINT NOT NULL,"
"UNIQUE INDEX(NewestPubForNote)) ENGINE=MEMORY"
" SELECT MAX(PubCod) AS NewestPubForNote"
" FROM social_pubs"
" WHERE %sPublisherCod IN"
" (SELECT '%ld'"
" UNION"
" SELECT FollowedCod FROM usr_follow WHERE FollowerCod='%ld')"
" AND NotCod NOT IN"
" (SELECT NotCod FROM social_timelines WHERE SessionId='%s')"
" GROUP BY NotCod"
" ORDER BY NewestPubForNote DESC LIMIT %u",
SubQueryRangePubs, SubQueryRangePubs,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
SubQueryLimit); Gbl.Session.Id,
Soc_MAX_OLD_PUBS_TO_GET_AND_SHOW);
break;
}
if (mysql_query (&Gbl.mysql,Query)) if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not create temporary table"); DB_ExitOnMySQLError ("can not create temporary table");