Version 21.58.1: Nov 21, 2021 Code refactoring in timeline.

This commit is contained in:
acanas 2021-11-21 11:40:57 +01:00
parent 9d46cff420
commit 0d0bb5c887
5 changed files with 32 additions and 43 deletions

View File

@ -602,14 +602,15 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/
#define Log_PLATFORM_VERSION "SWAD 21.58 (2021-11-21)"
#define Log_PLATFORM_VERSION "SWAD 21.58.1 (2021-11-21)"
#define CSS_FILE "swad21.57.css"
#define JS_FILE "swad21.58.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.58: Nov 21, 2021 Code refactoring in timeline. (319157 lines)
Version 21.58.1: Nov 21, 2021 Code refactoring in timeline. (319131 lines)
Version 21.58: Nov 21, 2021 Code refactoring in timeline. (319140 lines)
Version 21.57.5: Nov 18, 2021 Code refactoring related to check if user logged is me. (319174 lines)
Version 21.57.4: Nov 17, 2021 Code refactoring in timeline. (319235 lines)
Version 21.57.3: Nov 17, 2021 Code refactoring in timeline. (319225 lines)

View File

@ -891,39 +891,22 @@ void Tml_DB_CreateSubQueryPublishers (Tml_Usr_UsrOrGbl_t UsrOrGbl,Usr_Who_t Who,
}
}
/*****************************************************************************/
/********* Create subquery to get only notes not present in timeline *********/
/*****************************************************************************/
void Tml_DB_CreateSubQueryAlreadyExists (char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
{
Str_Copy (AlreadyExists,
" tml_pubs.NotCod NOT IN"
" (SELECT NotCod"
" FROM tml_tmp_timeline)",
Tml_Pub_MAX_BYTES_SUBQUERY);
}
/*****************************************************************************/
/***** Create subqueries with range of publications to get from tml_pubs *****/
/*****************************************************************************/
void Tml_DB_CreateSubQueryRangeBottom (long Bottom,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
void Tml_DB_CreateSubQueryRange (Tml_Pub_Range_t Range,long PubCod,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
{
if (Bottom > 0)
snprintf (SubQuery,Tml_Pub_MAX_BYTES_SUBQUERY + 1,
"tml_pubs.PubCod>%ld AND ",Bottom);
else
SubQuery[0] = '\0';
}
static const char Operator[Tml_Pub_NUM_RANGES] =
{
[Tml_Pub_TOP ] = '<',
[Tml_Pub_BOTTOM] = '>',
};
void Tml_DB_CreateSubQueryRangeTop (long Top,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
{
if (Top > 0)
if (PubCod > 0)
snprintf (SubQuery,Tml_Pub_MAX_BYTES_SUBQUERY + 1,
"tml_pubs.PubCod<%ld AND ",Top);
"tml_pubs.PubCod%c%ld AND ",Operator[Range],PubCod);
else
SubQuery[0] = '\0';
}
@ -943,14 +926,16 @@ unsigned Tml_DB_SelectTheMostRecentPub (MYSQL_RES **mysql_res,
"tml_pubs.PublisherCod," // row[2]
"tml_pubs.PubType" // row[3]
" FROM tml_pubs%s"
" WHERE %s%s%s%s"
" WHERE %s%s%s"
" tml_pubs.NotCod NOT IN"
" (SELECT NotCod"
" FROM tml_tmp_timeline)"
" ORDER BY tml_pubs.PubCod DESC"
" LIMIT 1",
SubQueries->Publishers.Table,
SubQueries->RangeBottom,
SubQueries->RangeTop,
SubQueries->Publishers.SubQuery,
SubQueries->AlreadyExists);
SubQueries->Publishers.SubQuery);
}
/*****************************************************************************/

View File

@ -96,11 +96,8 @@ void Tml_DB_RemoveAllCommsMadeBy (long UsrCod);
void Tml_DB_CreateSubQueryPublishers (Tml_Usr_UsrOrGbl_t UsrOrGbl,Usr_Who_t Who,
char **Table,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
void Tml_DB_CreateSubQueryAlreadyExists (char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
void Tml_DB_CreateSubQueryRangeBottom (long Bottom,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
void Tml_DB_CreateSubQueryRangeTop (long Top,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
void Tml_DB_CreateSubQueryRange (Tml_Pub_Range_t Range,long PubCod,
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
unsigned Tml_DB_SelectTheMostRecentPub (MYSQL_RES **mysql_res,
const struct Tml_Pub_SubQueries *SubQueries);
unsigned Tml_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);

View File

@ -105,13 +105,11 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
&SubQueries.Publishers.Table,
SubQueries.Publishers.SubQuery);
/* Create subquery to get only notes not present in timeline */
Tml_DB_CreateSubQueryAlreadyExists (SubQueries.AlreadyExists);
/* Create subquery with bottom range of publications to get from tml_pubs.
Bottom pub. code remains unchanged in all iterations of the loop. */
Tml_DB_CreateSubQueryRangeBottom (RangePubsToGet.Bottom,
SubQueries.RangeBottom);
Tml_DB_CreateSubQueryRange (Tml_Pub_BOTTOM,
RangePubsToGet.Bottom,
SubQueries.RangeBottom);
/***** Initialize list of publications *****/
/* Chained list of publications:
@ -158,7 +156,9 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
{
/* Create subquery with top range of publications to get from tml_pubs
In each iteration of this loop, top publication code is changed to a lower value */
Tml_DB_CreateSubQueryRangeTop (RangePubsToGet.Top,SubQueries.RangeTop);
Tml_DB_CreateSubQueryRange (Tml_Pub_TOP,
RangePubsToGet.Top,
SubQueries.RangeTop);
/* Select the most recent publication from tml_pubs */
Pub = Tml_Pub_SelectTheMostRecentPub (&SubQueries);

View File

@ -65,6 +65,13 @@ struct Tml_Pub_Publication
struct Tml_Pub_Publication *Next; // Used for chained list
};
#define Tml_Pub_NUM_RANGES 2
typedef enum
{
Tml_Pub_TOP = 0,
Tml_Pub_BOTTOM = 1,
} Tml_Pub_Range_t;
struct Tml_Pub_RangePubsToGet
{
long Top; // Top pub code
@ -88,7 +95,6 @@ struct Tml_Pub_SubQueries
} Publishers;
char RangeBottom [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
char RangeTop [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1];
};
/*****************************************************************************/