From 77ac719879190bb7df25b7aa66915164641fbba3 Mon Sep 17 00:00:00 2001 From: acanas Date: Sat, 27 Feb 2021 21:44:46 +0100 Subject: [PATCH] Version 20.36.19: Feb 27, 2021 Queries moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 48 +++++++++++++++++++++++++++++++++++++ swad_timeline_database.h | 5 ++++ swad_timeline_publication.c | 31 ++++-------------------- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 47215c99..d5b241d5 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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.36.18 (2021-02-27)" +#define Log_PLATFORM_VERSION "SWAD 20.36.19 (2021-02-27)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ 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: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.36.19: Feb 27, 2021 Queries moved to module swad_timeline_database. (305363 lines) Version 20.36.18: Feb 27, 2021 Function moved to module swad_timeline_database. (305334 lines) Version 20.36.17: Feb 27, 2021 Query moved to module swad_timeline_database. (305328 lines) Version 20.36.16: Feb 27, 2021 Query moved to module swad_timeline_database. (305317 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index c284f4e5..598810e5 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -623,3 +623,51 @@ long TL_DB_GetPubCodFromSession (const char *FieldName, return PubCod; } + +/*****************************************************************************/ +/************** Update first publication code stored in session **************/ +/*****************************************************************************/ + +void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod, + const char SessionId[Cns_BYTES_SESSION_ID + 1]) + { + DB_QueryUPDATE ("can not update first publication code into session", + "UPDATE sessions" + " SET FirstPubCod=%ld" + " WHERE SessionId='%s'", + FirstPubCod, + SessionId); + } + +/*****************************************************************************/ +/*************** Update last publication code stored in session **************/ +/*****************************************************************************/ + +void TL_DB_UpdateLastPubCodInSession (const char SessionId[Cns_BYTES_SESSION_ID + 1]) + { + DB_QueryUPDATE ("can not update last publication code into session", + "UPDATE sessions" + " SET LastPubCod=" + "(SELECT IFNULL(MAX(PubCod),0)" + " FROM tl_pubs)" // The most recent publication + " WHERE SessionId='%s'", + SessionId); + } + +/*****************************************************************************/ +/********* Update first and last publication codes stored in session *********/ +/*****************************************************************************/ + +void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod, + const char SessionId[Cns_BYTES_SESSION_ID + 1]) + { + 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, + SessionId); + } diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 1e9b474a..8ce595c8 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -93,5 +93,10 @@ void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod); /* Publications */ long TL_DB_GetPubCodFromSession (const char *FieldName, const char SessionId[Cns_BYTES_SESSION_ID + 1]); +void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod, + const char SessionId[Cns_BYTES_SESSION_ID + 1]); +void TL_DB_UpdateLastPubCodInSession (const char SessionId[Cns_BYTES_SESSION_ID + 1]); +void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod, + const char SessionId[Cns_BYTES_SESSION_ID + 1]); #endif diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index 2813a7aa..ce18db2a 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -373,41 +373,20 @@ static void TL_Pub_UpdateFirstLastPubCodesIntoSession (const struct TL_Timeline 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); + case TL_GET_ONLY_NEW_PUBS: // Get only new publications + TL_DB_UpdateLastPubCodInSession (Gbl.Session.Id); break; case TL_GET_ONLY_OLD_PUBS: // Get only old publications // The oldest publication code retrieved and shown FirstPubCod = Timeline->Pubs.Bottom ? Timeline->Pubs.Bottom->PubCod : 0; - - DB_QueryUPDATE ("can not update first/last publication codes into session", - "UPDATE sessions" - " SET FirstPubCod=%ld" - " WHERE SessionId='%s'", - FirstPubCod, - Gbl.Session.Id); + TL_DB_UpdateFirstPubCodInSession (FirstPubCod,Gbl.Session.Id); break; - case TL_GET_RECENT_TIMELINE: + case TL_GET_RECENT_TIMELINE: // Get last publications // The oldest publication code retrieved and shown FirstPubCod = Timeline->Pubs.Bottom ? Timeline->Pubs.Bottom->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); + TL_DB_UpdateFirstLastPubCodsInSession (FirstPubCod,Gbl.Session.Id); break; } }