-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#38: add timeline navigation functionality
- Loading branch information
Showing
9 changed files
with
166 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
ui/src/visualizations/team-awareness/components/Timeline/ActivityTimeline.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
import StackedAreaChart from '../../../../components/StackedAreaChart'; | ||
import _ from 'lodash'; | ||
|
||
export default class ActivityTimeline extends StackedAreaChart { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
shouldComponentUpdate(nextProps, nextState, nextContext) { | ||
const zoomedChanged = this.state.zoomed !== nextState.zoomed; | ||
const zoomDimsDifference = _.difference(this.state.zoomedDims, nextState.zoomedDims); | ||
const { onDimensionsRestricted } = this.props; | ||
|
||
if (zoomedChanged || zoomDimsDifference.length > 0) { | ||
onDimensionsRestricted({ | ||
activityRestricted: nextState.zoomed, | ||
activityDims: nextState.zoomedDims | ||
}); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
ui/src/visualizations/team-awareness/sagas/calculateFigures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { put, select } from 'redux-saga/effects'; | ||
import { processTeamAwarenessData } from './index'; | ||
import { getState } from '../util/util'; | ||
|
||
export default function*() { | ||
const appState = yield select(); | ||
yield put(processTeamAwarenessData(processData(appState))); | ||
} | ||
|
||
function processData(appState) { | ||
const vizState = getState(appState); | ||
|
||
/** @type {Map<number, any>} */ | ||
const stakeholders = new Map(); | ||
|
||
/** @type {Map<string, any>} */ | ||
const activities = new Map(); | ||
|
||
const dataBoundaries = { | ||
min: Number.MAX_SAFE_INTEGER, | ||
max: Number.MIN_SAFE_INTEGER | ||
}; | ||
|
||
let activityCalculator = calculateActivity; | ||
if (vizState.config.activityRestricted === true) { | ||
const from = Date.parse(vizState.config.activityDims[0]); | ||
const to = Date.parse(vizState.config.activityDims[1]); | ||
activityCalculator = filterCommit(from, to, calculateActivity); | ||
} | ||
|
||
vizState.data.data.commits.forEach(c => { | ||
const calculatedActivity = activityCalculator(c); | ||
if (calculatedActivity !== 0) { | ||
if (!stakeholders.has(c.stakeholder.id)) { | ||
stakeholders.set(c.stakeholder.id, { | ||
id: c.stakeholder.id, | ||
signature: c.stakeholder.gitSignature, | ||
name: c.stakeholder.id, | ||
activity: 0 | ||
}); | ||
} | ||
const dateString = c.date.substring(0, 10); | ||
|
||
const dateParsed = Date.parse(c.date); | ||
if (!activities.has(dateString)) { | ||
activities.set(dateString, { | ||
date: dateParsed, | ||
activity: 0 | ||
}); | ||
} | ||
|
||
const stakeholder = stakeholders.get(c.stakeholder.id); | ||
stakeholder.activity += calculatedActivity; | ||
|
||
const current = activities.get(dateString); | ||
current.activity += calculatedActivity; | ||
updateBoundaries(dataBoundaries, current.activity); | ||
} | ||
}); | ||
|
||
return { | ||
stakeholders: Array.from(stakeholders.values()), | ||
activityTimeline: Array.from(activities.values()), | ||
dataBoundaries | ||
}; | ||
} | ||
|
||
function updateBoundaries(boundaries, value) { | ||
if (value < boundaries.min) { | ||
boundaries.min = value; | ||
} | ||
if (value > boundaries.max) { | ||
boundaries.max = value; | ||
} | ||
} | ||
|
||
/** | ||
* @param from {number} | ||
* @param to {number} | ||
* @param fn {function} | ||
* @return {function(*): number} | ||
*/ | ||
function filterCommit(from, to, fn) { | ||
return commit => { | ||
const parsedDate = Date.parse(commit.date); | ||
if (from <= parsedDate && parsedDate <= to) { | ||
return fn(commit); | ||
} | ||
return 0; | ||
}; | ||
} | ||
|
||
function calculateActivity() { | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters