From e4f62b80d1401197f74c3366111f54a2fde087d8 Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 2 Mar 2021 10:46:37 +0100 Subject: [PATCH] Version 20.39.2: Mar 02, 2021 Code refactoring in timeline database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 28 +++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 7d6e4d56f..b0ea3f9a5 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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: Salvador Romero Cortés: @acanas opción para editar posts */ -#define Log_PLATFORM_VERSION "SWAD 20.39.1 (2021-03-02)" +#define Log_PLATFORM_VERSION "SWAD 20.39.2 (2021-03-02)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* + Version 20.39.2: Mar 02, 2021 Code refactoring in timeline database. (305612 lines) Version 20.39.1: Mar 02, 2021 Code refactoring in timeline comments. (305618 lines) Version 20.39: Mar 02, 2021 Code refactoring in user's photo. (305610 lines) Version 20.38.1: Mar 02, 2021 Code refactoring in timeline comments. (305768 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index d71a2e4da..af2c2323d 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -141,8 +141,8 @@ long TL_DB_GetPubCodOfOriginalNote (long NotCod) if (DB_QuerySELECT (&mysql_res,"can not get code of publication", "SELECT PubCod FROM tl_pubs" " WHERE NotCod=%ld AND PubType=%u", - NotCod,(unsigned) TL_Pub_ORIGINAL_NOTE) == 1) // Result should have a unique row - { + NotCod,(unsigned) TL_Pub_ORIGINAL_NOTE) == 1) + { // Result should have a unique row /* Get code of publication (row[0]) */ row = mysql_fetch_row (mysql_res); OriginalPubCod = Str_ConvertStrCodToLongCod (row[0]); @@ -753,22 +753,16 @@ void TL_DB_CreateSubQueryPublishers (const struct TL_Timeline *Timeline, void TL_DB_CreateSubQueryAlreadyExists (const struct TL_Timeline *Timeline, struct TL_Pub_SubQueries *SubQueries) { - switch (Timeline->WhatToGet) + static const char *Table[TL_NUM_WHAT_TO_GET] = { - case TL_GET_RECENT_TIMELINE: - case TL_GET_ONLY_NEW_PUBS: - Str_Copy (SubQueries->AlreadyExists, - " tl_pubs.NotCod NOT IN" - " (SELECT NotCod FROM tl_tmp_just_retrieved_notes)", // Avoid notes just retrieved - sizeof (SubQueries->AlreadyExists) - 1); - break; - case TL_GET_ONLY_OLD_PUBS: // Get only old publications - Str_Copy (SubQueries->AlreadyExists, - " tl_pubs.NotCod NOT IN" - " (SELECT NotCod FROM tl_tmp_visible_timeline)", // Avoid notes already shown - sizeof (SubQueries->AlreadyExists) - 1); - break; - } + [TL_GET_RECENT_TIMELINE] = "tl_tmp_just_retrieved_notes", // Avoid notes just retrieved + [TL_GET_ONLY_NEW_PUBS ] = "tl_tmp_just_retrieved_notes", // Avoid notes just retrieved + [TL_GET_ONLY_OLD_PUBS ] = "tl_tmp_visible_timeline", // Avoid notes already shown + }; + + snprintf (SubQueries->AlreadyExists,sizeof (SubQueries->AlreadyExists), + " tl_pubs.NotCod NOT IN (SELECT NotCod FROM %s)", + Table[Timeline->WhatToGet]); } /*****************************************************************************/