diff --git a/lib/pr_checker.js b/lib/pr_checker.js index 1c6c926..ef81328 100644 --- a/lib/pr_checker.js +++ b/lib/pr_checker.js @@ -4,11 +4,7 @@ const SECOND = 1000; const MINUTE = SECOND * 60; const HOUR = MINUTE * 60; -const SUNDAY = 0; -const SATURDAY = 6; - -const WEEKDAY_WAIT = 48; -const WEEKEND_WAIT = 72; +const WAIT_TIME = 48; const { REVIEW_SOURCES: { FROM_COMMENT, FROM_REVIEW_COMMENT } @@ -136,16 +132,11 @@ class PRChecker { */ getWait(now) { const createTime = new Date(this.pr.createdAt); - const utcDay = createTime.getUTCDay(); - // TODO: do we need to lose this a bit considering timezones? - const isWeekend = (utcDay === SUNDAY || utcDay === SATURDAY); - const waitTime = isWeekend ? WEEKEND_WAIT : WEEKDAY_WAIT; - const timeLeft = waitTime - Math.ceil( + const timeLeft = WAIT_TIME - Math.ceil( (now.getTime() - createTime.getTime()) / HOUR ); return { - isWeekend, timeLeft }; } @@ -183,8 +174,7 @@ class PRChecker { const wait = this.getWait(now); if (wait.timeLeft > 0) { const dateStr = new Date(pr.createdAt).toDateString(); - const type = wait.isWeekend ? 'weekend' : 'weekday'; - cli.info(`This PR was created on ${dateStr} (${type} in UTC)`); + cli.info(`This PR was created on ${dateStr}`); cli.warn(`Wait at least ${wait.timeLeft} more hours before landing`); return false; } diff --git a/test/unit/pr_checker.test.js b/test/unit/pr_checker.test.js index 221bb27..5a43d5f 100644 --- a/test/unit/pr_checker.test.js +++ b/test/unit/pr_checker.test.js @@ -165,44 +165,12 @@ describe('PRChecker', () => { }); describe('checkPRWait', () => { - it('should warn about PR younger than 72h on weekends', () => { - const cli = new TestCLI(); - - const expectedLogs = { - warn: [['Wait at least 49 more hours before landing']], - info: [['This PR was created on Sat Oct 28 2017 (weekend in UTC)']] - }; - - const now = new Date('2017-10-29T13:00:41.682Z'); - const youngPR = Object.assign({}, firstTimerPR, { - createdAt: '2017-10-28T14:25:41.682Z' - }); - - const data = { - pr: youngPR, - reviewers: allGreenReviewers, - comments: commentsWithLGTM, - reviews: approvingReviews, - commits: simpleCommits, - collaborators, - authorIsNew: () => true, - getThread() { - return PRData.prototype.getThread.call(this); - } - }; - const checker = new PRChecker(cli, data, argv); - - const status = checker.checkPRWait(now); - assert(!status); - cli.assertCalledWith(expectedLogs); - }); - - it('should warn about PR younger than 48h on weekdays', () => { + it('should warn about PR younger than 48h', () => { const cli = new TestCLI(); const expectedLogs = { warn: [['Wait at least 22 more hours before landing']], - info: [['This PR was created on Tue Oct 31 2017 (weekday in UTC)']] + info: [['This PR was created on Tue Oct 31 2017']] }; const now = new Date('2017-11-01T14:25:41.682Z');