Skip to content

Commit 74a7743

Browse files
authored
Merge pull request #1038 from mapswipe/feature/validate-image-proj
Feature: validate image project
2 parents 8f663c7 + 1371c5d commit 74a7743

File tree

43 files changed

+1626
-122
lines changed

Some content is hidden

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

43 files changed

+1626
-122
lines changed

.github/workflows/actions.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,28 @@ jobs:
4242
exit 1;
4343
}
4444
45+
- name: Decrypt Service Account Key File
46+
working-directory: ./
47+
run: |
48+
openssl enc -aes-256-cbc -d -K "$OPENSSL_KEY" -iv "$OPENSSL_IV" -in ci-mapswipe-firebase-adminsdk-80fzw-ebce84bd5b.json.enc -out mapswipe_workers/serviceAccountKey.json
49+
env:
50+
OPENSSL_PASSPHRASE: ${{ secrets.OPENSSL_PASSPHRASE }}
51+
OPENSSL_KEY: ${{ secrets.OPENSSL_KEY }}
52+
OPENSSL_IV: ${{ secrets.OPENSSL_IV }}
53+
54+
- name: Build docker images
55+
run: |
56+
# Create a mock file for wal-g setup
57+
touch postgres/serviceAccountKey.json
58+
docker compose build postgres firebase_deploy mapswipe_workers_creation django
59+
4560
- name: Setup Postgres Database Container
4661
env:
4762
POSTGRES_PASSWORD: postgres
4863
POSTGRES_USER: postgres
4964
POSTGRES_DB: postgres
5065
run: |
51-
# Create a mock file for wal-g setup
52-
touch postgres/serviceAccountKey.json
53-
docker compose up --build --detach postgres
66+
docker compose up --detach postgres
5467
for i in {1..5}; do docker compose exec -T postgres pg_isready && s=0 && break || s=$? && sleep 5; done; (docker compose logs postgres && exit $s)
5568
5669
- name: Deploy Firebase Rules and Functions
@@ -60,15 +73,6 @@ jobs:
6073
run: |
6174
docker compose run --rm firebase_deploy sh -c "firebase use $FIREBASE_DB && firebase deploy --token $FIREBASE_TOKEN --only database"
6275
63-
- name: Decrypt Service Account Key File
64-
working-directory: ./
65-
run: |
66-
openssl enc -aes-256-cbc -d -K "$OPENSSL_KEY" -iv "$OPENSSL_IV" -in ci-mapswipe-firebase-adminsdk-80fzw-ebce84bd5b.json.enc -out mapswipe_workers/serviceAccountKey.json
67-
env:
68-
OPENSSL_PASSPHRASE: ${{ secrets.OPENSSL_PASSPHRASE }}
69-
OPENSSL_KEY: ${{ secrets.OPENSSL_KEY }}
70-
OPENSSL_IV: ${{ secrets.OPENSSL_IV }}
71-
7276
- name: Run Tests
7377
working-directory: ./mapswipe_workers
7478
env:
Lines changed: 13 additions & 0 deletions
Loading

