diff --git a/client/app/project/project-dashboard.html b/client/app/project/project-dashboard.html index fa6c0d94cf..c91eefd2b3 100644 --- a/client/app/project/project-dashboard.html +++ b/client/app/project/project-dashboard.html @@ -105,7 +105,8 @@

Task Completion

{{ ' Total Tasks' | translate }}: {{ projectDashboardCtrl.project.totalTasks }} | {{ 'Tasks Mapped' | translate }}: {{ projectDashboardCtrl.project.tasksMapped }} | - {{ ' Tasks Validated' | translate }}: {{ projectDashboardCtrl.project.tasksValidated }} + {{ ' Tasks Validated' | translate }}: {{ projectDashboardCtrl.project.tasksValidated }} | + {{ ' Bad Imagery' | translate }}: {{ projectDashboardCtrl.project.tasksBadImagery }}
{{ projectDashboardCtrl.project.percentMapped }}{{ '% Mapped' | translate }} diff --git a/client/index.html b/client/index.html index 0833d3fa72..97bd8c9e83 100644 --- a/client/index.html +++ b/client/index.html @@ -265,6 +265,8 @@

+ + diff --git a/server/models/dtos/project_dto.py b/server/models/dtos/project_dto.py index b3572094e1..4898a50928 100644 --- a/server/models/dtos/project_dto.py +++ b/server/models/dtos/project_dto.py @@ -318,6 +318,7 @@ class ProjectStatsDTO(Model): aoi_centroid = BaseType(serialized_name='aoiCentroid') tasks_mapped = IntType(serialized_name='tasksMapped') tasks_validated = IntType(serialized_name='tasksValidated') + tasks_bad_imagery = IntType(serialized_name='tasksBadImagery') area_percent_mapped = IntType(serialized_name='areaPercentMapped') area_percent_validated = IntType(serialized_name='areaPercentValidated') diff --git a/server/models/postgis/project.py b/server/models/postgis/project.py index c02ad6f639..59f3645951 100644 --- a/server/models/postgis/project.py +++ b/server/models/postgis/project.py @@ -428,6 +428,23 @@ def get_validated_area(project_id: int): result.close() return area or 0 + def get_bad_imagery_area(project_id: int): + """ Get all tasks that are marked as bad imagery """ + sql = '''SELECT sum(ST_Area(geom)) + FROM ( + SELECT t.geometry :: geometry geom + FROM tasks t + WHERE t.project_id = :project_id AND t.task_status = 6) sub; + ''' + + result = db.engine.execute(text(sql), project_id=project_id) + if result.rowcount == 0: + raise NotFound() + + area = result.next()[0] + result.close() + return area or 0 + def get_project_stats(self) -> ProjectStatsDTO: """ Create Project Summary model for postgis project object""" project_stats = ProjectStatsDTO() @@ -448,6 +465,7 @@ def get_project_stats(self) -> ProjectStatsDTO: project_stats.total_tasks = self.total_tasks project_stats.tasks_mapped = self.tasks_mapped + self.tasks_validated project_stats.tasks_validated = self.tasks_validated + project_stats.tasks_bad_imagery = self.tasks_bad_imagery project_stats.total_comments = db.session.query(ProjectChat).filter(ProjectChat.project_id == self.id).count() project_stats.percent_mapped = Project.calculate_tasks_percent('mapped', self.total_tasks, self.tasks_mapped, self.tasks_validated, @@ -501,8 +519,8 @@ def get_project_stats(self) -> ProjectStatsDTO: project_stats.average_validation_time = average_validation_time # Calculate area_percent_complete to get completion percentage by state according to area - project_stats.area_percent_mapped = int((Project.get_mapped_area(self.id) / polygon.area) * 100) - project_stats.area_percent_validated = int((Project.get_validated_area(self.id) / polygon.area) * 100) + project_stats.area_percent_mapped = int((Project.get_mapped_area(self.id) / (polygon.area - Project.get_bad_imagery_area(self.id))) * 100) + project_stats.area_percent_validated = int((Project.get_validated_area(self.id) / (polygon.area - Project.get_bad_imagery_area(self.id))) * 100) return project_stats