forked from BlueHerons/StatTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Determine if a stat is ticking and show it. BlueHerons#111
- Loading branch information
1 parent
9bc364d
commit b799e11
Showing
4 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
DELIMITER $$ | ||
|
||
DROP FUNCTION IF EXISTS `IsStatTicking` $$ | ||
|
||
CREATE FUNCTION `IsStatTicking`(`agent_name` VARCHAR(15), `stat_name` VARCHAR(20)) RETURNS tinyint(1) | ||
READS SQL DATA | ||
BEGIN | ||
|
||
RETURN | ||
(SELECT (most_recent.date - previous.date) = (most_recent.value - previous.value) | ||
FROM (SELECT date, value FROM Data WHERE agent = agent_name AND stat = stat_name ORDER BY date DESC LIMIT 1) most_recent, | ||
(SELECT date, value FROM Data WHERE agent = agent_name AND stat = stat_name ORDER BY date DESC LIMIT 1,1) previous); | ||
|
||
END $$ | ||
|
||
DELIMITER ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters