Skip to content

Commit

Permalink
#233 can now set date range via universal settings
Browse files Browse the repository at this point in the history
  • Loading branch information
maerzman committed Sep 5, 2024
1 parent 14acdac commit 9ae1416
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const mapStateToProps = (state) => {
mergeRequests: mergeRequestOwnershipState.data.data.mergeRequests,
selectedAuthors: universalSettings.selectedAuthorsGlobal,
allAuthors: universalSettings.allAuthors,
firstSignificantTimestamp: mergeRequestOwnershipState.data.data.firstSignificantTimestamp,
lastSignificantTimestamp: mergeRequestOwnershipState.data.data.lastSignificantTimestamp,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { fetchFactory, timestampedActionFactory } from '../../../sagas/utils';
import Database from '../../../database/database';
import { createAction } from 'redux-actions';
import { fork, select, takeEvery } from 'redux-saga/effects';

export const setActiveVisualizations = createAction('SET_ACTIVE_VISUALIZATIONS');
export const requestMergeRequestOwnershipData = createAction('REQUEST_MERGE_REQUEST_OWNERSHIP_DATA');
Expand All @@ -13,6 +14,11 @@ export const onlyShowAuthors = createAction('SET_ONLY_SHOW_AUTHORS');

export default function* () {
yield* fetchMergeRequestOwnershipData();
yield fork(watchTimeSpan);
}

function* watchTimeSpan() {
yield takeEvery('SET_TIME_SPAN', fetchMergeRequestOwnershipData);
}

export const fetchMergeRequestOwnershipData = fetchFactory(
Expand All @@ -22,10 +28,21 @@ export const fetchMergeRequestOwnershipData = fetchFactory(
const firstMergeRequestTimestamp = Date.parse(firstMergeRequest.date);
const lastMergeRequestTimestamp = Date.parse(firstMergeRequest.date);

let firstSignificantTimestamp = firstMergeRequestTimestamp;
let lastSignificantTimestamp = lastMergeRequestTimestamp;

const state = yield select();

const timeSpan = state.universalSettings.chartTimeSpan;
firstSignificantTimestamp = timeSpan.from === undefined ? firstSignificantTimestamp : new Date(timeSpan.from).getTime();
lastSignificantTimestamp = timeSpan.to === undefined ? lastSignificantTimestamp : new Date(timeSpan.to).getTime();

console.log(firstSignificantTimestamp);

return yield Promise.resolve(
Database.getMergeRequestData(
[firstMergeRequestTimestamp, lastMergeRequestTimestamp],
[firstMergeRequestTimestamp, lastMergeRequestTimestamp],
[firstSignificantTimestamp, lastSignificantTimestamp],
),
).then((result) => {
const mergeRequests = result;
Expand Down

0 comments on commit 9ae1416

Please sign in to comment.