Skip to content

Commit 6d93da5

Browse files
author
matthias_schaub
committed
Merge branch 'dev' into docs
2 parents 2d7e4c9 + 655db3a commit 6d93da5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2587
-1465
lines changed

docker-compose.yaml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ services:
5353
context: mapswipe_workers/
5454
depends_on:
5555
- postgres
56-
command: mapswipe_workers --verbose run --schedule m
56+
command: mapswipe_workers --verbose run --schedule m --only_new_results
5757
volumes:
5858
- ./api-data:/var/lib/mapswipe_workers/api-data/:rw
59-
- ./api-data/agg_res_by_task_id:/var/lib/mapswipe_workers/api-data/agg_res_by_task_id:rw
60-
- ./api-data/agg_res_by_project_id_and_date:/var/lib/mapswipe_workers/api-data/agg_res_by_project_id_and_date:rw
61-
- ./api-data/agg_progress_by_project_id_and_date:/var/lib/mapswipe_workers/api-data/agg_progress_by_project_id_and_date:rw
62-
- ./api-data/agg_res_by_user_id_and_date:/var/lib/mapswipe_workers/api-data/agg_res_by_user_id_and_date:rw
63-
restart: unless-stopped
59+
- ./api-data/agg_results:/var/lib/mapswipe_workers/api-data/agg_results:rw
60+
- ./api-data/groups:/var/lib/mapswipe_workers/api-data/groups:rw
61+
- ./api-data/history:/var/lib/mapswipe_workers/api-data/history:rw
62+
- ./api-data/projects:/var/lib/mapswipe_workers/api-data/projects:rw
63+
- ./api-data/results:/var/lib/mapswipe_workers/api-data/results:rw
64+
- ./api-data/tasks:/var/lib/mapswipe_workers/api-data/tasks:rw
65+
restart: "no"
6466
networks:
6567
- mapswipe_workers
6668
- postgres
@@ -70,38 +72,37 @@ services:
7072
build:
7173
context: postgres/
7274
environment:
73-
POSTGERS_PASSWORD: '${POSTGRES_PASSWORD}'
75+
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
7476
POSTGRES_USER: 'mapswipe_workers'
7577
POSTGRES_DB: 'mapswipe'
78+
PGDATA: '/var/lib/postgresql/mapswipe'
7679
WALG_GS_PREFIX: '${WALG_GS_PREFIX}'
7780
GOOGLE_APPLICATION_CREDENTIALS: '/serviceAccountKey.json'
7881
# Set options for WAL-G (backup tool)
7982
command: postgres -c archive_mode=on -c archive_timeout=60 -c archive_command="/archive_command.sh %p"
8083
volumes:
81-
- ./postgres-data:/var/lib/postgresql/data
84+
- ./postgres-data:/var/lib/postgresql/mapswipe
8285
restart: unless-stopped
8386
ports:
8487
- "5432:5432"
8588
networks:
8689
- postgres
8790

88-
postgres_restore_backup:
89-
container_name: postgres_restore_backup
91+
postgres_recovery:
92+
container_name: postgres_recovery
9093
build:
91-
context: postgres/
92-
dockerfile: Dockerfile-restore_backup
93-
args:
94-
WALG_GS_PREFIX: '${WALG_GS_PREFIX}'
95-
GOOGLE_APPLICATION_CREDENTIALS: '/serviceAccountKey.json'
94+
context: postgres/recovery/
9695
environment:
9796
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
9897
POSTGRES_USER: 'mapswipe_workers'
9998
POSTGRES_DB: 'mapswipe'
100-
command: postgres
99+
PGDATA: '/var/lib/postgresql/mapswipe'
100+
WALG_GS_PREFIX: '${WALG_GS_PREFIX}'
101+
GOOGLE_APPLICATION_CREDENTIALS: '/serviceAccountKey.json'
101102
volumes:
102-
- ./postgres-data:/var/lib/postgresql/restored_cluster
103+
- ./pgdata_restored:/var/lib/postgresql/mapswipe
103104
ports:
104-
- "5432:5432"
105+
- "5445:5432"
105106

106107
firebase_deploy:
107108
container_name: firebase_deploy

docs/source/cli.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ This document describes how to use the command line interface of MapSwipe Worker
44

55
In our current deployment setup the commands of the MapSwipe Workers CLI are hard-coded in the Docker-Compose File.
66

7+
You can run these commands also using docker-compose:
8+
```
9+
docker-compose run mapswipe_workers mapswipe_workers --help
10+
```
11+
712

