Skip to content

Commit

Permalink
billed time in project progress view (#4236)
Browse files Browse the repository at this point in the history
* report billed time per project
* update snapshot tests
* Merge branch 'master' into billed-hours-project-progress-view
* added (billed) hours to project progress table
* Merge branch 'master' into billed-hours-project-progress-view
* added changelog entry
* Merge branch 'billed-hours-project-progress-view' of github.com:scalableminds/webknossos into billed-hours-project-progress-view
* only displaying 1 fraction digit of spent hours on a project
* Merge branch 'master' into billed-hours-project-progress-view
  • Loading branch information
youri-k authored and bulldozer-boy[bot] committed Aug 26, 2019
1 parent fa24ad5 commit e42abda
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- Enabled the advanced search for the comment tab. [#4238](https://github.com/scalableminds/webknossos/pull/4238)
- Added limited support for `uint64` segmentation layer by using the lower 4 bytes. [#4233](https://github.com/scalableminds/webknossos/pull/4233)
- Added an API route to add and delete dataStores. [#4242](https://github.com/scalableminds/webknossos/pull/4242)
- Added currently spent hours on a project to the project progress view. [#4236](https://github.com/scalableminds/webknossos/pull/4236)

### Changed
- Each of the columns of the dataset table and explorative annotations table in the dashboard now have an individual fixed width, so the tables become scrollable on smaller screens. [#4207](https://github.com/scalableminds/webknossos/pull/4207)
Expand Down
12 changes: 7 additions & 5 deletions app/controllers/ReportController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ case class ProjectProgressEntry(projectName: String,
totalInstances: Int,
openInstances: Int,
finishedInstances: Int,
activeInstances: Int)
activeInstances: Int,
billedMilliseconds: Long)
object ProjectProgressEntry { implicit val jsonFormat = Json.format[ProjectProgressEntry] }

class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(implicit ec: ExecutionContext)
Expand Down Expand Up @@ -67,7 +68,8 @@ class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(im
p.priority priority,
count(t._id) totalTasks,
sum(t.totalInstances) totalInstances,
sum(t.openInstances) openInstances
sum(t.openInstances) openInstances,
sum(t.tracingTime) tracingTime
from
filteredProjects p
join webknossos.tasks_ t on p._id = t._project
Expand All @@ -83,14 +85,14 @@ class ReportDAO @Inject()(sqlClient: SQLClient, annotationDAO: AnnotationDAO)(im
)


select s1.projectName, s1.paused, s1.priority, 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, s1.tracingTime
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, Long, Int, Int, Int, Int, Int)])
""".as[(String, Boolean, Long, Int, Int, Int, Int, Int, Long)])
} yield {
r.toList.map(row => ProjectProgressEntry(row._1, row._2, row._3, row._4, row._5, row._6, row._7, row._8))
r.toList.map(row => ProjectProgressEntry(row._1, row._2, row._3, row._4, row._5, row._6, row._7, row._8, row._9))
}

def getAssignmentsByProjectsFor(userId: ObjectId)(implicit ctx: DBAccessContext): Fox[Map[String, Int]] =
Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/admin/api_flow_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ export type APIProjectProgressReport = {
+activeInstances: number,
+finishedInstances: number,
+priority: number,
+billedMilliseconds: number,
};

export type APIOpenTasksReport = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ class ProjectProgressReportView extends React.PureComponent<{}, State> {
sorter={Utils.compareBy(typeHint, project => project.priority)}
render={number => number.toLocaleString()}
/>
<Column
title="Time [h]"
dataIndex="billedMilliseconds"
sorter={Utils.compareBy(typeHint, project => project.billedMilliseconds)}
render={number =>
Utils.millisecondsToHours(number).toLocaleString(undefined, {
maximumFractionDigits: 1,
})
}
width={150}
/>
<ColumnGroup title="Instances">
<Column
title="Total"
Expand Down
5 changes: 5 additions & 0 deletions frontend/javascripts/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ export function minutesToMilliseconds(min: number) {
return min * 60000;
}

export function millisecondsToHours(ms: number) {
const oneHourInMilliseconds = 1000 * 60 * 60;
return ms / oneHourInMilliseconds;
}

export function isNoElementFocussed(): boolean {
// checks whether an <input> or <button> element has the focus
// when no element is focused <body> gets the focus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Generated by [AVA](https://ava.li).
[
{
activeInstances: 1,
billedMilliseconds: 0,
finishedInstances: 0,
openInstances: 19,
paused: false,
Expand Down
Binary file not shown.

0 comments on commit e42abda

Please sign in to comment.