Version20.21.4

This commit is contained in:
acanas 2021-02-10 18:41:42 +01:00
parent ddd0ed5ca9
commit 0214a3c54d
2 changed files with 50 additions and 38 deletions

View File

@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 20.21.3 (2021-02-10)"
#define Log_PLATFORM_VERSION "SWAD 20.21.4 (2021-02-10)"
#define CSS_FILE "swad20.8.css"
#define JS_FILE "swad20.6.2.js"
/*
@ -599,7 +599,9 @@ Juan Miguel.
TODO: DNI de un estudiante sale erróneamente como ******* en lugar de mostrarse al ver los accesos de un estudiante a la asignatura.
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
Version 20.21.4: Feb 10, 2021 Code refactoring in timeline. (305136 lines)
Version 20.21.3: Feb 10, 2021 Code refactoring in timeline. (305122 lines)
Version 20.21.2: Feb 10, 2021 Fixed bug in timeline. (305128 lines)
Version 20.21.1: Feb 10, 2021 Code refactoring in timeline. (305128 lines)

View File

@ -236,8 +236,7 @@ static void TL_GetAndShowOldTimeline (struct TL_Timeline *Timeline);
static void TL_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline);
static unsigned TL_GetMaxPubsToGet (const struct TL_Timeline *Timeline);
static long TL_GetPubCodFromSession (const char *FieldName);
static void TL_UpdateLastPubCodIntoSession (void);
static void TL_UpdateFirstPubCodIntoSession (const struct TL_Timeline *Timeline);
static void TL_UpdateFirstLastPubCodesIntoSession (const struct TL_Timeline *Timeline);
static void TL_CreateTmpTableCurrentTimeline (const struct TL_Timeline *Timeline);
static void TL_CreateTmpTablePublishers (void);
static void TL_DropTmpTablesUsedToQueryTimeline (void);
@ -757,8 +756,6 @@ static void TL_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
if (Timeline->Pubs.Lst[NumPub].PubCod <= 0) // Nothing got ==> abort loop
break; // Last publication
Timeline->Pubs.Num++;
/* Insert note in temporary tables with just retrieved notes.
These tables will be used to not get notes already shown */
TL_InsertNoteInJustRetrievedNotes (Timeline->Pubs.Lst[NumPub].NotCod);
@ -767,11 +764,11 @@ static void TL_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
RangePubsToGet.Top = Timeline->Pubs.Lst[NumPub].PubCod; // Narrow the range for the next iteration
}
Timeline->Pubs.Num = NumPub; // Number of publications actually got
/***** Update last (more recent) publication code into session for next refresh *****/
// Do this inmediately after getting the publications codes...
// ...in order to not lose publications
TL_UpdateLastPubCodIntoSession ();
/***** Update first (oldest) and last (more recent) publication codes
into session for next refresh *****/
TL_UpdateFirstLastPubCodesIntoSession (Timeline);
/***** Add notes just retrieved to current timeline for this session *****/
TL_AddNotesJustRetrievedToTimelineThisSession ();
@ -829,34 +826,53 @@ static long TL_GetPubCodFromSession (const char *FieldName)
}
/*****************************************************************************/
/***************** Update the most recent publication code *******************/
/************* Update first (oldest) and last (more recent) ***************/
/************* publication codes into session for next refresh ***************/
/*****************************************************************************/
static void TL_UpdateLastPubCodIntoSession (void)
static void TL_UpdateFirstLastPubCodesIntoSession (const struct TL_Timeline *Timeline)
{
/***** Update last publication code *****/
DB_QueryUPDATE ("can not update last publication code into session",
"UPDATE sessions"
" SET LastPubCod="
"(SELECT IFNULL(MAX(PubCod),0) FROM tl_pubs)"
" WHERE SessionId='%s'",
Gbl.Session.Id);
}
long FirstPubCod;
/*****************************************************************************/
/******************** Update the oldest publication code *********************/
/*****************************************************************************/
switch (Timeline->WhatToGet)
{
case TL_GET_ONLY_NEW_PUBS:
DB_QueryUPDATE ("can not update first/last publication codes into session",
"UPDATE sessions"
" SET LastPubCod="
"(SELECT IFNULL(MAX(PubCod),0)"
" FROM tl_pubs)" // The most recent publication
" WHERE SessionId='%s'",
Gbl.Session.Id);
break;
case TL_GET_ONLY_OLD_PUBS:
// The oldest publication code retrieved and shown
FirstPubCod = Timeline->Pubs.Num ? Timeline->Pubs.Lst[Timeline->Pubs.Num - 1].PubCod :
0;
static void TL_UpdateFirstPubCodIntoSession (const struct TL_Timeline *Timeline)
{
/***** Update last publication code *****/
DB_QueryUPDATE ("can not update first publication code into session",
"UPDATE sessions"
" SET FirstPubCod=%ld"
" WHERE SessionId='%s'",
Timeline->Pubs.Num ? Timeline->Pubs.Lst[Timeline->Pubs.Num - 1].PubCod : // The last element in list is the oldest
0L,
Gbl.Session.Id);
DB_QueryUPDATE ("can not update first/last publication codes into session",
"UPDATE sessions"
" SET FirstPubCod=%ld"
" WHERE SessionId='%s'",
FirstPubCod,
Gbl.Session.Id);
break;
case TL_GET_RECENT_TIMELINE:
// The oldest publication code retrieved and shown
FirstPubCod = Timeline->Pubs.Num ? Timeline->Pubs.Lst[Timeline->Pubs.Num - 1].PubCod :
0;
DB_QueryUPDATE ("can not update first/last publication codes into session",
"UPDATE sessions"
" SET FirstPubCod=%ld,"
"LastPubCod="
"(SELECT IFNULL(MAX(PubCod),0)"
" FROM tl_pubs)" // The most recent publication
" WHERE SessionId='%s'",
FirstPubCod,
Gbl.Session.Id);
break;
}
}
/*****************************************************************************/
@ -1174,9 +1190,6 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline,
}
HTM_UL_End ();
/***** Store first (oldest) publication code into session *****/
TL_UpdateFirstPubCodIntoSession (Timeline);
if (Timeline->Pubs.Num == TL_MAX_REC_PUBS_TO_GET_AND_SHOW)
{
/***** Link to view old publications via AJAX *****/
@ -1424,9 +1437,6 @@ static void TL_ShowOldPubsInTimeline (struct TL_Timeline *Timeline)
TL_DONT_HIGHLIGHT_NOTE,
TL_DONT_SHOW_NOTE_ALONE);
}
/***** Store first (oldest) publication code into session *****/
TL_UpdateFirstPubCodIntoSession (Timeline);
}
/*****************************************************************************/