Last active
June 3, 2019 15:48
-
-
Save travisrcory/9242f85f168d60156cc8691a3db853f8 to your computer and use it in GitHub Desktop.
Find inactive users on Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("fetching users..."); | |
var intervalId = window.setInterval( | |
() => { | |
console.log('...\n'); | |
}, | |
750 | |
); | |
let resultsPromise = new Promise( | |
(resolve, reject) => { | |
Liferay.Service( | |
'/loop-portlet.people/search', | |
{ | |
end: -1, | |
keywords: '', | |
start: -1 | |
}, | |
({data}) => resolve(data.results) | |
); | |
} | |
); | |
resultsPromise.then( | |
results => { | |
console.log('Users fetched! Preparing list...'); | |
let inactiveUsers = _.filter(results, 'inactive'); | |
return _.sortBy(inactiveUsers, 'modifiedDate'); | |
} | |
) | |
.then( | |
results => { | |
window.clearInterval(intervalId); | |
console.log('done!'); | |
console.log(`Inactive people: ${results.map(person => person.name)}`); | |
} | |
) | |
.catch( | |
reason => console.log(reason) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment