Skip to content

Commit

Permalink
tests pass, and also fixed data generation so the test could run prop…
Browse files Browse the repository at this point in the history
…erly :)
  • Loading branch information
yochannah committed Jan 11, 2024
1 parent acaf1f7 commit d7bbfc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ async function timeToMergePrOrIssue(config) {
}

//calculate closed/merged time if known
let createdTime = new Date(response.created_at);
let createdTime = new Date(parseInt(response.created_at, 10));

if (response.closed) {
let closedTime = new Date(response.merged_at || response.closed_at);
Expand Down Expand Up @@ -467,8 +467,10 @@ async function timeToMergePrOrIssue(config) {
function calculateMedian(anArray) {
//needs to be sorted if we want to get the middlest (median) value
if (anArray.length) {
// sometime we end up with strings, and an alphabetic string sort DOES NOT give a numeric median...
// so MAKE SURE we have numbers:
anArray = anArray.map(item => parseInt(item, 10));
anArray.sort();

let len = anArray.length,
middlePosition = len / 2,
middlestValue;
Expand Down Expand Up @@ -498,7 +500,7 @@ function calculateMean(anArray) {
// so we round it.
if (anArray.length) {
let sum = anArray.reduce(function (a, b) {
return a + b;
return parseInt(a, 10) + parseInt(b, 10);
});
return Math.round(sum / anArray.length);
} else {
Expand Down
3 changes: 2 additions & 1 deletion test/data_prep/generate_fake_pr_or_issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ function fakeIssues(howMany, isPrOrIssue, state) {
}

let isItClosed = isClosed(state,i),
closeTimeinMs = (now - closeTimes[i]).toString();
response = {
id: new Date().valueOf() +i, //this is hacky, if we ever care about ids
//right now we don't really. But be aware.
created_at: (now - closeTimes[i])+"", // simulates strings. Should be handled gracefully.
created_at: closeTimeinMs,
closed: isClosed(state,i),
pr_or_issue: prOrIssue,
}
Expand Down

0 comments on commit d7bbfc8

Please sign in to comment.