diff --git a/swad_changelog.h b/swad_changelog.h index c39a46c1e..368bb92a6 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -121,19 +121,20 @@ // TODO: Limit text of post/comment in social timeline to 1000 characters? Limit textarea to 20 lines not resizeable. // TODO: Sinchronize timeline in other actions // TODO: Optimize Javascript not concatenating big strings in new timeline -// TODO: FIX BUG: Timeline is not shown on user's profile /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.110.17 (2016-01-13)" +#define Log_PLATFORM_VERSION "SWAD 15.110.18 (2016-01-13)" #define CSS_FILE "swad15.110.13.css" #define JS_FILE "swad15.110.13.js" // 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 15.110.19:Jan 13, 2016 Fixed bug in user's timeline. (? lines) + Version 15.110.18:Jan 13, 2016 Optimization in query to get initial recent timeline. (192564 lines) Version 15.110.17:Jan 13, 2016 Reviewed code related to Soc_MAX_RECENT_PUBS_TO_GET. (192568 lines) Version 15.110.16:Jan 13, 2016 Form to go to public profile of author of comment in timeline. (192563 lines) Version 15.110.15:Jan 13, 2016 Form to go to public profile of author of note in timeline. diff --git a/swad_social.c b/swad_social.c index 469b7523b..f74297bec 100644 --- a/swad_social.c +++ b/swad_social.c @@ -297,7 +297,7 @@ void Soc_ShowTimelineUsr (void) extern const char *Txt_Public_activity_OF_A_USER; char Query[512]; - /***** Build query to show timeline with publishing of a unique user *****/ + /***** Build query to show timeline with publishings of a unique user *****/ sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,PubType,UNIX_TIMESTAMP(TimePublish)" " FROM social_pubs" " WHERE PublisherCod='%ld'" @@ -403,21 +403,15 @@ static void Soc_BuildQueryToGetTimelineGbl (Soc_WhatToGetFromTimeline_t WhatToGe DB_ExitOnMySQLError ("can not create temporary table"); /***** Create temporary table with notes already present in current timeline *****/ - switch (WhatToGetFromTimeline) + if (WhatToGetFromTimeline == Soc_GET_ONLY_OLD_PUBS) { - case Soc_GET_ONLY_OLD_PUBS: - case Soc_GET_RECENT_TIMELINE: - sprintf (Query,"CREATE TEMPORARY TABLE current_timeline " - "(NotCod BIGINT NOT NULL," - "UNIQUE INDEX(NotCod)) ENGINE=MEMORY" - " SELECT NotCod FROM social_timelines WHERE SessionId='%s'", - Gbl.Session.Id); - if (mysql_query (&Gbl.mysql,Query)) - DB_ExitOnMySQLError ("can not create temporary table"); - break; - case Soc_GET_ONLY_NEW_PUBS: - // Get publishings even if they are already present in current timeline - break; + sprintf (Query,"CREATE TEMPORARY TABLE current_timeline " + "(NotCod BIGINT NOT NULL," + "UNIQUE INDEX(NotCod)) ENGINE=MEMORY" + " SELECT NotCod FROM social_timelines WHERE SessionId='%s'", + Gbl.Session.Id); + if (mysql_query (&Gbl.mysql,Query)) + DB_ExitOnMySQLError ("can not create temporary table"); } /***** Create temporary table with publishing codes *****/ @@ -425,21 +419,21 @@ static void Soc_BuildQueryToGetTimelineGbl (Soc_WhatToGetFromTimeline_t WhatToGe // of every set of publishings corresponding to the same note switch (WhatToGetFromTimeline) { - case Soc_GET_RECENT_TIMELINE: - // Get some limited recent publishings + case Soc_GET_RECENT_TIMELINE: // Get some limited recent publishings + /* This is the first query to get initial timeline shown + ==> no notes yet in current timeline table */ 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 UsrCod FROM publishers)" - " AND NotCod NOT IN (SELECT NotCod FROM current_timeline)" " GROUP BY NotCod" " ORDER BY NewestPubForNote DESC LIMIT %u", Soc_MAX_RECENT_PUBS_TO_GET); break; - case Soc_GET_ONLY_NEW_PUBS: - // Get the publishings (without limit) newer than LastPubCod + case Soc_GET_ONLY_NEW_PUBS: // Get the publishings (without limit) newer than LastPubCod + /* This query is made via AJAX automatically from time to time */ LastPubCod = Soc_GetPubCodFromSession ("LastPubCod"); if (LastPubCod > 0) sprintf (SubQueryRangePubs,"PubCod>'%ld' AND ",LastPubCod); @@ -455,8 +449,9 @@ static void Soc_BuildQueryToGetTimelineGbl (Soc_WhatToGetFromTimeline_t WhatToGe " ORDER BY NewestPubForNote DESC", SubQueryRangePubs); break; - case Soc_GET_ONLY_OLD_PUBS: - // Get some limited publishings older than FirstPubCod + case Soc_GET_ONLY_OLD_PUBS: // Get some limited publishings older than FirstPubCod + /* This query is made via AJAX + when I click in link to get old publishings */ FirstPubCod = Soc_GetPubCodFromSession ("FirstPubCod"); if (FirstPubCod > 0) sprintf (SubQueryRangePubs,"PubCod<'%ld' AND ",FirstPubCod);