community-dashboard/app/views/StatsBoard/index.tsx

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ import InformationCard from '#components/InformationCard';
4343
import areaSvg from '#resources/icons/area.svg';
4444
import sceneSvg from '#resources/icons/scene.svg';
4545
import featureSvg from '#resources/icons/feature.svg';
46+
import validateImageSvg from '#resources/icons/validate-image.svg';
4647
import {
4748
ContributorTimeStatType,
4849
OrganizationSwipeStatsType,
4950
ProjectTypeSwipeStatsType,
5051
ProjectTypeAreaStatsType,
5152
ContributorSwipeStatType,
53+
ProjectTypeEnum,
5254
} from '#generated/types';
5355
import { mergeItems } from '#utils/common';
5456
import {
@@ -67,17 +69,28 @@ const CHART_BREAKPOINT = 700;
6769
export type ActualContributorTimeStatType = ContributorTimeStatType & { totalSwipeTime: number };
6870
const UNKNOWN = '-1';
6971
const BUILD_AREA = 'BUILD_AREA';
72+
const MEDIA = 'MEDIA';
73+
const DIGITIZATION = 'DIGITIZATION';
7074
const FOOTPRINT = 'FOOTPRINT';
7175
const CHANGE_DETECTION = 'CHANGE_DETECTION';
76+
const VALIDATE_IMAGE = 'VALIDATE_IMAGE';
7277
const COMPLETENESS = 'COMPLETENESS';
7378
const STREET = 'STREET';
7479

7580
// FIXME: the name property is not used properly
76-
const projectTypes: Record<string, { color: string, name: string }> = {
81+
const projectTypes: Record<ProjectTypeEnum | '-1', { color: string, name: string }> = {
7782
[UNKNOWN]: {
7883
color: '#cacaca',
7984
name: 'Unknown',
8085
},
86+
[MEDIA]: {
87+
color: '#cacaca',
88+
name: 'Media',
89+
},
90+
[DIGITIZATION]: {
91+
color: '#cacaca',
92+
name: 'Digitization',
93+
},
8194
[BUILD_AREA]: {
8295
color: '#f8a769',
8396
name: 'Find',
@@ -94,6 +107,10 @@ const projectTypes: Record<string, { color: string, name: string }> = {
94107
color: '#fb8072',
95108
name: 'Completeness',
96109
},
110+
[VALIDATE_IMAGE]: {
111+
color: '#a1b963',
112+
name: 'Validate Image',
113+
},
97114
[STREET]: {
98115
color: '#808080',
99116
name: 'Street',
@@ -376,14 +393,16 @@ function StatsBoard(props: Props) {
376393
const sortedProjectSwipeType = useMemo(
377394
() => (
378395
swipeByProjectType
379-
?.map((item) => ({
380-
...item,
381-
projectType: (
382-
isDefined(item.projectType)
383-
&& isDefined(projectTypes[item.projectType])
384-
) ? item.projectType
385-
: UNKNOWN,
386-
}))
396+
?.map((item) => {
397+
const projectType: ProjectTypeEnum | '-1' = (
398+
isDefined(item.projectType) && isDefined(projectTypes[item.projectType])
399+
) ? item.projectType : UNKNOWN;
400+
401+
return ({
402+
...item,
403+
projectType,
404+
});
405+
})
387406
.sort((a, b) => compareNumber(a.totalSwipes, b.totalSwipes, -1)) ?? []
388407
),
389408
[swipeByProjectType],
@@ -449,6 +468,10 @@ function StatsBoard(props: Props) {
449468
(project) => project.projectType === FOOTPRINT,
450469
)?.totalSwipes;
451470

471+
const validateImageTotalSwipes = swipeByProjectType?.find(
472+
(project) => project.projectType === VALIDATE_IMAGE,
473+
)?.totalSwipes;
474+
452475
const organizationColors = scaleOrdinal<string, string | undefined>()
453476
.domain(totalSwipesByOrganizationStats?.map(
454477
(organization) => (organization.organizationName),
@@ -699,6 +722,29 @@ function StatsBoard(props: Props) {
699722
subHeading="Compare"
700723
variant="stat"
701724
/>
725+
<InformationCard
726+
icon={(
727+
<img
728+
src={validateImageSvg}
729+
alt="group icon"
730+
/>
731+
)}
732+
value={(
733+
<NumberOutput
734+
className={styles.numberOutput}
735+
value={validateImageTotalSwipes}
736+
normal
737+
invalidText={0}
738+
/>
739+
)}
740+
label={(
741+
<div className={styles.infoLabel}>
742+
Images Validated
743+
</div>
744+
)}
745+
subHeading="Validate Image"
746+
variant="stat"
747+
/>
702748
</div>
703749
<div className={styles.overallStatsContainer}>
704750
<InformationCard

community-dashboard/app/views/StatsBoard/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
>* {
6868
flex-basis: 0;
6969
flex-grow: 1;
70-
min-width: 12rem;
70+
min-width: 24rem;
7171

7272
@media (max-width: 48rem) {
7373
min-width: 100%;

community-dashboard/docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ version: '3.3'
22

33
services:
44
react:
5-
build: .
65
command: sh -c 'yarn install --frozen-lockfile && yarn start'
76
build:
87
context: ./
@@ -15,4 +14,4 @@ services:
1514
volumes:
1615
- .:/code
1716
ports:
18-
- '3080:3080'
17+
- '3081:3081'

django/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-buster
1+
FROM python:3.10-bullseye
22

33
LABEL maintainer="Mapswipe info@mapswipe.org"
44

django/apps/aggregated/management/commands/update_aggregated_data.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
WHEN P.project_type = {Project.Type.CHANGE_DETECTION.value} THEN 11.2
5656
-- FOOTPRINT: Not calculated right now
5757
WHEN P.project_type = {Project.Type.FOOTPRINT.value} THEN 6.1
58+
WHEN P.project_type = {Project.Type.VALIDATE_IMAGE.value} THEN 6.1
5859
WHEN P.project_type = {Project.Type.STREET.value} THEN 65
5960
ELSE 1
6061
END
@@ -111,6 +112,7 @@
111112
WHEN P.project_type = {Project.Type.CHANGE_DETECTION.value} THEN 11.2
112113
-- FOOTPRINT: Not calculated right now
113114
WHEN P.project_type = {Project.Type.FOOTPRINT.value} THEN 6.1
115+
WHEN P.project_type = {Project.Type.VALIDATE_IMAGE.value} THEN 6.1
114116
WHEN P.project_type = {Project.Type.STREET.value} THEN 65
115117
ELSE 1
116118
END
@@ -136,8 +138,10 @@
136138
G.group_id,
137139
(
138140
CASE
139-
-- Hide area for Footprint
141+
-- Hide area for Footprint and Validate Image
142+
-- FIXME: What should we do for Project.Type.STREET.value
140143
WHEN P.project_type = {Project.Type.FOOTPRINT.value} THEN 0
144+
WHEN P.project_type = {Project.Type.VALIDATE_IMAGE.value} THEN 0
141145
ELSE G.total_area
142146
END
143147
) as total_task_group_area,

django/apps/existing_database/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Type(models.IntegerChoices):
6969
MEDIA = 5, "Media"
7070
DIGITIZATION = 6, "Digitization"
7171
STREET = 7, "Street"
72+
VALIDATE_IMAGE = 10, "Validate Image"
7273

7374
project_id = models.CharField(primary_key=True, max_length=999)
7475
created = models.DateTimeField(blank=True, null=True)

django/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ enum ProjectTypeEnum {
100100
MEDIA
101101
DIGITIZATION
102102
STREET
103+
VALIDATE_IMAGE
103104
}
104105

105106
type ProjectTypeSwipeStatsType {

docker-compose.tc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ x-mapswipe-workers: &base_mapswipe_workers
3333
SLACK_CHANNEL: '${SLACK_CHANNEL}'
3434
SENTRY_DSN: '${SENTRY_DSN}'
3535
OSMCHA_API_KEY: '${OSMCHA_API_KEY}'
36+
MAPILLARY_API_KEY: '${MAPILLARY_API_KEY}'
3637
depends_on:
3738
- postgres
3839
volumes:

0 commit comments

Comments
 (0)