Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Make time errors more explicit when setting the ":next" Testday #77

Conversation

xabolcs
Copy link
Contributor

@xabolcs xabolcs commented Feb 18, 2015

Fix for #74.

@xabolcs
Copy link
Contributor Author

xabolcs commented Feb 18, 2015

Example talk with my testdaybot named xabolcs_tdb:

[23:46:38]  xabolcs :next
[23:46:39]  xabolcs_tdb Need some help? :next <start as YYYY-MM-DDThh:mmZ> <end as YYYY-MM-DDThh:mmZ> <etherpad> <topic>: set next Test Day
[23:49:41]  xabolcs :next 2014-12-13T23:30Z 2013-12-13T23:45Z etherpad topic
[23:49:41]  xabolcs_tdb Please use valid dates.
[23:49:41]  xabolcs_tdb Start time was set after End time.
[23:50:09]  xabolcs :next 2014-12-13T23:30Z 2014-12-13T23:45Z etherpad topic
[23:50:10]  xabolcs_tdb Please use valid dates.
[23:50:10]  xabolcs_tdb Start time is set in the past.
[23:50:29]  xabolcs :next 2015-12-13T23:30Z 2014-12-13T23:45Z etherpad topic
[23:50:30]  xabolcs_tdb Please use valid dates.
[23:50:30]  xabolcs_tdb Start time was set after End time.
[23:50:35]  xabolcs :next 2015-12-13T23:30Z 2015-12-13T23:45Z etherpad topic
[23:50:36]  xabolcs_tdb Next Test Day's start is Sun, 13 Dec 2015 23:30:00 GMT
[23:50:36]  xabolcs_tdb Next Test Day's end is Sun, 13 Dec 2015 23:45:00 GMT
[23:50:36]  xabolcs_tdb Next Test Day's etherpad is etherpad
[23:50:36]  xabolcs_tdb Next Test Day's topic is topic

@xabolcs
Copy link
Contributor Author

xabolcs commented Feb 18, 2015

Interestingly there was a message in the channel after setting up a test day. Was it expected?

[23:50:36]  xabolcs_tdb The topic testday starts now. For details, see etherpad

@@ -418,6 +418,11 @@ client.addListener('pm', function(from, message) { // private messages to bot
client.say(from, "Next Test Day's topic is " + testDay.topic);
} else {
client.say(from, "Please use valid dates.");
if (testDay.end < testDay.start) {
client.say(from, "Start time was set after End time.");
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other option here is using if to print all errors at once.

@whimboo, should I go that way? Currently only one error is printed.

An advanced solution would be to count all the errors and print a it like "Your specified a time interval which has the following 2 errors: the start time is after end time, the start time is in the past."

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a string variable for the client.say call in line 420, and then just combine the text for the individual error message like "Please use valid dates: %error%". That way we also only send a single message to the user.

I don't think the extended logic is that more helpful right now. Personally I would move those sanity checks for times up before line 410, so we do not have to check for the dates twice but return early.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would move those sanity checks for times up before line 410, so we do not have to check for the dates twice but return early.

I happily do this move in this PR, should I?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be perfect.

@xabolcs
Copy link
Contributor Author

xabolcs commented Feb 22, 2015

This is ready to review!

@xabolcs
Copy link
Contributor Author

xabolcs commented Feb 28, 2015

Pushed commits to PR's branch including 45f4fc9.
Ready to review.

Please see the following conversation!


URL     ircs://moznet/xabolcs_tdb,isnick    Connected via   fripp.mozilla.org
Conversation with xabolcs_tdb <nodebot@moz-fci6nk.catv.broadband.hu>
nodeJS IRC client
xabolcs_tdb
[13:54:06]  [INFO]  Messages Cleared.
[13:54:11]  xabolcs :next
[13:54:12]  xabolcs_tdb Need some help? :next <start as YYYY-MM-DDThh:mmZ> <end as YYYY-MM-DDThh:mmZ> <etherpad> <topic>: set next Test Day
[13:55:46]  xabolcs :next 2014-03-04T11:00Z 2014-03-04T11:30Z https://etherpad.location.url TestDayBot Test Day
[13:55:46]  xabolcs_tdb Please use valid dates: start time is set in the past.
[13:56:01]  xabolcs :next 2014-03-04T11:00Z 2014-03-04T10:30Z https://etherpad.location.url TestDayBot Test Day
[13:56:02]  xabolcs_tdb Please use valid dates: start time is set after End time, start time is set in the past.
[13:56:24]  xabolcs :next 2015-03-04T11:00Z 2014-03-04T10:30Z https://etherpad.location.url TestDayBot Test Day
[13:56:24]  xabolcs_tdb Please use valid dates: start time is set after End time.
[13:56:43]  xabolcs :next 2015-03-04T11:00Z 2015-03-04T11:30Z https://etherpad.location.url TestDayBot Test Day
[13:56:43]  xabolcs_tdb Next Test Day's start is Wed, 04 Mar 2015 11:00:00 GMT
[13:56:43]  xabolcs_tdb Next Test Day's end is Wed, 04 Mar 2015 11:30:00 GMT
[13:56:43]  xabolcs_tdb Next Test Day's etherpad is https://etherpad.location.url
[13:56:43]  xabolcs_tdb Next Test Day's topic is TestDayBot Test Day

if (timerID !== 0) {
clearTimeout(timerID);
}
testDay.start = new Date(command[1]);
testDay.end = new Date(command[2]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, these should be startTime and endTime.

@xabolcs
Copy link
Contributor Author

xabolcs commented Mar 2, 2015

This is ready to review!

testDay.topic = command.slice(4, cmdLen).join(" ");
// if the start and end dates appear valid, set the test date
if ((testDay.end > testDay.start) && (testDay.start > Date.now())) {
var startTime, endTime, dateErrors = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not declare multiple variables in a single line. So move the declaration for startTime and endTime to the lines 406 and 407.

@xabolcs
Copy link
Contributor Author

xabolcs commented Mar 10, 2015

This is ready to review up to commit b14a8a0.

@whimboo
Copy link
Contributor

whimboo commented Mar 10, 2015

This looks fine! I got it merged as 5a749f9. Thanks for your contribution.

@whimboo whimboo closed this Mar 10, 2015
@xabolcs xabolcs deleted the branch-issue-74-next-more-explicit-errors branch March 10, 2015 08:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants