liveblog
liveblog copied to clipboard
[LBSD-2832] - Create Go pricing plan notification for bandwidth
Purpose
This PR introduces an implementation to fetch bandwidth usage for Go pricing plan and notify the user on the client side.
What has changed
- Added a new
Bandwidth
resource and service to store the bandwidth of the client. - Added a new task to make the API call to fetch bandwidth usage from Cloudflare and scheduled it for midnight.
- Added endpoint to fetch bandwidth usage on client side and notify the user when close to upper bandwidth limit
Steps to test
- Checkout to this branch and set needed env variables for the server, then run Liveblog. Ensure the subscription level is 'liveblog-go'.
SUBSCRIPTION_LEVEL='liveblog-go'
CLOUDFLARE_URL=''
CLOUDFLARE_AUTH=''
CLOUDFLARE_ZONE_TAG=''
- Under the server directory, initialize data to create new bandwidth collection
$ python3 manage.py app:initialize_data;
- For easier testing, you can change the schedule of the task to run every two minutes under
settings.py
"bandwidth:update": {
"task": "liveblog.bandwidth.tasks.fetch_bandwidth_usage",
# "schedule": crontab(minute=0, hour=0), # every midnight
"schedule": crontab(minute="*/2"), # every 2 minutes
},
- Observe the logs to see the task being called and running.
- After a while, log in on the client side and if the bandwidth used is greater than 75%, it should show a warning notification. You can reduce this value in
client/app/scripts/liveblog-bloglist/controllers/blog-list.js
for easier testing.
Resolves: LBSD-2832