Skip to content

Commit

Permalink
(Backend only) Add project priority to progress report json (#3476)
Browse files Browse the repository at this point in the history
* add project priority to progress report json

* new snapshots (priority in progress report)
  • Loading branch information
fm3 authored Nov 21, 2018
1 parent 3494850 commit 4d291e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Generated by [AVA](https://ava.li).
finishedInstances: 0,
openInstances: 19,
paused: false,
priority: 100,
projectName: 'Test_Project',
totalInstances: 20,
totalTasks: 2,
Expand Down
Binary file not shown.
14 changes: 8 additions & 6 deletions app/controllers/ReportController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ object OpenTasksEntry { implicit val jsonFormat = Json.format[OpenTasksEntry] }

case class ProjectProgressEntry(projectName: String,
paused: Boolean,
priority: Long,
totalTasks: Int,
totalInstances: Int,
openInstances: Int,
Expand All @@ -40,7 +41,7 @@ class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(im
JOIN webknossos.user_experiences ue on ue._user = u._user
)

,filteredProjects as (select p._id, p.name, p.paused
,filteredProjects as (select p._id, p.name, p.paused, p.priority
from
webknossos.projects_ p
JOIN webknossos.tasks_ t ON t._project = p._id
Expand All @@ -49,7 +50,7 @@ class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(im
t.neededExperience_domain = ue.domain and
t.neededExperience_value <= ue.value and
not p.isblacklistedfromreport
group by p._id, p.name, p.paused)
group by p._id, p.name, p.paused, p.priority)

,projectModifiedTimes as (select p._id, MAX(a.modified) as modified
from
Expand All @@ -63,13 +64,14 @@ class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(im
p._id,
p.name projectName,
p.paused paused,
p.priority priority,
count(t._id) totalTasks,
sum(t.totalInstances) totalInstances,
sum(t.openInstances) openInstances
from
filteredProjects p
join webknossos.tasks_ t on p._id = t._project
group by p._id, p.name, p.paused)
group by p._id, p.name, p.paused, p.priority)

,s2 as (select p._id,
count(a) activeInstances
Expand All @@ -81,14 +83,14 @@ class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(im
)


select s1.projectName, s1.paused, s1.totalTasks, s1.totalInstances, s1.openInstances, (s1.totalInstances - s1.openInstances - s2.activeInstances) finishedInstances, s2.activeInstances
select s1.projectName, s1.paused, s1.priority, s1.totalTasks, s1.totalInstances, s1.openInstances, (s1.totalInstances - s1.openInstances - s2.activeInstances) finishedInstances, s2.activeInstances
from s1
join s2 on s1._id = s2._id
join projectModifiedTimes pmt on s1._id = pmt._id
where (not (s1.paused and s1.totalInstances = s1.openInstances)) and ((s1.openInstances > 0 and not s1.paused) or s2.activeInstances > 0 or pmt.modified > NOW() - INTERVAL '30 days')
""".as[(String, Boolean, Int, Int, Int, Int, Int)])
""".as[(String, Boolean, Long, Int, Int, Int, Int, Int)])
} yield {
r.toList.map(row => ProjectProgressEntry(row._1, row._2, row._3, row._4, row._5, row._6, row._7))
r.toList.map(row => ProjectProgressEntry(row._1, row._2, row._3, row._4, row._5, row._6, row._7, row._8))
}

def getAssignmentsByProjectsFor(userId: ObjectId)(implicit ctx: DBAccessContext): Fox[Map[String, Int]] =
Expand Down

0 comments on commit 4d291e1

Please sign in to comment.