Skip to content

Commit e36da7b

Browse files
committed
add data
1 parent d4d4fa1 commit e36da7b

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

mapswipe_workers/mapswipe_workers/generate_stats/project_stats.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@ def get_tasks(filename: str, project_id: str) -> pd.DataFrame:
118118

119119
sql_query = sql.SQL(
120120
"""
121-
COPY (
122-
SELECT project_id, group_id, task_id, ST_AsText(geom) as geom
123-
FROM tasks
124-
WHERE project_id = {}
125-
) TO STDOUT WITH CSV HEADER
121+
COPY (
122+
SELECT project_id, group_id, task_id, ST_AsText(geom) as geom,
123+
(project_type_specifics->'properties'->'osmId')::text as osmId,
124+
(project_type_specifics->'properties'->'changesetId')::text::int as changesetId,
125+
(project_type_specifics->'properties'->'version')::text::smallint as version,
126+
(project_type_specifics->'properties'->'userid')::text::int as userid,
127+
(project_type_specifics->'properties'->'username')::text as username,
128+
(project_type_specifics->'properties'->'editor')::text as editor,
129+
(project_type_specifics->'properties'->'comment')::text as comment,
130+
(project_type_specifics->'properties'->'lastEdit')::text::timestamp as lastEdit
131+
FROM tasks
132+
WHERE project_id = {}
133+
) TO STDOUT WITH CSV HEADER
126134
"""
127135
).format(sql.Literal(project_id))
128136
write_sql_to_gzipped_csv(filename, sql_query)
@@ -304,7 +312,22 @@ def get_agg_results_by_task_id(
304312

305313
# add task geometry using left join
306314
agg_results_df = results_by_task_id_df.merge(
307-
tasks_df[["geom", "task_id"]], left_on="task_id", right_on="task_id"
315+
tasks_df[
316+
[
317+
"geom",
318+
"task_id",
319+
"osmId",
320+
"changesetId",
321+
"version",
322+
"userid",
323+
"username",
324+
"editor",
325+
"comment",
326+
"lastEdit",
327+
]
328+
],
329+
left_on="task_id",
330+
right_on="task_id",
308331
)
309332
logger.info("added geometry to aggregated results")
310333

0 commit comments

Comments
 (0)