Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

billed time in project progress view #4236

Merged
merged 9 commits into from
Aug 26, 2019
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- The segmentation layer can now be turned invisible and also supports the find data feature. [#4232](https://github.com/scalableminds/webknossos/pull/4232)
- 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 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 @@ -126,6 +126,13 @@ 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()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toLocaleString seems to show up to three decimal places by default. Although the original request was to floor this number, I see a benefit in seeing a decimal place. Three may be a bit too much, but you can supply some options to toLocaleString, I'd go with 1 or 2: .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.