/* NOTES
================================================================================
Git Repo: https://git.abbether.net/return-to-ritherdon/ritherdon-charts
Project:  https://www.nicolaellisandritherdon.com/

This file is part of the Ritherdon Charts repository ('Git Repo' link above).
The repository does not include the SQLite database used by this file. The 
reason why is because I did not want to include a 500MB database in the 
repository.

The main aim of this file is to extract the data from the database and export it
as CSV files. From there, those CSV file can be process into smaller more 
manageable files on (below) average spec'd computers. So, this file is probably
going to be useless for you but I (Craig) needed a place to put this file.
The project's repository seemed like the most appropriate place.

The database contains the Light Meter readings (two in total) recorded by the
'Personal Flash' artworks during the 'No Gaps in the Line' art exhibition
('Project' link above).
*/

-- LIGHT METER 1
-- =============================================================================

-- Gets all the readings for Light Meter 1 in the database.
-- The exhibiton ('No Gaps in the Line') ran betwen 13th June 2021 and 1st August 2021.
-- DO NOT ALTER THIS STATEMENT. USE THE ONE BELOW FOR INSPECTING DATE RANGES.
SELECT
	time,
	reading
FROM
	meter1
WHERE
	time BETWEEN DATETIME('2021-06-13') AND DATETIME('2021-08-01');

-- Gets readings between two dates for Light Meter 1 in the database.
-- USE THIS TO EXPLORE READINGS FROM A PARTICULAR DATE RANGE.
SELECT
	time,
	reading
FROM
	meter1
WHERE
-- NOTE: SET SECOND DATETIME TO DAY AFTER TO GET READINGS FOR SINGLE DAY.
-- =============================================================================
-- BETWEEN DATETIME('2021-06-13') AND DATETIME('2021-06-14') gets all the 
-- readings for the 13th June 2021.
	time BETWEEN DATETIME('2021-06-13') AND DATETIME('2021-06-14');

-- Gets all readings which were above 0, recorded by Light Meter 1.
SELECT
	time,
	reading
FROM
	meter1
WHERE
	reading > 0;

-- Gets all readings which were below or equal to 0, recorded by Light Meter 1.
-- This equates to welding booth having no light source active in them.
SELECT
	time,
	reading
FROM
	meter1
WHERE
	reading =< 0;

-- LIGHT METER 2
-- =============================================================================

-- Gets all the readings for Light Meter 2 in the database.
-- The exhibiton ('No Gaps in the Line') ran betwen 13th June 2021 & 1st August 2021.
-- DO NOT ALTER THIS STATEMENT. USE THE ONE BELOW FOR INSPECTING DATE RANGES.
SELECT
	time,
	reading
FROM
	meter2
WHERE
	time BETWEEN DATETIME('2021-06-13') AND DATETIME('2021-08-01');
	
-- Gets readings between two dates for Light Meter 2 in the database.
-- USE THIS TO EXPLORE READINGS FROM A PARTICULAR DATE RANGE.
SELECT
	time,
	reading
FROM
	meter2
WHERE
-- NOTE: SET SECOND DATETIME TO DAY AFTER TO GET READINGS FOR SINGLE DAY.
-- =============================================================================
-- BETWEEN DATETIME('2021-06-13') AND DATETIME('2021-06-14') gets all the 
-- readings for the 13th June 2021.
	time BETWEEN DATETIME('2021-06-13') AND DATETIME('2021-06-14');
	
-- Gets all readings which were above 0, recorded by Light Meter 2.
SELECT
	time,
	reading
FROM
	meter2
WHERE
	reading > 0;

-- Gets all readings which were below or equal to 0, recorded by Light Meter 2.
-- This equates to welding booth 2 having no light source active in them.
SELECT
	time,
	reading
FROM
	meter2
WHERE
	reading =< 0;