Skip to content

Commit

Permalink
#59: Getting data from database, connected via reducers now works
Browse files Browse the repository at this point in the history
  • Loading branch information
profjellybean committed Nov 27, 2022
1 parent 3ac6407 commit c9250ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 54 deletions.
13 changes: 10 additions & 3 deletions ui/src/visualizations/legacy/file-tree-comparison/reducers/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import _ from 'lodash';

export default handleActions(
{
REQUEST_CHANGES_DATA: (state) => _.assign({}, state, { isFetching: true }),
RECEIVE_CHANGES_DATA: (state, action) => {
REQUEST_COMMITS_AND_FILE_TREE: (state) => _.assign({}, state, { isFetching: true }),
RECEIVE_COMMITS_AND_FILE_TREE: (state, action) => {
return _.assign({}, state, {
data: action.payload,
isFetching: false,
Expand All @@ -15,7 +15,14 @@ export default handleActions(
},
},
{
data: {},
data: [
{
commits: [],
tree: [],
commit1: [],
commit2: [],
},
],
lastFetched: null,
isFetching: null,
}
Expand Down
57 changes: 6 additions & 51 deletions ui/src/visualizations/legacy/file-tree-comparison/sagas/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';

import { fetchFactory, mapSaga, timestampedActionFactory } from '../../../../sagas/utils';
import { fetchFactory, timestampedActionFactory } from '../../../../sagas/utils';
import { createAction } from 'redux-actions';
import Database from '../../../../database/database';
import { graphQl } from '../../../../utils';

export const requestCommitsAndFileTree = createAction('REQUEST_COMMITS_AND_FILE_TREE');
export const receiveCommitsAndFileTree = timestampedActionFactory('RECEIVE_COMMITS_AND_FILE_TREE');
export const receiveCommitsAndFileTreeError = createAction('RECEIVE_COMMITS_AND_FILE_TREE_ERROR');
export const setCommit1 = createAction('SET_COMMIT_1', (f) => f);
export const setCommit2 = createAction('SET_COMMIT_2', (f) => f);

export default function* () {
// fetch data once on entry
Expand All @@ -22,58 +23,13 @@ export const fetchFileTreeEvolutionData = fetchFactory(
const lastCommitTimestamp = Date.parse(lastCommit.date);

const commits = yield Database.getCommitData([firstCommitTimestamp, lastCommitTimestamp], [firstCommitTimestamp, lastCommitTimestamp]); //COMMITS

const fileTree = yield Database.requestFileStructure();
const hierarchicalFileTree = makeHierarchyFileTree(fileTree); //FILETREE



const hierarchicalFileTree = makeHierarchyFileTree(fileTree); //file-tree
//console.log(yield Database.searchCommits('Bug')); //search commits

return { commits, hierarchicalFileTree };

return yield graphQl //TODO replace with my query, get changes by certain commit
.query(
`{
commits(sort: "ASC") {
data {
date
message
files {
data {
stats {
additions
deletions
}
file {
path,
}
lineCount
}
}
}
}
}`
)
.then((resp) => {
const commitsWithFileTree = [];

for (const commit of resp.commits.data) {
//const fileTree = makeHierarchyFileTreee(commit);
//const commitWithFileTree = [commit, fileTree];
//commitsWithFileTree.push(commitWithFileTree);
//fileTree = applyCommit(fileTree, commit);
//fileTreeHistory.push(fileTree);
}
return {
commitsWithFileTree,

//fileTreeHistory,
//commits: resp.commits.data
};
});
return { commits: commits, tree: hierarchicalFileTree };
},
requestCommitsAndFileTree, //LOGGER
requestCommitsAndFileTree,
receiveCommitsAndFileTree,
receiveCommitsAndFileTreeError
);
Expand All @@ -88,7 +44,6 @@ function makeHierarchyFileTree(fileTree) {
r[name] = { result: [] };
r.result.push({ name, children: r[name].result });
}

return r[name];
}, level);
});
Expand Down

0 comments on commit c9250ff

Please sign in to comment.