mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-16 13:44:06 +02:00
Version 15.115.2
This commit is contained in:
parent
9d8c09c32a
commit
8ae6904a57
|
@ -122,13 +122,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.115.1 (2016-01-17)"
|
#define Log_PLATFORM_VERSION "SWAD 15.115.2 (2016-01-17)"
|
||||||
#define CSS_FILE "swad15.115.css"
|
#define CSS_FILE "swad15.115.css"
|
||||||
#define JS_FILE "swad15.115.js"
|
#define JS_FILE "swad15.115.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.115.2: Jan 17, 2016 Code refactoring in timeline. (192860 lines)
|
||||||
Version 15.115.1: Jan 17, 2016 Code refactoring in timeline. (192857 lines)
|
Version 15.115.1: Jan 17, 2016 Code refactoring in timeline. (192857 lines)
|
||||||
Version 15.115: Jan 17, 2016 Code refactoring in actions. (192823 lines)
|
Version 15.115: Jan 17, 2016 Code refactoring in actions. (192823 lines)
|
||||||
2 changes necessary in database:
|
2 changes necessary in database:
|
||||||
|
|
124
swad_social.c
124
swad_social.c
|
@ -484,6 +484,60 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl
|
||||||
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");
|
||||||
|
|
||||||
|
|
||||||
|
/***** Create subquery with range of publishings to get from social_pubs *****/
|
||||||
|
switch (WhatToGetFromTimeline)
|
||||||
|
{
|
||||||
|
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 */
|
||||||
|
MaxPubsToGet = Soc_MAX_NEW_PUBS_TO_GET_AND_SHOW;
|
||||||
|
|
||||||
|
LastPubCod = Soc_GetPubCodFromSession ("LastPubCod");
|
||||||
|
if (LastPubCod > 0)
|
||||||
|
switch (TimelineUsrOrGbl)
|
||||||
|
{
|
||||||
|
case Soc_TIMELINE_USR: // Show the timeline of a user
|
||||||
|
sprintf (SubQueryRangePubs,"PubCod>'%ld' AND ",
|
||||||
|
LastPubCod);
|
||||||
|
break;
|
||||||
|
case Soc_TIMELINE_GBL: // Show the timeline of the users I follow
|
||||||
|
sprintf (SubQueryRangePubs,"social_pubs.PubCod>'%ld' AND ",
|
||||||
|
LastPubCod);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SubQueryRangePubs[0] = '\0';
|
||||||
|
break;
|
||||||
|
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 */
|
||||||
|
MaxPubsToGet = Soc_MAX_REC_PUBS_TO_GET_AND_SHOW;
|
||||||
|
|
||||||
|
SubQueryRangePubs[0] = '\0';
|
||||||
|
break;
|
||||||
|
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 */
|
||||||
|
MaxPubsToGet = Soc_MAX_OLD_PUBS_TO_GET_AND_SHOW;
|
||||||
|
|
||||||
|
FirstPubCod = Soc_GetPubCodFromSession ("FirstPubCod");
|
||||||
|
if (FirstPubCod > 0)
|
||||||
|
switch (TimelineUsrOrGbl)
|
||||||
|
{
|
||||||
|
case Soc_TIMELINE_USR: // Show the timeline of a user
|
||||||
|
sprintf (SubQueryRangePubs,"PubCod<'%ld' AND ",
|
||||||
|
FirstPubCod);
|
||||||
|
break;
|
||||||
|
case Soc_TIMELINE_GBL: // Show the timeline of the users I follow
|
||||||
|
sprintf (SubQueryRangePubs,"social_pubs.PubCod<'%ld' AND ",
|
||||||
|
FirstPubCod);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SubQueryRangePubs[0] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/***** Create temporary table and subquery with potential publishers *****/
|
/***** Create temporary table and subquery with potential publishers *****/
|
||||||
switch (TimelineUsrOrGbl)
|
switch (TimelineUsrOrGbl)
|
||||||
{
|
{
|
||||||
|
@ -539,69 +593,18 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Create temporary table with publishing codes *****/
|
/***** Get the publishings in timeline *****/
|
||||||
// Get the maximum PubCod -more recent publishing (original, shared or commment)-
|
|
||||||
// of every set of publishings corresponding to the same note
|
|
||||||
switch (WhatToGetFromTimeline)
|
|
||||||
{
|
|
||||||
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 */
|
|
||||||
MaxPubsToGet = Soc_MAX_NEW_PUBS_TO_GET_AND_SHOW;
|
|
||||||
|
|
||||||
LastPubCod = Soc_GetPubCodFromSession ("LastPubCod");
|
|
||||||
if (LastPubCod > 0)
|
|
||||||
switch (TimelineUsrOrGbl)
|
|
||||||
{
|
|
||||||
case Soc_TIMELINE_USR: // Show the timeline of a user
|
|
||||||
sprintf (SubQueryRangePubs,"PubCod>'%ld' AND ",
|
|
||||||
LastPubCod);
|
|
||||||
break;
|
|
||||||
case Soc_TIMELINE_GBL: // Show the timeline of the users I follow
|
|
||||||
sprintf (SubQueryRangePubs,"social_pubs.PubCod>'%ld' AND ",
|
|
||||||
LastPubCod);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SubQueryRangePubs[0] = '\0';
|
|
||||||
break;
|
|
||||||
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 */
|
|
||||||
MaxPubsToGet = Soc_MAX_REC_PUBS_TO_GET_AND_SHOW;
|
|
||||||
|
|
||||||
SubQueryRangePubs[0] = '\0';
|
|
||||||
break;
|
|
||||||
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 */
|
|
||||||
MaxPubsToGet = Soc_MAX_OLD_PUBS_TO_GET_AND_SHOW;
|
|
||||||
|
|
||||||
FirstPubCod = Soc_GetPubCodFromSession ("FirstPubCod");
|
|
||||||
if (FirstPubCod > 0)
|
|
||||||
switch (TimelineUsrOrGbl)
|
|
||||||
{
|
|
||||||
case Soc_TIMELINE_USR: // Show the timeline of a user
|
|
||||||
sprintf (SubQueryRangePubs,"PubCod<'%ld' AND ",
|
|
||||||
FirstPubCod);
|
|
||||||
break;
|
|
||||||
case Soc_TIMELINE_GBL: // Show the timeline of the users I follow
|
|
||||||
sprintf (SubQueryRangePubs,"social_pubs.PubCod<'%ld' AND ",
|
|
||||||
FirstPubCod);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SubQueryRangePubs[0] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
As an alternative, we tried
|
With the current approach, we select one by one
|
||||||
|
the publishings and notes in a loop. In each iteration,
|
||||||
|
we get the more recent note that is not already retrieved.
|
||||||
|
|
||||||
|
As an alternative, we tried to get the maximum PubCod,
|
||||||
|
i.e more recent publishing (original, shared or commment),
|
||||||
|
of every set of publishings corresponding to the same note:
|
||||||
"SELECT MAX(PubCod) AS NewestPubCod FROM social_pubs ...
|
"SELECT MAX(PubCod) AS NewestPubCod FROM social_pubs ...
|
||||||
" GROUP BY NotCod ORDER BY NewestPubCod DESC LIMIT ..."
|
" GROUP BY NotCod ORDER BY NewestPubCod DESC LIMIT ..."
|
||||||
but it's slow (several seconds) with a big table.
|
but this query is slow (several seconds) with a big table.
|
||||||
|
|
||||||
With the current approach, we select one by one the notes in a loop.
|
|
||||||
In each iteration, we get the more recent note that is not already retrieved.
|
|
||||||
*/
|
*/
|
||||||
for (NumPub = 0;
|
for (NumPub = 0;
|
||||||
NumPub < MaxPubsToGet;
|
NumPub < MaxPubsToGet;
|
||||||
|
@ -635,7 +638,6 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl
|
||||||
sprintf (Query,"INSERT INTO pub_codes SET PubCod='%ld'",PubCod);
|
sprintf (Query,"INSERT INTO pub_codes SET PubCod='%ld'",PubCod);
|
||||||
DB_QueryINSERT (Query,"can not store publishing code");
|
DB_QueryINSERT (Query,"can not store publishing code");
|
||||||
|
|
||||||
|
|
||||||
/* Get social note code (row[1]) */
|
/* Get social note code (row[1]) */
|
||||||
NotCod = Str_ConvertStrCodToLongCod (row[1]);
|
NotCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
sprintf (Query,"INSERT INTO not_codes SET NotCod='%ld'",NotCod);
|
sprintf (Query,"INSERT INTO not_codes SET NotCod='%ld'",NotCod);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user