From fd3aa49331aa2ac0688a4120eaed60f8c70e36c1 Mon Sep 17 00:00:00 2001 From: acanas Date: Fri, 26 Feb 2021 22:34:11 +0100 Subject: [PATCH] Version 20.36.2: Feb 26, 2021 Query moved to module swad_timeline_database. --- swad_changelog.h | 3 +- swad_timeline_comment.c | 22 +++------------ swad_timeline_database.c | 61 ++++++++++++++++++++++++++++------------ swad_timeline_database.h | 3 ++ 4 files changed, 52 insertions(+), 37 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 8f957902b..21da0e62b 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.1 (2021-02-26)" +#define Log_PLATFORM_VERSION "SWAD 20.36.2 (2021-02-26)" #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.2: Feb 26, 2021 Query moved to module swad_timeline_database. (305126 lines) Version 20.36.1: Feb 26, 2021 Function moved to module swad_timeline_database. (305113 lines) Version 20.36: Feb 26, 2021 New module swad_timeline_database. (305133 lines) Version 20.35.1: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305021 lines) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index d865fb3b1..59e6646d4 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -354,25 +354,11 @@ static unsigned TL_Com_WriteHiddenComments (struct TL_Timeline *Timeline, unsigned long NumCom; /***** Get comments of this note from database *****/ - NumInitialCommentsGot = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get comments", - "SELECT tl_pubs.PubCod," // row[0] - "tl_pubs.PublisherCod," // row[1] - "tl_pubs.NotCod," // row[2] - "UNIX_TIMESTAMP(" - "tl_pubs.TimePublish)," // row[3] - "tl_comments.Txt," // row[4] - "tl_comments.MedCod" // row[5] - " FROM tl_pubs,tl_comments" - " WHERE tl_pubs.NotCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod" - " ORDER BY tl_pubs.PubCod" - " LIMIT %lu", - NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE, - NumInitialCommentsToGet); + NumInitialCommentsGot = TL_DB_GetInitialComments (NotCod, + NumInitialCommentsToGet, + &mysql_res); - /***** List with comments *****/ + /***** List comments *****/ HTM_UL_Begin ("id=\"com_%s\" class=\"TL_LIST\"",IdComments); for (NumCom = 0; NumCom < NumInitialCommentsGot; diff --git a/swad_timeline_database.c b/swad_timeline_database.c index bcf5dedf9..9d9730fe9 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -62,6 +62,32 @@ unsigned TL_DB_GetNumCommentsInNote (long NotCod) NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); } +/*****************************************************************************/ +/************** Get initial comments of a note from database *****************/ +/*****************************************************************************/ + +unsigned TL_DB_GetInitialComments (long NotCod, + unsigned NumInitialCommentsToGet, + MYSQL_RES **mysql_res) + { + return (unsigned) + DB_QuerySELECT (mysql_res,"can not get comments", + "SELECT tl_pubs.PubCod," // row[0] + "tl_pubs.PublisherCod," // row[1] + "tl_pubs.NotCod," // row[2] + "UNIX_TIMESTAMP(tl_pubs.TimePublish)," // row[3] + "tl_comments.Txt," // row[4] + "tl_comments.MedCod" // row[5] + " FROM tl_pubs,tl_comments" + " WHERE tl_pubs.NotCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod" + " ORDER BY tl_pubs.PubCod" + " LIMIT %lu", + NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE, + NumInitialCommentsToGet); + } + /*****************************************************************************/ /*************** Get final comments of a note from database ******************/ /*****************************************************************************/ @@ -73,22 +99,21 @@ unsigned TL_DB_GetFinalComments (long NotCod, /***** Get final comments of a note from database *****/ return (unsigned) DB_QuerySELECT (mysql_res,"can not get comments", - "SELECT * FROM " - "(" - "SELECT tl_pubs.PubCod," // row[0] - "tl_pubs.PublisherCod," // row[1] - "tl_pubs.NotCod," // row[2] - "UNIX_TIMESTAMP(" - "tl_pubs.TimePublish)," // row[3] - "tl_comments.Txt," // row[4] - "tl_comments.MedCod" // row[5] - " FROM tl_pubs,tl_comments" - " WHERE tl_pubs.NotCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod" - " ORDER BY tl_pubs.PubCod DESC LIMIT %u" - ") AS comments" - " ORDER BY PubCod", - NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE, - NumFinalCommentsToGet); + "SELECT * FROM " + "(" + "SELECT tl_pubs.PubCod," // row[0] + "tl_pubs.PublisherCod," // row[1] + "tl_pubs.NotCod," // row[2] + "UNIX_TIMESTAMP(tl_pubs.TimePublish)," // row[3] + "tl_comments.Txt," // row[4] + "tl_comments.MedCod" // row[5] + " FROM tl_pubs,tl_comments" + " WHERE tl_pubs.NotCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod" + " ORDER BY tl_pubs.PubCod DESC LIMIT %u" + ") AS comments" + " ORDER BY PubCod", + NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE, + NumFinalCommentsToGet); } diff --git a/swad_timeline_database.h b/swad_timeline_database.h index e492ece98..be59440aa 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -42,6 +42,9 @@ /*****************************************************************************/ unsigned TL_DB_GetNumCommentsInNote (long NotCod); +unsigned TL_DB_GetInitialComments (long NotCod, + unsigned NumInitialCommentsToGet, + MYSQL_RES **mysql_res); unsigned TL_DB_GetFinalComments (long NotCod, unsigned NumFinalCommentsToGet, MYSQL_RES **mysql_res);