mirror of https://github.com/acanas/swad-core.git
Version 20.36.15: Feb 27, 2021 Functions moved to module swad_timeline_database.
This commit is contained in:
parent
f346dfc4f1
commit
fd99ef1116
|
@ -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.14 (2021-02-27)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.36.15 (2021-02-27)"
|
||||
#define CSS_FILE "swad20.33.9.css"
|
||||
#define JS_FILE "swad20.6.2.js"
|
||||
/*
|
||||
|
@ -601,7 +601,8 @@ 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.14: Feb 27, 2021 Query moved to module swad_timeline_database. (? lines)
|
||||
Version 20.36.15: Feb 27, 2021 Functions moved to module swad_timeline_database. (305305 lines)
|
||||
Version 20.36.14: Feb 27, 2021 Query moved to module swad_timeline_database. (305300 lines)
|
||||
Version 20.36.13: Feb 27, 2021 Functions moved to module swad_timeline_database. (305285 lines)
|
||||
Version 20.36.12: Feb 27, 2021 Queries moved to module swad_timeline_database. (305282 lines)
|
||||
Version 20.36.11: Feb 27, 2021 Query moved to module swad_timeline_database. (305246 lines)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_timeline_note.h"
|
||||
#include "swad_timeline_database.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
|
@ -227,7 +227,7 @@ static void Ses_RemoveSessionFromDB (void)
|
|||
|
||||
/***** Clear old unused social timelines in database *****/
|
||||
// This is necessary to prevent the table growing and growing
|
||||
TL_Not_ClearOldTimelinesNotesFromDB ();
|
||||
TL_DB_ClearOldTimelinesNotesFromDB ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -159,6 +159,30 @@ void TL_DB_MarkNotesChildrenOfFolderAsUnavailable (TL_Not_NoteType_t NoteType,
|
|||
Path);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Create temporary tables used to not get notes already shown *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_DB_CreateTmpTableJustRetrievedNotes (void)
|
||||
{
|
||||
/***** Create temporary table with notes just retrieved *****/
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE tl_tmp_just_retrieved_notes "
|
||||
"(NotCod BIGINT NOT NULL,UNIQUE INDEX(NotCod))"
|
||||
" ENGINE=MEMORY");
|
||||
}
|
||||
|
||||
void TL_DB_CreateTmpTableVisibleTimeline (char SessionId[Cns_BYTES_SESSION_ID + 1])
|
||||
{
|
||||
/***** Create temporary table with all notes visible in timeline *****/
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE tl_tmp_visible_timeline "
|
||||
"(NotCod BIGINT NOT NULL,UNIQUE INDEX(NotCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT NotCod FROM tl_timelines WHERE SessionId='%s'",
|
||||
SessionId);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**** Insert note in temporary tables used to not get notes already shown ****/
|
||||
/*****************************************************************************/
|
||||
|
@ -214,6 +238,49 @@ mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId;
|
|||
SessionId);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Drop temporary tables used to not get notes already shown **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_DB_DropTmpTableJustRetrievedNotes (void)
|
||||
{
|
||||
/***** Drop temporary table with notes just retrieved *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS tl_tmp_just_retrieved_notes");
|
||||
}
|
||||
|
||||
void TL_DB_DropTmpTableVisibleTimeline (void)
|
||||
{
|
||||
/***** Drop temporary table with all notes visible in timeline *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS tl_tmp_visible_timeline");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Clear unused old timelines in database ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_DB_ClearOldTimelinesNotesFromDB (void)
|
||||
{
|
||||
/***** Remove timelines for expired sessions *****/
|
||||
DB_QueryDELETE ("can not remove old timelines",
|
||||
"DELETE LOW_PRIORITY FROM tl_timelines"
|
||||
" WHERE SessionId NOT IN (SELECT SessionId FROM sessions)");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Clear timeline for a session in database ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_DB_ClearTimelineNotesOfSessionFromDB (char SessionId[Cns_BYTES_SESSION_ID + 1])
|
||||
{
|
||||
/***** Remove timeline for a session *****/
|
||||
DB_QueryDELETE ("can not remove timeline",
|
||||
"DELETE FROM tl_timelines"
|
||||
" WHERE SessionId='%s'",
|
||||
SessionId);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************************** Remove favs for a note **************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -54,9 +54,15 @@ void TL_DB_MarkNotesChildrenOfFolderAsUnavailable (TL_Not_NoteType_t NoteType,
|
|||
Brw_FileBrowser_t FileBrowser,
|
||||
long Cod,
|
||||
const char *Path);
|
||||
void TL_DB_CreateTmpTableJustRetrievedNotes (void);
|
||||
void TL_DB_CreateTmpTableVisibleTimeline (char SessionId[Cns_BYTES_SESSION_ID + 1]);
|
||||
void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod);
|
||||
void TL_DB_InsertNoteInVisibleTimeline (long NotCod);
|
||||
void TL_DB_AddNotesJustRetrievedToVisibleTimelineOfSession (char SessionId[Cns_BYTES_SESSION_ID + 1]);
|
||||
void TL_DB_DropTmpTableJustRetrievedNotes (void);
|
||||
void TL_DB_DropTmpTableVisibleTimeline (void);
|
||||
void TL_DB_ClearOldTimelinesNotesFromDB (void);
|
||||
void TL_DB_ClearTimelineNotesOfSessionFromDB (char SessionId[Cns_BYTES_SESSION_ID + 1]);
|
||||
void TL_DB_RemoveNoteFavs (long NotCod);
|
||||
void TL_DB_RemoveNotePubs (long NotCod);
|
||||
void TL_DB_RemoveNote (long NotCod,long PublisherCod);
|
||||
|
|
|
@ -1358,64 +1358,3 @@ void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not)
|
|||
/***** Reset fields of note *****/
|
||||
TL_Not_ResetNote (Not);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Clear unused old timelines in database ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_Not_ClearOldTimelinesNotesFromDB (void)
|
||||
{
|
||||
/***** Remove timelines for expired sessions *****/
|
||||
DB_QueryDELETE ("can not remove old timelines",
|
||||
"DELETE LOW_PRIORITY FROM tl_timelines"
|
||||
" WHERE SessionId NOT IN (SELECT SessionId FROM sessions)");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Clear timeline for this session in database ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_Not_ClearTimelineNotesThisSessionFromDB (void)
|
||||
{
|
||||
/***** Remove timeline for this session *****/
|
||||
DB_QueryDELETE ("can not remove timeline",
|
||||
"DELETE FROM tl_timelines"
|
||||
" WHERE SessionId='%s'",
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Create/drop temporary tables with notes already retrieved **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TL_Not_CreateTmpTablesWithNotesAlreadyRetrieved (const struct TL_Timeline *Timeline)
|
||||
{
|
||||
/***** Create temporary table with notes just retrieved *****/
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE tl_tmp_just_retrieved_notes "
|
||||
"(NotCod BIGINT NOT NULL,UNIQUE INDEX(NotCod))"
|
||||
" ENGINE=MEMORY");
|
||||
|
||||
if (Timeline->WhatToGet == TL_GET_ONLY_OLD_PUBS)
|
||||
/***** Create temporary table with all notes visible in timeline *****/
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE tl_tmp_visible_timeline "
|
||||
"(NotCod BIGINT NOT NULL,UNIQUE INDEX(NotCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT NotCod FROM tl_timelines WHERE SessionId='%s'",
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
||||
void TL_Not_DropTmpTableJustRetrievedNotes (void)
|
||||
{
|
||||
/***** Drop temporary table with notes just retrieved *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS tl_tmp_just_retrieved_notes");
|
||||
}
|
||||
|
||||
void TL_Not_DropTmpTableVisibleTimeline (void)
|
||||
{
|
||||
/***** Drop temporary table with all notes visible in timeline *****/
|
||||
DB_Query ("can not remove temporary table",
|
||||
"DROP TEMPORARY TABLE IF EXISTS tl_tmp_visible_timeline");
|
||||
}
|
||||
|
|
|
@ -112,11 +112,4 @@ void TL_Not_RemoveNoteGbl (void);
|
|||
|
||||
void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not);
|
||||
|
||||
void TL_Not_ClearOldTimelinesNotesFromDB (void);
|
||||
void TL_Not_ClearTimelineNotesThisSessionFromDB (void);
|
||||
|
||||
void TL_Not_CreateTmpTablesWithNotesAlreadyRetrieved (const struct TL_Timeline *Timeline);
|
||||
void TL_Not_DropTmpTableJustRetrievedNotes (void);
|
||||
void TL_Not_DropTmpTableVisibleTimeline (void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -77,8 +77,6 @@ extern struct Globals Gbl;
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void TL_Pub_DropTemporaryTables (const struct TL_Timeline *Timeline);
|
||||
|
||||
static unsigned TL_Pub_GetMaxPubsToGet (const struct TL_Timeline *Timeline);
|
||||
|
||||
static void TL_Pub_CreateSubQueryPublishers (const struct TL_Timeline *Timeline,
|
||||
|
@ -111,15 +109,21 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
|
|||
|
||||
/***** Clear timeline for this session in database *****/
|
||||
if (Timeline->WhatToGet == TL_GET_RECENT_TIMELINE)
|
||||
TL_Not_ClearTimelineNotesThisSessionFromDB ();
|
||||
TL_DB_ClearTimelineNotesOfSessionFromDB (Gbl.Session.Id);
|
||||
|
||||
/***** Create temporary table with notes in current timeline *****/
|
||||
TL_Not_CreateTmpTablesWithNotesAlreadyRetrieved (Timeline);
|
||||
/***** Create temporary tables *****/
|
||||
/* Create temporary table with notes just retrieved */
|
||||
TL_DB_CreateTmpTableJustRetrievedNotes ();
|
||||
|
||||
/***** Create temporary table and subquery with potential publishers *****/
|
||||
/* Create temporary table with all notes visible in timeline */
|
||||
if (Timeline->WhatToGet == TL_GET_ONLY_OLD_PUBS)
|
||||
TL_DB_CreateTmpTableVisibleTimeline (Gbl.Session.Id);
|
||||
|
||||
/***** Create subqueries *****/
|
||||
/* Create subquery with potential publishers */
|
||||
TL_Pub_CreateSubQueryPublishers (Timeline,&SubQueries);
|
||||
|
||||
/***** Create subquery to get only notes not present in timeline *****/
|
||||
/* Create subquery to get only notes not present in timeline */
|
||||
TL_Pub_CreateSubQueryAlreadyExists (Timeline,&SubQueries);
|
||||
|
||||
/***** Get the publications in timeline *****/
|
||||
|
@ -240,21 +244,12 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline)
|
|||
TL_DB_AddNotesJustRetrievedToVisibleTimelineOfSession (Gbl.Session.Id);
|
||||
|
||||
/***** Drop temporary tables *****/
|
||||
TL_Pub_DropTemporaryTables (Timeline);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************************** Drop temporary tables ***************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void TL_Pub_DropTemporaryTables (const struct TL_Timeline *Timeline)
|
||||
{
|
||||
/***** Drop temporary tables with notes already retrieved *****/
|
||||
TL_Not_DropTmpTableJustRetrievedNotes ();
|
||||
/* Drop temporary tables with notes already retrieved */
|
||||
TL_DB_DropTmpTableJustRetrievedNotes ();
|
||||
if (Timeline->WhatToGet == TL_GET_ONLY_OLD_PUBS) // Get only old publications
|
||||
TL_Not_DropTmpTableVisibleTimeline ();
|
||||
TL_DB_DropTmpTableVisibleTimeline ();
|
||||
|
||||
/**** Drop temporary table with me and users I follow ****/
|
||||
/* Drop temporary table with me and users I follow */
|
||||
if (Timeline->UsrOrGbl == TL_Usr_TIMELINE_GBL) // Show the global timeline
|
||||
if (Timeline->Who == Usr_WHO_FOLLOWED) // Show the timeline of the users I follow
|
||||
Fol_DropTmpTableMeAndUsrsIFollow ();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_timeline.h"
|
||||
#include "swad_timeline_database.h"
|
||||
#include "swad_timeline_form.h"
|
||||
#include "swad_timeline_notification.h"
|
||||
#include "swad_timeline_publication.h"
|
||||
|
|
Loading…
Reference in New Issue