This is a simple application to help gain adoption of trailhead by allowing your team to see stats in the same manner as a gaming leaderboard.
https://sample-trailhead-leaderboard.herokuapp.com/
This entire application can run for free on Heroku.
-
Click the Deploy to Heroku button
- For App Name, specify a name for your application. For example, if you specify sample-trailhead-leaderboard, your application will be available at http://sample-trailhead-leaderboard.herokuapp.com. Your app name has to be unique on the herokuapp.com domain.
- Click the Deploy App button
-
Configure the schedule: (this keeps the leaderboard up to date daily)
- Navigate to the heroku dashboard https://dashboard.heroku.com/apps and select your app.
- Choose Resources > Heroku Scheduler (a new browser tab will appear)
- Click Create Job (the Job Editor side panel will display)
- In the Schedule area, choose Every day at... and
1:00 PM UTC
- In the Run Command area next to the dollar sign ($), type in
node scheduled-refresh.js
- Click Save Job
Pull Requests are Welcome!
It is good to follow Heroku's node.js tutorial to get an understanding of how node.js works on Heroku and to configure your local environment.
Grab a copy of the code
You'll want to create your own .env file with the MongoDB URI in it:
MONGODB_URI=mongodb://<<username>>:<<password>>@<<your instance>>.mlab.com:<<port number>>/<<your instance>>
Run npm install
in the directory you've downloaded
There is a launch.json
file part of the project to make it easy to debug with VSCode, run in VS code and look at the Debug Console to see what port it is running at (typically 5000) open your web browser to http://localhost:5000 and view it locally.
Error Logs
To view error logs:
heroku logs --tail -a <<appname>>
Kill Local Instance
To kill the local development environment:
Sometimes the local heroku development enviornment may die in the background, this stackoverflow tip was helpful:
Lists all processes on port 5000:
lsof -i :5000
Find the PID and then kill the process with this command:
sudo kill -9 <<pid>>
Best Performance
For best performance, ensure that the app is running in production mode (it should be already by default):
heroku config:set NODE_ENV=production -a <<your app aname>>
The puppeteer buildpack used to scrape trailhead profiles:
heroku buildpacks:set jontewks/puppeteer
Node JS:
heroku buildpacks:set heroku/nodejs
Additional Addons: