mirror of https://github.com/acanas/swad-core.git
Version 20.41.4: Mar 03, 2021 Code refactoring in timeline publications.
This commit is contained in:
parent
fe4a67691a
commit
907824c0c3
|
@ -598,10 +598,11 @@ TODO: DNI de un estudiante sale err
|
||||||
TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede.
|
TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede.
|
||||||
TODO: Salvador Romero Cortés: @acanas opción para editar posts
|
TODO: Salvador Romero Cortés: @acanas opción para editar posts
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.41.3 (2021-03-03)"
|
#define Log_PLATFORM_VERSION "SWAD 20.41.4 (2021-03-03)"
|
||||||
#define CSS_FILE "swad20.33.9.css"
|
#define CSS_FILE "swad20.33.9.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
|
Version 20.41.4: Mar 03, 2021 Code refactoring in timeline publications. (305577 lines)
|
||||||
Version 20.41.3: Mar 03, 2021 Code refactoring in timeline publications. (305580 lines)
|
Version 20.41.3: Mar 03, 2021 Code refactoring in timeline publications. (305580 lines)
|
||||||
Version 20.41.2: Mar 03, 2021 Code refactoring in timeline. (305569 lines)
|
Version 20.41.2: Mar 03, 2021 Code refactoring in timeline. (305569 lines)
|
||||||
Version 20.41.1: Mar 03, 2021 Code refactoring in timeline posts. (305563 lines)
|
Version 20.41.1: Mar 03, 2021 Code refactoring in timeline posts. (305563 lines)
|
||||||
|
|
|
@ -772,22 +772,18 @@ void TL_DB_CreateSubQueryAlreadyExists (const struct TL_Timeline *Timeline,
|
||||||
/***** Create subqueries with range of publications to get from tl_pubs ******/
|
/***** Create subqueries with range of publications to get from tl_pubs ******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TL_DB_CreateSubQueryRangeBottom (const struct TL_Pub_RangePubsToGet *RangePubsToGet,
|
void TL_DB_CreateSubQueryRangeBottom (long Bottom,struct TL_Pub_SubQueries *SubQueries)
|
||||||
struct TL_Pub_SubQueries *SubQueries)
|
|
||||||
{
|
{
|
||||||
if (RangePubsToGet->Bottom > 0)
|
if (Bottom > 0)
|
||||||
sprintf (SubQueries->RangeBottom,"tl_pubs.PubCod>%ld AND ",
|
sprintf (SubQueries->RangeBottom,"tl_pubs.PubCod>%ld AND ",Bottom);
|
||||||
RangePubsToGet->Bottom);
|
|
||||||
else
|
else
|
||||||
SubQueries->RangeBottom[0] = '\0';
|
SubQueries->RangeBottom[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void TL_DB_CreateSubQueryRangeTop (const struct TL_Pub_RangePubsToGet *RangePubsToGet,
|
void TL_DB_CreateSubQueryRangeTop (long Top,struct TL_Pub_SubQueries *SubQueries)
|
||||||
struct TL_Pub_SubQueries *SubQueries)
|
|
||||||
{
|
{
|
||||||
if (RangePubsToGet->Top > 0)
|
if (Top > 0)
|
||||||
sprintf (SubQueries->RangeTop,"tl_pubs.PubCod<%ld AND ",
|
sprintf (SubQueries->RangeTop,"tl_pubs.PubCod<%ld AND ",Top);
|
||||||
RangePubsToGet->Top);
|
|
||||||
else
|
else
|
||||||
SubQueries->RangeTop[0] = '\0';
|
SubQueries->RangeTop[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,10 +105,8 @@ void TL_DB_CreateSubQueryPublishers (const struct TL_Timeline *Timeline,
|
||||||
struct TL_Pub_SubQueries *SubQueries);
|
struct TL_Pub_SubQueries *SubQueries);
|
||||||
void TL_DB_CreateSubQueryAlreadyExists (const struct TL_Timeline *Timeline,
|
void TL_DB_CreateSubQueryAlreadyExists (const struct TL_Timeline *Timeline,
|
||||||
struct TL_Pub_SubQueries *SubQueries);
|
struct TL_Pub_SubQueries *SubQueries);
|
||||||
void TL_DB_CreateSubQueryRangeBottom (const struct TL_Pub_RangePubsToGet *RangePubsToGet,
|
void TL_DB_CreateSubQueryRangeBottom (long Bottom,struct TL_Pub_SubQueries *SubQueries);
|
||||||
struct TL_Pub_SubQueries *SubQueries);
|
void TL_DB_CreateSubQueryRangeTop (long Top,struct TL_Pub_SubQueries *SubQueries);
|
||||||
void TL_DB_CreateSubQueryRangeTop (const struct TL_Pub_RangePubsToGet *RangePubsToGet,
|
|
||||||
struct TL_Pub_SubQueries *SubQueries);
|
|
||||||
unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries,
|
unsigned TL_DB_SelectTheMostRecentPub (const struct TL_Pub_SubQueries *SubQueries,
|
||||||
MYSQL_RES **mysql_res);
|
MYSQL_RES **mysql_res);
|
||||||
unsigned TL_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);
|
unsigned TL_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);
|
||||||
|
|
|
@ -81,6 +81,9 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
|
||||||
unsigned NumPub;
|
unsigned NumPub;
|
||||||
struct TL_Pub_Publication *Pub;
|
struct TL_Pub_Publication *Pub;
|
||||||
|
|
||||||
|
/***** Initialize range of publications *****/
|
||||||
|
TL_Pub_InitializeRangeOfPubs (Timeline->WhatToGet,&RangePubsToGet);
|
||||||
|
|
||||||
/***** Clear timeline for this session in database *****/
|
/***** Clear timeline for this session in database *****/
|
||||||
if (Timeline->WhatToGet == TL_GET_RECENT_TIMELINE)
|
if (Timeline->WhatToGet == TL_GET_RECENT_TIMELINE)
|
||||||
TL_DB_ClearTimelineNotesOfSessionFromDB ();
|
TL_DB_ClearTimelineNotesOfSessionFromDB ();
|
||||||
|
@ -100,30 +103,12 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
|
||||||
/* Create subquery to get only notes not present in timeline */
|
/* Create subquery to get only notes not present in timeline */
|
||||||
TL_DB_CreateSubQueryAlreadyExists (Timeline,&SubQueries);
|
TL_DB_CreateSubQueryAlreadyExists (Timeline,&SubQueries);
|
||||||
|
|
||||||
/***** Get the publications in timeline *****/
|
|
||||||
/* Initialize range of pubs */
|
|
||||||
TL_Pub_InitializeRangeOfPubs (Timeline->WhatToGet,&RangePubsToGet);
|
|
||||||
|
|
||||||
/* Create subquery with bottom range of publications to get from tl_pubs.
|
/* Create subquery with bottom range of publications to get from tl_pubs.
|
||||||
Bottom pub. code remains unchanged in all iterations of the next loop. */
|
Bottom pub. code remains unchanged in all iterations of the loop. */
|
||||||
TL_DB_CreateSubQueryRangeBottom (&RangePubsToGet,&SubQueries);
|
TL_DB_CreateSubQueryRangeBottom (RangePubsToGet.Bottom,&SubQueries);
|
||||||
|
|
||||||
/* With the current approach, we select one by one
|
/***** Initialize list of publications *****/
|
||||||
the publications and notes in a loop. In each iteration,
|
/* Chained list of publications:
|
||||||
we get the most recent publication (original, shared or commment)
|
|
||||||
of every set of publications corresponding to the same note,
|
|
||||||
checking that the note is not already retrieved.
|
|
||||||
After getting a publication, its note code is stored
|
|
||||||
in order to not get it again.
|
|
||||||
|
|
||||||
As an alternative, we tried to get the maximum PubCod,
|
|
||||||
i.e more recent publication (original, shared or commment),
|
|
||||||
of every set of publications corresponding to the same note:
|
|
||||||
"SELECT MAX(PubCod) AS NewestPubCod FROM tl_pubs ...
|
|
||||||
" GROUP BY NotCod ORDER BY NewestPubCod DESC LIMIT ..."
|
|
||||||
but this query is slow (several seconds) with a big table.
|
|
||||||
|
|
||||||
Chained list of publications:
|
|
||||||
|
|
||||||
Timeline->Pubs.Top Pub #0
|
Timeline->Pubs.Top Pub #0
|
||||||
______ ______ Pub #1
|
______ ______ Pub #1
|
||||||
|
@ -142,13 +127,29 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
|
||||||
Timeline->Pubs.Top =
|
Timeline->Pubs.Top =
|
||||||
Timeline->Pubs.Bottom = NULL;
|
Timeline->Pubs.Bottom = NULL;
|
||||||
|
|
||||||
|
/***** Get the publications in timeline *****/
|
||||||
|
/* With the current approach, we select one by one
|
||||||
|
the publications and notes in a loop. In each iteration,
|
||||||
|
we get the most recent publication (original, shared or commment)
|
||||||
|
of every set of publications corresponding to the same note,
|
||||||
|
checking that the note is not already retrieved.
|
||||||
|
After getting a publication, its note code is stored
|
||||||
|
in order to not get it again.
|
||||||
|
|
||||||
|
As an alternative, we tried to get the maximum PubCod,
|
||||||
|
i.e more recent publication (original, shared or commment),
|
||||||
|
of every set of publications corresponding to the same note:
|
||||||
|
"SELECT MAX(PubCod) AS NewestPubCod FROM tl_pubs ...
|
||||||
|
" GROUP BY NotCod ORDER BY NewestPubCod DESC LIMIT ..."
|
||||||
|
but this query is slow (several seconds) with a big table.
|
||||||
|
*/
|
||||||
for (NumPub = 0;
|
for (NumPub = 0;
|
||||||
NumPub < MaxPubsToGet;
|
NumPub < MaxPubsToGet;
|
||||||
NumPub++)
|
NumPub++)
|
||||||
{
|
{
|
||||||
/* Create subquery with top range of publications to get from tl_pubs
|
/* Create subquery with top range of publications to get from tl_pubs
|
||||||
In each iteration of this loop, top publication code is changed to a lower value */
|
In each iteration of this loop, top publication code is changed to a lower value */
|
||||||
TL_DB_CreateSubQueryRangeTop (&RangePubsToGet,&SubQueries);
|
TL_DB_CreateSubQueryRangeTop (RangePubsToGet.Top,&SubQueries);
|
||||||
|
|
||||||
/* Select the most recent publication from tl_pubs */
|
/* Select the most recent publication from tl_pubs */
|
||||||
Pub = TL_Pub_SelectTheMostRecentPub (&SubQueries);
|
Pub = TL_Pub_SelectTheMostRecentPub (&SubQueries);
|
||||||
|
|
Loading…
Reference in New Issue