Last active
July 3, 2025 09:44
-
-
Save mqu/b5829f90f3315d04d9d3f2f91c073f00 to your computer and use it in GitHub Desktop.
Wekan / mongosh / filter users with last connexion < 6 months
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
# - query mongodb database with services.resume.loginTokens having date greater than 6 months | |
# - display in json format username, email, loginToken as lastLogin | |
# - sort by date in reverse-order | |
# - inject query in mongodb container with docker-compose | |
# tags: mongo, wekan, users, mongosh, mongodb, jq, users dump. | |
# FAQ : https://chatgpt.com/share/686650cf-2c00-8011-ad3a-745dd635ba44 | |
docker-compose exec -T mongo mongosh wekan --quiet --eval ' | |
console.log(JSON.stringify( | |
db.users.find({ | |
"services.resume.loginTokens.when": { | |
$gte: new Date(new Date().setMonth(new Date().getMonth() - 6)) | |
} | |
}, { | |
username: 1, | |
emails: 1, | |
"services.resume.loginTokens.when": 1 | |
}).toArray() | |
)); | |
' | jq 'map({ | |
username, | |
email: .emails[0].address, | |
lastLogin: (.services.resume.loginTokens | map(.when) | max) | |
}) | sort_by(.lastLogin) | reverse' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment