Skip to content

Commit 221fe1e

Browse files
committed
adjust get results function in generate stats to check for missing usernames
1 parent 0162825 commit 221fe1e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

mapswipe_workers/mapswipe_workers/generate_stats/project_stats.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ def get_results(filename: str, project_id: str) -> pd.DataFrame:
112112
ms.start_time,
113113
ms.end_time,
114114
msr.result,
115-
U.username
115+
-- the username for users which login to MapSwipe with their
116+
-- OSM account is not defined or ''.
117+
-- We capture this here as it will cause problems
118+
-- for the user stats generation.
119+
CASE
120+
WHEN U.username IS NULL or U.username = '' THEN 'unknown'
121+
ELSE U.username
122+
END as username
116123
FROM mapping_sessions_results msr
117124
LEFT JOIN mapping_sessions ms ON
118125
ms.mapping_session_id = msr.mapping_session_id

mapswipe_workers/tests/readme.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can extract the data into csv files like this. Make sure to adjust the where
2727
where
2828
project_id = '-NFNr55R_LYJvxP7wmte'
2929
and group_id in ('g101', 'g102', 'g103', 'g104', 'g105', 'g106', 'g107', 'g108', 'g109' )
30-
) to 'test_groups.csv' delimiter E'\t' NULL '\N' cs
30+
) to 'test_groups.csv' delimiter E'\t' NULL '\N' csv
3131
```
3232

3333
```
@@ -36,7 +36,7 @@ You can extract the data into csv files like this. Make sure to adjust the where
3636
where
3737
project_id = '-NFNr55R_LYJvxP7wmte'
3838
and group_id in ('g101', 'g102', 'g103', 'g104', 'g105', 'g106', 'g107', 'g108', 'g109' )
39-
) to 'test_tasks.csv' delimiter E'\t' csv
39+
) to 'test_tasks.csv' delimiter E'\t' NULL '\N' csv
4040
```
4141

4242
These 3 tables contain a column in json format. When exporting this into a csv file there is an issue with the quotes, which prevents us from importing the csv file correctly into the test database. Hence you need to adjust the quotes manually in the csv file.
@@ -46,12 +46,14 @@ These 3 tables contain a column in json format. When exporting this into a csv f
4646
* hit enter, then do the same with the second command: `%s/""/"/g` (it's a search/replace expression, like sed, :%s/thing_to_search/repalcement/g)
4747
* save with `:w` for (write) and quit with `:q`
4848

49+
* for the projects file make sure to check if there is no unwanted line break in the csv file.
50+
4951
```
5052
\copy (
5153
select * from mapping_sessions ms
5254
where project_id = '-NFNr55R_LYJvxP7wmte'
5355
and group_id in ('g101', 'g102', 'g103', 'g104', 'g105', 'g106', 'g107', 'g108', 'g109' )
54-
) to 'test_mapping_sessions.csv' delimiter E'\t' csv
56+
) to 'test_mapping_sessions.csv' delimiter E'\t' NULL '\N' csv
5557
```
5658

5759
```
@@ -61,7 +63,7 @@ These 3 tables contain a column in json format. When exporting this into a csv f
6163
where
6264
ms.project_id = '-NFNr55R_LYJvxP7wmte'
6365
and group_id in ('g101', 'g102', 'g103', 'g104', 'g105', 'g106', 'g107', 'g108', 'g109' )
64-
) to 'test_mapping_sessions_results.csv' delimiter E'\t' csv
66+
) to 'test_mapping_sessions_results.csv' delimiter E'\t' NULL '\N' csv
6567
```
6668

6769
```

0 commit comments

Comments
 (0)