813
```
914
Usage: mapswipe_workers [OPTIONS] COMMAND [ARGS]...
@@ -56,8 +61,26 @@ Usage: mapswipe_workers generate-stats [OPTIONS]
5661
Options:
5762
-s, --schedule [m|h|d] Generate stats every 10 minutes (m), every hour (h)
5863
or every day (d).
59-
--only_new_results Generate stats for all projects or only for those
60-
updated or with new results.
64+
--project_id_list TEXT provide project id strings as a list stats will be
65+
generated only for these projects.
66+
Use it like '["project_a", "project_b"]'
67+
--help Show this message and exit.
68+
```
69+
70+
## Generate Statistics for all projects
71+
72+
Ideally you run this using a separate docker container. e.g. like this:
73+
74+
```
75+
docker-compose run mapswipe_workers mapswipe_workers generate-stats-all-projects
76+
```
77+
78+
```
79+
Usage: mapswipe_workers generate-stats-all-projects [OPTIONS]
80+
81+
Options:
82+
-s, --schedule [m|h|d] Generate stats every 10 minutes (m), every hour (h)
83+
or every day (d).
6184
--help Show this message and exit.
6285
```
6386

firebase/functions/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ exports.counter = functions.database.ref('/v2/results/{projectId}/{groupId}/{use
1919
const promises = []
2020
const result = snapshot.after.val()
2121

22+
// if result ref does not contain all required attributes we don't updated counters
23+
// e.g. due to some error when uploading from client
24+
if (!result.hasOwnProperty('results')) {
25+
console.log('no results attribute for /v2/results/'+context.params.projectId+'/'+context.params.groupId+'/'+context.params.userId )
26+
console.log('will not update counters')
27+
return null
28+
} else if (!result.hasOwnProperty('timestamp')) {
29+
console.log('no timestamp attribute for /v2/results/'+context.params.projectId+'/'+context.params.groupId+'/'+context.params.userId )
30+
console.log('will not update counters')
31+
return null
32+
} else if (!result.hasOwnProperty('endTime')) {
33+
console.log('no endTime attribute for /v2/results/'+context.params.projectId+'/'+context.params.groupId+'/'+context.params.userId )
34+
console.log('will not update counters')
35+
return null
36+
} else if (!result.hasOwnProperty('startTime')) {
37+
console.log('no startTime attribute for /v2/results/'+context.params.projectId+'/'+context.params.groupId+'/'+context.params.userId )
38+
console.log('will not update counters')
39+
return null
40+
}
41+
42+
2243
// Firebase Realtime Database references
2344
const groupFinishedCountRef = admin.database().ref('/v2/groups/'+context.params.projectId+'/'+context.params.groupId+'/finishedCount')
2445
const groupRequiredCountRef = admin.database().ref('/v2/groups/'+context.params.projectId+'/'+context.params.groupId+'/requiredCount')

manager_dashboard/manager_dashboard/create.html

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,24 @@
2222
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
2323
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
2424
<link type="text/css" rel="stylesheet" href="css/mapswipe.css" />
25+
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
26+
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
27+
crossorigin=""/>
28+
<!-- Make sure you put this AFTER Leaflet's CSS -->
29+
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
30+
integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
31+
crossorigin=""></script>
32+
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
33+
34+
<script
35+
src="https://browser.sentry-cdn.com/5.7.1/bundle.min.js"
36+
integrity="sha384-KMv6bBTABABhv0NI+rVWly6PIRvdippFEgjpKyxUcpEmDWZTkDOiueL5xW+cztZZ"
37+
crossorigin="anonymous"></script>
38+
<script>
39+
Sentry.init({ dsn: 'https://[email protected]/1788403' });
40+
</script>
2541
</head>
26-
<body>
42+
<body onload="initMap()">
2743

2844
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
2945
<a class="navbar-brand" href="index.html">
@@ -74,10 +90,30 @@ <h3>Basic Project Information</h3>
7490

7591
<form class="form-style-7">
7692
<ul>
93+
<li>
94+
<label for="projectTopic">Project Topic</label>
95+
<input type="text" name="projectTopic" id="projectTopic" maxlength="50" required>
96+
<span>Enter the topic of your project (50 chars max).</span>
97+
</li>
98+
<li>
99+
<label for="projectRegion">Project Region</label>
100+
<input type="text" name="projectRegion" id="projectRegion" maxlength="50" required>
101+
<span>Enter name of your project Region (50 chars max).</span>
102+
</li>
103+
<li>
104+
<label for="projectNumber">Project Number</label>
105+
<input type="number" name="projectNumber" id="projectNumber" min="1" value="1">
106+
<span>Is this project part of a bigger campaign with multiple projects?</span>
107+
</li>
108+
<li>
109+
<label for="requestingOrganisation">Requesting Organisation</label>
110+
<input type="text" name="requestingOrganisation" id="requestingOrganisation" maxlength="100" required>
111+
<span>Which group, institution or community is requesting this project.</span>
112+
</li>
77113
<li>
78114
<label for="name">Name</label>
79-
<input type="text" name="name" id="name" maxlength="25" required>
80-
<span>Enter the name of your project (25 chars max).</span>
115+
<p id="name"></br>[projectTopic] - [projectRegion](taskNumber)<br>[requesting organisation]</p>
116+
<span>We will generate you project name based on your inputs above.</span>
81117
</li>
82118
<li>
83119
<label for="lookFor">Look For</label>
@@ -113,7 +149,7 @@ <h3>Basic Project Information</h3>
113149
</li>
114150
<li>
115151
<label for="groupSize">Group Size</label>
116-
<input type="number" name="groupSize" id="groupSize" value="50" min="10" max="200">
152+
<input type="number" name="groupSize" id="groupSize" value="120" min="10" max="200">
117153
<span>How big should a mapping session be? Group size refers to the number of tasks per mapping session.</span>
118154
</li>
119155
<li></li>
@@ -136,8 +172,10 @@ <h3>Project Type Specific Information</h3>
136172
<label for="geometry">GeoJSON File</label>
137173
<!-- <textarea name="geometry" id="geometry" onkeyup="adjust_textarea(this)"></textarea> -->
138174
<input type="file" accept=".GeoJSON" id="geometry" onchange='openFile(event)'>
175+
<div id="geometryMap"></div>
176+
<p id="geometryInfo"></p>
139177
<p id="geometryContent"></p>
140-
<span>Upload your project area as GeoJSON File. Make sure that you provide a single polygon geometry.</span>
178+
<span>Upload your project area as GeoJSON File (max. 2.5MB). Make sure that you provide a single polygon geometry.</span>
141179
</li>
142180
<li>
143181
<label for="tileServerBuildArea">Tile Server Name</label>
@@ -161,7 +199,7 @@ <h3>Project Type Specific Information</h3>
161199
</li>
162200
<li id="tileServerCreditsFieldBuildArea">
163201
<label for="tileServerCreditsFieldBuildArea">Imagery Credits</label>
164-
<input type="text" name="tileServerCreditsBuildArea" id="tileServerCreditsBuildArea">
202+
<input type="text" name="tileServerCreditsBuildArea" id="tileServerCreditsBuildArea" value="© 2019 Microsoft Corporation, Earthstar Geographics SIO">
165203
<span>Insert appropriate imagery credits. E.g. for Bing: "© 2019 Microsoft Corporation, Earthstar Geographics SIO"</span>
166204
</li>
167205
<li>
@@ -209,7 +247,7 @@ <h3>Project Type Specific Information</h3>
209247
</li>
210248
<li id="tileServerCreditsFieldFootprint">
211249
<label for="tileServerCreditsFieldFootprint">Imagery Credits</label>
212-
<input type="text" name="tileServerCreditsFootprint" id="tileServerCreditsFootprint">
250+
<input type="text" name="tileServerCreditsFootprint" id="tileServerCreditsFootprint" value="© 2019 Microsoft Corporation, Earthstar Geographics SIO">
213251
<span>Insert appropriate imagery credits. E.g. for Bing: "© 2019 Microsoft Corporation, Earthstar Geographics SIO"</span>
214252
</li>
215253
<li>
@@ -229,8 +267,10 @@ <h3>Project Type Specific Information</h3>
229267
<label for="geometry">GeoJSON File</label>
230268
<!-- <textarea name="geometry" id="geometry" onkeyup="adjust_textarea(this)"></textarea> -->
231269
<input type="file" accept=".GeoJSON" id="geometryChangeDetection" onchange='openFile(event)'>
270+
<div id="geometryChangeDetectionMap"></div>
271+
<p id="geometryChangeDetectionInfo"></p>
232272
<p id="geometryChangeDetectionContent"></p>
233-
<span>Upload your project area as GeoJSON File. Make sure that you provide a single polygon geometry.</span>
273+
<span>Upload your project area as GeoJSON File (max. 2.5MB). Make sure that you provide a single polygon geometry.</span>
234274
</li>
235275
<h4>Tile Server A</h4>
236276
<li>

manager_dashboard/manager_dashboard/css/mapswipe.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,6 @@
132132
background: #6B9FFF;
133133
color:#fff;
134134
}
135+
136+
#geometryMap { height: 300px; width: 100%}
137+
#geometryChangeDetectionMap { height: 300px; width: 100%}

manager_dashboard/manager_dashboard/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
2222
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
2323
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
24+
25+
<script
26+
src="https://browser.sentry-cdn.com/5.7.1/bundle.min.js"
27+
integrity="sha384-KMv6bBTABABhv0NI+rVWly6PIRvdippFEgjpKyxUcpEmDWZTkDOiueL5xW+cztZZ"
28+
crossorigin="anonymous"></script>
29+
<script>
30+
Sentry.init({ dsn: 'https://[email protected]/1788403' });
31+
</script>
32+
2433
</head>
2534
<body>
2635

0 commit comments

Comments
 (0)