Skip to content

Commit

Permalink
All days results should be on same line
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwalley committed Nov 12, 2016
1 parent ba3ecec commit c0b20ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,21 +872,29 @@ export function read_tg(input) {

for (let j = 1; j < m.length; j++) {
if (m[j].indexOf('#') !== 0) {
event.results.push(m[j]);
Array.prototype.push.apply(event.results, m[j].split(' '));
}
}
} else {
for (let j = 0; j < m.length; j++) {
if (inresults === 1 && m[j].indexOf('#') !== 0) {
event.results.push(m[j]);
Array.prototype.push.apply(event.results, m[j].split(' '));
} else if (indivision === 1) {
addcrew(curdiv, m[j]);
}
}
}
}

event.results = event.results.filter(r => r !== '').map(r => r.trim()).join('\n');
const results = [];

for (let i = 0; i < event.days; i++) {
results.push([]);
}

event.results.filter(r => r !== '').map((r, i) => results[Math.floor(i / event.divisions.length)].push(r.trim()));

event.results = results.map(r => r.join(' ')).join('\n');

if (curdiv.length > 0) {
event.divisions.push(curdiv);
Expand Down
12 changes: 9 additions & 3 deletions test/bumps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ Division,Cantabs 2,City 2\n\
Division,Champs 1\n\
\n\
Results\n\
r ur rrrrr\n\
r ur ro3u\n\
r ru urrr\n';
r\n\
ur\n\
rrrrr\n\
r\n\
ur\n\
ro3u\n\
r\n\
ru\n\
urrr\n';

var expected = {
completed: [[true, true, true], [true, true, true], [true, true, true]],
Expand Down

0 comments on commit c0b20ec

Please sign in to comment.