refix triggers updating EventCounts. remove unsigned from eventcounts and diskspace totals.

This commit is contained in:
Isaac Connor 2018-02-20 22:48:23 -05:00
parent af560b8291
commit 0ad01f09bd
3 changed files with 18 additions and 18 deletions

View File

@ -205,10 +205,10 @@ FOR EACH ROW
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
UPDATE Monitors SET UPDATE Monitors SET
HourEvents = COALESCE(DayEvents,0)+1, HourEvents = COALESCE(HourEvents,0)+1,
DayEvents = COALESCE(DayEvents,0)+1, DayEvents = COALESCE(DayEvents,0)+1,
WeekEvents = COALESCE(DayEvents,0)+1, WeekEvents = COALESCE(WeekEvents,0)+1,
MonthEvents = COALESCE(DayEvents,0)+1, MonthEvents = COALESCE(MonthEvents,0)+1,
TotalEvents = COALESCE(TotalEvents,0)+1 TotalEvents = COALESCE(TotalEvents,0)+1
WHERE Id=NEW.MonitorId; WHERE Id=NEW.MonitorId;
END; END;

View File

@ -756,18 +756,18 @@ CREATE TABLE `Monitors` (
`WebColour` varchar(32) NOT NULL default 'red', `WebColour` varchar(32) NOT NULL default 'red',
`Exif` tinyint(1) unsigned NOT NULL default '0', `Exif` tinyint(1) unsigned NOT NULL default '0',
`Sequence` smallint(5) unsigned default NULL, `Sequence` smallint(5) unsigned default NULL,
`TotalEvents` int(10) unsigned, `TotalEvents` int(10) default NULL,
`TotalEventDiskSpace` bigint unsigned, `TotalEventDiskSpace` bigint default NULL,
`HourEvents` int(10) unsigned, `HourEvents` int(10) default NULL,
`HourEventDiskSpace` bigint unsigned, `HourEventDiskSpace` bigint default NULL,
`DayEvents` int(10) unsigned, `DayEvents` int(10) default NULL,
`DayEventDiskSpace` bigint unsigned, `DayEventDiskSpace` bigint default NULL,
`WeekEvents` int(10) unsigned, `WeekEvents` int(10) default NULL,
`WeekEventDiskSpace` bigint unsigned, `WeekEventDiskSpace` bigint default NULL,
`MonthEvents` int(10) unsigned, `MonthEvents` int(10) default NULL,
`MonthEventDiskSpace` bigint unsigned, `MonthEventDiskSpace` bigint default NULL,
`ArchivedEvents` int(10) unsigned, `ArchivedEvents` int(10) default NULL,
`ArchivedEventDiskSpace` bigint unsigned, `ArchivedEventDiskSpace` bigint default NULL,
`ZoneCount` TINYINT NOT NULL DEFAULT 0, `ZoneCount` TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (`Id`) PRIMARY KEY (`Id`)
) ENGINE=@ZM_MYSQL_ENGINE@; ) ENGINE=@ZM_MYSQL_ENGINE@;

View File

@ -205,10 +205,10 @@ FOR EACH ROW
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
UPDATE Monitors SET UPDATE Monitors SET
HourEvents = COALESCE(DayEvents,0)+1, HourEvents = COALESCE(HourEvents,0)+1,
DayEvents = COALESCE(DayEvents,0)+1, DayEvents = COALESCE(DayEvents,0)+1,
WeekEvents = COALESCE(DayEvents,0)+1, WeekEvents = COALESCE(WeekEvents,0)+1,
MonthEvents = COALESCE(DayEvents,0)+1, MonthEvents = COALESCE(MonthEvents,0)+1,
TotalEvents = COALESCE(TotalEvents,0)+1 TotalEvents = COALESCE(TotalEvents,0)+1
WHERE Id=NEW.MonitorId; WHERE Id=NEW.MonitorId;
END; END;