change behaviour to avoid mr slow updates. Event extended

Former-commit-id: c5a6d5448a14b10b6851f59c5f688f360d747606
This commit is contained in:
fbsanchez 2019-02-11 19:46:46 +01:00
parent e1d87ce0c8
commit 332c53b098
4 changed files with 27 additions and 8 deletions

View File

@ -1856,8 +1856,6 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL;
ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0';
ALTER TABLE `tevento` ADD COLUMN `extended_info` tinyint(1) NOT NULL default '0';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tevent_extended` -- Table `tevent_extended`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------

View File

@ -397,7 +397,7 @@ if ($get_extended_event) {
// Tabs. // Tabs.
$tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>"; $tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>";
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>'; $tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>';
if ($event['extended_info'] == 1) { if (events_has_extended_info($event['id_evento']) === true) {
$tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>'; $tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>';
} }
@ -491,7 +491,7 @@ if ($get_extended_event) {
$details = events_page_details($event, $server); $details = events_page_details($event, $server);
if ($event['extended_info'] == 1) { if (events_has_extended_info($event['id_evento']) === true) {
$related = events_page_related($event, $server); $related = events_page_related($event, $server);
} }
@ -568,7 +568,7 @@ if ($get_extended_event) {
$js .= '});'; $js .= '});';
if ($event['extended_info'] == 1) { if (events_has_extended_info($event['id_evento']) === true) {
$js .= ' $js .= '
$("#link_related").click(function (){ $("#link_related").click(function (){
$.post ({ $.post ({

View File

@ -2602,7 +2602,8 @@ function events_get_extended_events(int $id_evento)
{ {
return db_get_all_rows_sql( return db_get_all_rows_sql(
sprintf( sprintf(
'SELECT * FROM tevent_extended WHERE id_evento=%d', 'SELECT * FROM tevent_extended
WHERE id_evento=%d ORDER BY utimestamp DESC',
$id_evento $id_evento
) )
); );
@ -2610,6 +2611,27 @@ function events_get_extended_events(int $id_evento)
} }
/**
* Return if event has extended info or not.
*
* @param integer $id_event Target event.
*
* @return boolean Has extended info or not
*/
function events_has_extended_info(int $id_event)
{
return (bool) db_get_value_sql(
sprintf(
'
SELECT count(*) as "n"
FROM tevent_extended WHERE id_evento=%d
',
$id_event
)
);
}
/** /**
* Generates the 'related' page in event view. * Generates the 'related' page in event view.
* *

View File

@ -643,8 +643,7 @@ CREATE TABLE IF NOT EXISTS `tevento` (
`ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0',
`custom_data` TEXT NOT NULL, `custom_data` TEXT NOT NULL,
`data` double(22,5) default NULL, `data` double(22,5) default NULL,
`module_status` int(4) NOT NULL default '0', `module_status` int(4) NOT NULL default '0'
`extended_info` tinyint(1) NOT NULL default '0'
PRIMARY KEY (`id_evento`), PRIMARY KEY (`id_evento`),
KEY `idx_agente` (`id_agente`), KEY `idx_agente` (`id_agente`),
KEY `idx_agentmodule` (`id_agentmodule`), KEY `idx_agentmodule` (`id_agentmodule`),