mirror of
https://github.com/reactos/developer-web-interface.git
synced 2024-11-23 03:49:43 +00:00
merging into single saga for buildbot
This commit is contained in:
parent
a89e441698
commit
e7801fc7d1
@ -8,8 +8,8 @@ import Loading from './Loading';
|
||||
|
||||
class Commits extends React.Component {
|
||||
componentDidMount() {
|
||||
this.props.loadBuildSets();
|
||||
this.props.loadCommits();
|
||||
this.props.loadBuildSets();
|
||||
}
|
||||
|
||||
renderBsid = id => {
|
||||
@ -22,10 +22,41 @@ class Commits extends React.Component {
|
||||
return obj;
|
||||
})
|
||||
.filter(item => item.sourcestamps[0].revision === commit.sha);
|
||||
let BSID = filteredBs.map(id => {
|
||||
return id.bsid;
|
||||
});
|
||||
console.log(BSID);
|
||||
if (BSID) {
|
||||
var filterBReq = [];
|
||||
BSID.forEach(val => {
|
||||
filterBReq.push(
|
||||
this.props.bsid
|
||||
.map(obj => {
|
||||
return obj;
|
||||
})
|
||||
.filter(item => item.buildsetid === val)
|
||||
);
|
||||
});
|
||||
var mergedBsID = [].concat.apply([], filterBReq);
|
||||
var filterBuild = [];
|
||||
mergedBsID.forEach(val => {
|
||||
filterBuild.push(
|
||||
this.props.build
|
||||
.map(obj => {
|
||||
return obj;
|
||||
})
|
||||
.filter(item => item.buildrequestid === val.buildrequestid)
|
||||
);
|
||||
});
|
||||
var mergedBuild = [].concat.apply([], filterBuild);
|
||||
console.log(mergedBsID);
|
||||
console.log(mergedBuild);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='panel-margin' key={commit.sha}>
|
||||
<CommitsCard commit={commit} />
|
||||
{filteredBs.map(bsid => 'buildsetid__contain=' + bsid.bsid).join('&')}
|
||||
{filteredBs.map(this.renderBsid)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@ -87,13 +118,15 @@ class Commits extends React.Component {
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
const mapStateToProps = ({ isLoading, commits, error, branch,page,buildData}) => ({
|
||||
const mapStateToProps = ({ isLoading, commits, error, branch,page,buildData,bsid,build}) => ({
|
||||
isLoading,
|
||||
commits,
|
||||
error,
|
||||
branch,
|
||||
page,
|
||||
buildData
|
||||
buildData,
|
||||
bsid,
|
||||
build
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
@ -26,6 +26,7 @@ export const fetchBuildReq = async str => {
|
||||
};
|
||||
|
||||
export const fetchBuilds = async str => {
|
||||
console.log(str);
|
||||
const response = await fetch(`/api/builds?${str}`);
|
||||
const data = await response.json();
|
||||
if (response.status >= 400) {
|
||||
|
@ -1,49 +0,0 @@
|
||||
import { takeEvery, call, select, put } from 'redux-saga/effects';
|
||||
import { COMMITS } from '../constants';
|
||||
import { fetchBuildReq } from '../api';
|
||||
import { setBuildSetsError, setBsID } from '../actions';
|
||||
const commitSha = state => state.commits;
|
||||
const buildData = state => state.buildData;
|
||||
|
||||
function matchSha(commits, buildData) {
|
||||
let cs = commits.map(commit => {
|
||||
return commit.sha;
|
||||
});
|
||||
let bs = buildData.map(builds => {
|
||||
return builds;
|
||||
});
|
||||
var filterBs = [];
|
||||
cs.forEach(val => {
|
||||
filterBs.push(
|
||||
bs
|
||||
.map(obj => {
|
||||
return obj;
|
||||
})
|
||||
.filter(item => item.sourcestamps[0].revision === val)
|
||||
);
|
||||
});
|
||||
|
||||
var merged = [].concat.apply([], filterBs);
|
||||
|
||||
let str = merged.map(bsid => 'buildsetid__contains=' + bsid.bsid).join('&');
|
||||
return str;
|
||||
}
|
||||
|
||||
function* handleBuildReqLoad() {
|
||||
try {
|
||||
const commit = yield select(commitSha);
|
||||
const build = yield select(buildData);
|
||||
var str = matchSha(commit, build);
|
||||
if (str) {
|
||||
let bsID = yield call(fetchBuildReq, str);
|
||||
yield put(setBsID(bsID));
|
||||
//console.log(bsID);
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(setBuildSetsError(error.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
export default function* watchBuildsLoad() {
|
||||
yield takeEvery(COMMITS.LOAD_SUCCESS, handleBuildReqLoad);
|
||||
}
|
@ -1,16 +1,72 @@
|
||||
import { takeEvery, call, put } from 'redux-saga/effects';
|
||||
import { BUILD_DATA } from '../constants';
|
||||
import { fetchBuildSets } from '../api';
|
||||
import { setBuildSets, setBuildSetsError } from '../actions';
|
||||
import { takeEvery, call, put, select } from 'redux-saga/effects';
|
||||
import { COMMITS } from '../constants';
|
||||
import { fetchBuildSets, fetchBuildReq, fetchBuilds } from '../api';
|
||||
import {
|
||||
setBuildSets,
|
||||
setBuildSetsError,
|
||||
setBsID,
|
||||
setBuilds
|
||||
} from '../actions';
|
||||
|
||||
const commitSha = state => state.commits;
|
||||
const buildData = state => state.buildData;
|
||||
const bsid = state => state.bsid;
|
||||
|
||||
function buildStr(build) {
|
||||
let str = build
|
||||
.map(build => 'buildrequestid__contains=' + build.buildrequestid)
|
||||
.join('&');
|
||||
return str;
|
||||
}
|
||||
|
||||
function matchSha(commits, buildData) {
|
||||
let cs = commits.map(commit => {
|
||||
return commit.sha;
|
||||
});
|
||||
let bs = buildData.map(builds => {
|
||||
return builds;
|
||||
});
|
||||
var filterBs = [];
|
||||
cs.forEach(val => {
|
||||
filterBs.push(
|
||||
bs
|
||||
.map(obj => {
|
||||
return obj;
|
||||
})
|
||||
.filter(item => item.sourcestamps[0].revision === val)
|
||||
);
|
||||
});
|
||||
// console.log(filterBs);
|
||||
|
||||
var merged = [].concat.apply([], filterBs);
|
||||
//console.log(merged);
|
||||
let str = merged.map(bsid => 'buildsetid__contains=' + bsid.bsid).join('&');
|
||||
return str;
|
||||
}
|
||||
|
||||
function* handleBuildsLoad() {
|
||||
try {
|
||||
const buildSets = yield call(fetchBuildSets);
|
||||
yield put(setBuildSets(buildSets));
|
||||
const commit = yield select(commitSha);
|
||||
const build = yield select(buildData);
|
||||
var str = matchSha(commit, build);
|
||||
if (str) {
|
||||
let bsID = yield call(fetchBuildReq, str);
|
||||
yield put(setBsID(bsID));
|
||||
//console.log(bsID);
|
||||
}
|
||||
const build1 = yield select(bsid);
|
||||
var str1 = buildStr(build1);
|
||||
if (str1) {
|
||||
let build2 = yield call(fetchBuilds, str1);
|
||||
yield put(setBuilds(build2));
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(setBuildSetsError(error.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
export default function* watchBuildsLoad() {
|
||||
yield takeEvery(BUILD_DATA.LOAD, handleBuildsLoad);
|
||||
yield takeEvery(COMMITS.LOAD_SUCCESS, handleBuildsLoad);
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
import { takeEvery, call, select, put } from 'redux-saga/effects';
|
||||
import { fetchBuilds } from '../api';
|
||||
import { setBuildSetsError, setBuilds } from '../actions';
|
||||
const bsid = state => state.bsid;
|
||||
|
||||
function buildStr(build) {
|
||||
let str = build
|
||||
.map(build => 'buildrequestid__contains=' + build.buildrequestid)
|
||||
.join('&');
|
||||
return str;
|
||||
}
|
||||
|
||||
function* handleBuildsLoad() {
|
||||
try {
|
||||
const build = yield select(bsid);
|
||||
var str = buildStr(build);
|
||||
if (str) {
|
||||
let build = yield call(fetchBuilds, str);
|
||||
yield put(setBuilds(build));
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(setBuildSetsError(error.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
export default function* watchBuildsLoad() {
|
||||
yield takeEvery('BUILD_SET_ID_SUCCESS', handleBuildsLoad);
|
||||
}
|
@ -4,16 +4,7 @@ import commitsSaga from './commitsSaga';
|
||||
import branchesSaga from './branchesSaga';
|
||||
import pullsSaga from './pullsSaga';
|
||||
import buildSetSaga from './buildSetSaga';
|
||||
import buildReqSaga from './buildReqSaga';
|
||||
import buildsSaga from './buildsSaga';
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield all([
|
||||
commitsSaga(),
|
||||
branchesSaga(),
|
||||
pullsSaga(),
|
||||
buildSetSaga(),
|
||||
buildReqSaga(),
|
||||
buildsSaga()
|
||||
]);
|
||||
yield all([commitsSaga(), branchesSaga(), pullsSaga(), buildSetSaga()]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user