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

Move the checks of users existence and activity to hubot-routines #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ya7on
Copy link
Contributor

@ya7on ya7on commented Jan 28, 2019

close #158
close #161

Please make sure all below checkboxes in the Mandatory section have been checked before submitting your PR (also don't forget to pay attention to the Depending on Circumstances section)

Mandatory

  • The commit message is an imperative and starts with a capital letter (for example, Add something, Remove something, Fix something, etc.).
  • I made sure I hadn't put a period at the end of the the commit message(s).

Depending on Circumstances

Some of the items in the section become mandatory if you are a first-time contributor and/or your changes are relevant to the items.

  • Adding a new parameter I didn't forget to reflect it in README.md.
  • Modifying a list of constants or imports I didn't brake an alphabetical order.
  • (for first-time contributors) One of the commits in the pull request adds me to the Acknowledgements section in AUTHORS.md.

@ya7on ya7on changed the title Refactor isUserActive [WIP] Refactor isUserActive Jan 28, 2019
@ya7on ya7on force-pushed the user-active-list branch 2 times, most recently from 21ac052 to b800b89 Compare January 30, 2019 13:26
@ya7on ya7on changed the title [WIP] Refactor isUserActive Move the checks of users existence and activity to hubot-routines Feb 6, 2019
src/birthder.js Outdated
const username = msg.message.user.name
const user = Object.values(brain).filter(item => item.name === username).shift()
const user = (await routines.getAllUsers(robot)).filter(item => item.name === username).shift()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you should use findUserByName instead.

src/birthder.js Outdated
userNames = users.map(user => `@${user.name}`)
message = `${userNames.join(', ')}`
const userNames = users.map(user => `@${user.name}`)
const message = `${userNames.join(', ')}`

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about it - first you delete block of variable declaration, then add it again in other place. May be will be less changes and they will be more clear if you change type of variables in block upper?

src/birthder.js Outdated
let users = []

if (!await routines.isAdmin(robot, msg.message.user.name.toString())) {
if (!await routines.isAdmin(robot, msg.message.user.name)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This string looks like refactoring and not relative to the commit message refactoring.

src/birthder.js Outdated
}
}
const name = msg.match[2].trim()
const user = await routines.findUserByName(robot, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

And again you combine small changes with moving block of variable declaration.

@ya7on ya7on force-pushed the user-active-list branch 2 times, most recently from 70900aa to 1127c33 Compare February 12, 2019 11:14
Copy link
Contributor

@polina-popova polina-popova left a comment

Choose a reason for hiding this comment

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

Let's exclude refactoring from the PR.

src/birthder.js Outdated
} else {
return msg.send(`I have never met ${name}.`)
}
})

// Print the users names whose birthdays match the specified date.
robot.respond(routes.check, async (msg) => {
let allUsers
let date
let message
let users = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Now the variable users doesn't need the initial value.

src/birthder.js Outdated
@@ -204,16 +181,9 @@
title = `First working days`
}

let message
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave message here to not redefine it lower.

src/birthder.js Outdated

if (!await routines.isAdmin(robot, msg.message.user.name.toString())) {
msg.send(utils.MSG_PERMISSION_DENIED)
return
}

name = msg.match[2].trim()
date = msg.match[3]
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's don't rewrite date and name variables.

src/utils.js Outdated
users.push(bdayUser)
}
}
const targetDay = moment().add(-exp.BIRTHDAY_CHANNEL_TTL, 'day')
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's don't refactor targetDay variable.

@ya7on ya7on force-pushed the user-active-list branch 3 times, most recently from 2fbc2fb to 0d15a39 Compare February 13, 2019 14:34
Copy link
Contributor

@polina-popova polina-popova left a comment

Choose a reason for hiding this comment

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

The reminding about users without birthday is broken.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants