Skip to content

Instantly share code, notes, and snippets.

@itaditya
Created March 25, 2018 05:47
Show Gist options
  • Save itaditya/4d69a3e33ca0a361d2dc7d781a7af7f7 to your computer and use it in GitHub Desktop.
Save itaditya/4d69a3e33ca0a361d2dc7d781a7af7f7 to your computer and use it in GitHub Desktop.
module.exports = robot => {
const remindUserToCode = async() => {
robot.log('remindUserToCode')
const installation_id = 116342
const github = await robot.auth(installation_id);
const yesterdayDate = getYesterdayDate();
const { data:{ total_count:total_commits }} = await github.search.commits({
q: `author:itaditya author-date:>${yesterdayDate}`
});
console.log('total_commits', total_commits)
if(total_commits > 0) return
robot.log('nothing committed yet');
}
return {
remindUserToCode
}
}
const getYesterdayDate = () => {
const date = new Date();
let d = date.getDate() - 1;
let m = date.getMonth() + 1;
let y = date.getFullYear();
const f = x => x.toString().padStart(2, '0')
const formattedDate = `${y}-${f(m)}-${f(d)}`
return formattedDate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment