Commit 3890099e authored by Christoph Häfner's avatar Christoph Häfner

Code format process reducer

parent 554d11c8
Pipeline #506 passed with stages
in 10 minutes and 37 seconds
......@@ -4,10 +4,11 @@ import {
START_EMPTY_PROCESS,
START_COMPARISON_PROCESS,
UPDATE_COMPARISON_PROCESS,
FINISH_COMPARISON_PROCESS } from './actions'
FINISH_COMPARISON_PROCESS
} from './actions'
export default (state = {}, action) => {
switch(action.type) {
switch (action.type) {
case START_EMPTY_PROCESS:
case START_COMPARISON_PROCESS:
case UPDATE_COMPARISON_PROCESS:
......@@ -20,41 +21,41 @@ export default (state = {}, action) => {
}
};
const ratingProcess = reducer({finished: false}, {
[START_COMPARISON_PROCESS]: (state, action) => {
const ratingProcess = reducer({ finished: false }, {
[START_COMPARISON_PROCESS]: (state, action) => {
const R = action.payload.personalMovieListLength;
return Object.assign({}, state, {
L: 0,
R: R,
m: Math.floor((R)/2),
m: Math.floor((R) / 2),
movieFromCollection: action.payload.chosenMovie
});
},
[UPDATE_COMPARISON_PROCESS]: (state, action) => {
return Object.assign({}, iterateBinarySearch(
state.L, state.R, state.m,
action.payload.comparisonWonByMovieFromCollection
), {
state.L, state.R, state.m,
action.payload.comparisonWonByMovieFromCollection
), {
movieFromCollection: state.movieFromCollection
}
);
},
[FINISH_COMPARISON_PROCESS]: () => {}
},
[FINISH_COMPARISON_PROCESS]: () => { }
});
const iterateBinarySearch = (L, R, m, comparisonResult) => {
let l = L,
r = R;
if(comparisonResult) {
if (comparisonResult) {
r = m;
} else {
l = m+1;
l = m + 1;
}
const nextM = Math.floor((l+r)/2);
const nextM = Math.floor((l + r) / 2);
if(l === r) {
if (l === r) {
return {
finished: true,
result: l
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment