-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,550 additions
and
1,408 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
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,13 @@ | ||
Notes: | ||
1) Branch/country level summarisation to be done in front end (by summing up the locations) | ||
2) Row and column totals in each grid done by the front end | ||
|
||
Proposed development path | ||
1) Currently only week based summarisation, as that is what UKBMS want. Expand to allow Month based summarisation | ||
2) Allow >1 summarisation per survey | ||
3) Currently deals with super/subsample with locations, as that is what UKBMS want. Expand to handle other cases. | ||
4) Amalgamation of raw data into a daily summary. Would need to store sample list. | ||
5) Make 0-1 rounding configurable | ||
6) Configurable end of year processing: Include data for overlap, include periods that overlap | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
65 changes: 65 additions & 0 deletions
65
modules/summary_builder/db/version_2_29_0/201903091200_tables.sql
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,65 @@ | ||
|
||
|
||
DROP VIEW IF EXISTS gv_summariser_definitions; | ||
DROP VIEW IF EXISTS list_summariser_definitions; | ||
|
||
ALTER TABLE summariser_definitions | ||
DROP COLUMN check_for_missing, | ||
DROP COLUMN max_records_per_cycle; | ||
|
||
CREATE VIEW gv_summariser_definitions AS | ||
SELECT s.id as survey_id, s.title, w.title AS website, s.website_id, sd.id | ||
FROM summariser_definitions sd | ||
LEFT JOIN surveys s ON sd.survey_id = s.id AND s.deleted = FALSE | ||
LEFT JOIN websites w ON s.website_id = w.id AND w.deleted = FALSE | ||
WHERE sd.survey_id = s.id AND sd.deleted = false; | ||
|
||
CREATE VIEW list_summariser_definitions AS | ||
SELECT s.website_id, sd.id, sd.survey_id, sd.period_type, sd.period_start, sd.period_one_contains, sd.calculate_estimates | ||
FROM summariser_definitions sd | ||
JOIN surveys s ON sd.survey_id = s.id AND s.deleted = FALSE | ||
JOIN websites w ON s.website_id = w.id AND w.deleted = FALSE | ||
WHERE sd.survey_id = s.id AND sd.deleted = false; | ||
|
||
DROP VIEW IF EXISTS list_summary_occurrences; | ||
|
||
DROP TABLE summary_occurrences; | ||
|
||
CREATE TABLE summary_occurrences | ||
( | ||
website_id INTEGER NOT NULL, | ||
survey_id INTEGER NOT NULL, | ||
location_id INTEGER NOT NULL, | ||
user_id INTEGER NOT NULL, | ||
year INTEGER NOT NULL, | ||
type CHARACTER VARYING NOT NULL, | ||
taxon_list_id INTEGER NOT NULL, | ||
taxa_taxon_list_id INTEGER NOT NULL, | ||
preferred_taxa_taxon_list_id INTEGER NOT NULL, | ||
taxonomic_sort_order bigint, | ||
taxon CHARACTER VARYING, | ||
preferred_taxon CHARACTER VARYING, | ||
default_common_name CHARACTER VARYING, | ||
taxon_meaning_id INTEGER NOT NULL, | ||
summarised_data JSON, | ||
created_by_id INTEGER NOT NULL, | ||
summary_created_on timestamp without time zone NOT NULL | ||
) WITH ( | ||
OIDS --- want oids as no pk. | ||
); | ||
CREATE INDEX ix_summary_occurrences_STLU ON summary_occurrences USING btree (survey_id, year, taxa_taxon_list_id, location_id, user_id); | ||
CREATE INDEX ix_summary_occurrences_STU ON summary_occurrences USING btree (survey_id, taxa_taxon_list_id, user_id); | ||
|
||
CREATE OR REPLACE VIEW list_summary_occurrences AS | ||
SELECT website_id, survey_id, | ||
year, location_id, user_id, type, | ||
taxa_taxon_list_id, preferred_taxa_taxon_list_id, taxonomic_sort_order, | ||
taxon, preferred_taxon, default_common_name, taxon_meaning_id, taxon_list_id, | ||
created_by_id, summary_created_on, summarised_data | ||
FROM summary_occurrences; | ||
|
||
COMMENT ON TABLE summary_occurrences IS 'Summary of occurrence data used for reporting.'; | ||
COMMENT ON COLUMN summary_occurrences.location_id IS 'Summary data location id, zero if for all locations.'; | ||
COMMENT ON COLUMN summary_occurrences.user_id IS 'ID of user who created the data summarised in this record, zero if for all users.'; | ||
COMMENT ON COLUMN summary_occurrences.type IS 'summariser_definition period type.'; | ||
|
13 changes: 13 additions & 0 deletions
13
modules/summary_builder/db/version_2_29_0/201903091201_work_queue.sql
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,13 @@ | ||
-- #slow script# | ||
|
||
-- trigger a rebuild of the entire data table, using the the work queue. | ||
|
||
DELETE FROM work_queue WHERE task='task_summary_builder_sample'; | ||
|
||
INSERT INTO work_queue (task, entity, record_id, priority, cost_estimate, created_on) | ||
SELECT DISTINCT 'task_summary_builder_sample', 'sample', id, 2, 50, now() | ||
FROM samples | ||
WHERE deleted=false | ||
AND parent_id IS NULL | ||
AND survey_id IN (SELECT survey_id FROM summariser_definitions WHERE deleted = false) | ||
ORDER BY date desc; |
Oops, something went wrong.