Project

General

Profile

« Previous | Next » 

Revision 1185

Factored verify.sql out into schemas dir

View differences:

inputs/SALVIAS/verify.sql
1
SELECT '# projects' AS ___;
2
SELECT count(*) AS count
3
FROM project
4
JOIN party ON party_id = datasource_id AND organizationname = :datasource
5
;
6

  
7
SELECT 'projects' AS ___;
8
SELECT projectname AS project
9
FROM project
10
JOIN party ON party_id = datasource_id AND organizationname = :datasource
11
ORDER BY project
12
;
13

  
14
SELECT E'each project\'s # locations' AS ___;
15
SELECT projectname AS project, count(*) AS locations_count
16
FROM project
17
JOIN party ON party_id = datasource_id AND organizationname = :datasource
18
JOIN locationevent USING (project_id)
19
GROUP BY project
20
ORDER BY project
21
;
22

  
23
SELECT '# locations' AS ___;
24
SELECT count(DISTINCT location_id) AS count
25
FROM locationevent
26
JOIN party ON party_id = datasource_id AND organizationname = :datasource
27
WHERE parent_id IS NULL -- no subplots
28
;
29

  
30
SELECT '# location events' AS ___;
31
SELECT count(*) AS count
32
FROM locationevent
33
JOIN party ON party_id = datasource_id AND organizationname = :datasource
34
AND parent_id IS NULL -- no subplots
35
;
36

  
37
SELECT '1st methods' AS ___;
38
SELECT DISTINCT
39
    projectname AS project
40
    , method.name AS method
41
FROM project
42
JOIN party ON party_id = datasource_id AND organizationname = :datasource
43
JOIN locationevent USING (project_id)
44
JOIN method USING (method_id)
45
ORDER BY project, method
46
LIMIT 10;
47

  
48
SELECT '1st observation measures' AS ___;
49
SELECT DISTINCT
50
    projectname AS project
51
    , method.observationmeasure AS observationmeasure
52
FROM project
53
JOIN party ON party_id = datasource_id AND organizationname = :datasource
54
JOIN locationevent USING (project_id)
55
JOIN method USING (method_id)
56
ORDER BY project, observationmeasure
57
LIMIT 10;
inputs/input.Makefile
34 34
# Paths
35 35
root := $(selfDir_uZPPqC)..
36 36
mappings := $(root)/mappings
37
schemas := $(root)/schemas
37 38
psqlOpts := --set ON_ERROR_STOP=1 --quiet
38 39
psqlAsBien := $(root)/bin/psql_vegbien $(psqlOpts)
39 40

  
......
159 160

  
160 161
all += verify.out
161 162

  
162
%.out: %.sql _always
163
verify.out: $(schemas)/verify.sql _always
163 164
	$(out_cmd)
164 165
.PRECIOUS: %.out
165 166
out_cmd = $(psqlAsBien) --set=datasource="'$(db)'" --no-align\
schemas/verify.sql
1
SELECT '# projects' AS ___;
2
SELECT count(*) AS count
3
FROM project
4
JOIN party ON party_id = datasource_id AND organizationname = :datasource
5
;
6

  
7
SELECT 'projects' AS ___;
8
SELECT projectname AS project
9
FROM project
10
JOIN party ON party_id = datasource_id AND organizationname = :datasource
11
ORDER BY project
12
;
13

  
14
SELECT E'each project\'s # locations' AS ___;
15
SELECT projectname AS project, count(*) AS locations_count
16
FROM project
17
JOIN party ON party_id = datasource_id AND organizationname = :datasource
18
JOIN locationevent USING (project_id)
19
GROUP BY project
20
ORDER BY project
21
;
22

  
23
SELECT '# locations' AS ___;
24
SELECT count(DISTINCT location_id) AS count
25
FROM locationevent
26
JOIN party ON party_id = datasource_id AND organizationname = :datasource
27
WHERE parent_id IS NULL -- no subplots
28
;
29

  
30
SELECT '# location events' AS ___;
31
SELECT count(*) AS count
32
FROM locationevent
33
JOIN party ON party_id = datasource_id AND organizationname = :datasource
34
AND parent_id IS NULL -- no subplots
35
;
36

  
37
SELECT '1st methods' AS ___;
38
SELECT DISTINCT
39
    projectname AS project
40
    , method.name AS method
41
FROM project
42
JOIN party ON party_id = datasource_id AND organizationname = :datasource
43
JOIN locationevent USING (project_id)
44
JOIN method USING (method_id)
45
ORDER BY project, method
46
LIMIT 10;
47

  
48
SELECT '1st observation measures' AS ___;
49
SELECT DISTINCT
50
    projectname AS project
51
    , method.observationmeasure AS observationmeasure
52
FROM project
53
JOIN party ON party_id = datasource_id AND organizationname = :datasource
54
JOIN locationevent USING (project_id)
55
JOIN method USING (method_id)
56
ORDER BY project, observationmeasure
57
LIMIT 10;

Also available in: Unified diff