Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Ignore edits to issues predating the bot #13460

Merged
merged 3 commits into from
Nov 2, 2017

Conversation

strugee
Copy link
Contributor

@strugee strugee commented Nov 2, 2017

No description provided.

@strugee
Copy link
Contributor Author

strugee commented Nov 2, 2017

Should fix the scenario described in #10843 (comment).

@strugee
Copy link
Contributor Author

strugee commented Nov 2, 2017

/cc @Hainish @koops76

@@ -20,6 +20,13 @@ module.exports = function(robot, alexa) {
return;
}

const createdAt = new Date(context.payload.issue.created_at);
// September 25th, 2017
if (createdAt.getFullYear() <= 2017 && createdAt.getMonth() <= 8 && createdAt.getDate() <= 25) {
Copy link
Member

Choose a reason for hiding this comment

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

This conditional will fail for an issue created in September, 2016.

Copy link
Member

Choose a reason for hiding this comment

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

The cleanest way to do this without a long conditional is probably formatted string comparison. Munge createdAt into YYYY-MM-DD format, then compare it to "2017-08-25"

Copy link

Choose a reason for hiding this comment

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

Can't we compare Dates directly, or at least by conversion to timestamps?

Copy link

Choose a reason for hiding this comment

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

@Hainish Better way is to compare dates directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Hainish nice catch. Will push a fix based on #13460 (comment)

@@ -20,6 +20,13 @@ module.exports = function(robot, alexa) {
return;
}

const createdAt = new Date(context.payload.issue.created_at);
// September 25th, 2017
if (createdAt.getFullYear() <= 2017 && createdAt.getMonth() <= 8 && createdAt.getDate() <= 25) {
Copy link

@ghost ghost Nov 2, 2017

Choose a reason for hiding this comment

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

const botCreatedDate = new Date(2017, 10, 25)
if (createdAt <= botCreatedDate) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thanks! I had no idea you could compare Dates like this; I was gonna compare Unix timestamps.

@strugee strugee force-pushed the fix-date-ignore-code branch from b6232e9 to 1fb5445 Compare November 2, 2017 18:52
@strugee
Copy link
Contributor Author

strugee commented Nov 2, 2017

Fixed the date comparison and rebased on master.

@strugee
Copy link
Contributor Author

strugee commented Nov 2, 2017

Also pushed an unrelated test suite improvement that didn't seem worth sending a separate PR for.

@strugee strugee mentioned this pull request Nov 2, 2017
3 tasks
@Hainish Hainish merged commit d3ced54 into EFForg:master Nov 2, 2017
@strugee strugee deleted the fix-date-ignore-code branch November 2, 2017 23:19
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