fredericojordan / progress-bar

📊 Flask API for SVG progress badges
https://progress-bar.dev/91/
MIT License
490 stars 121 forks source link

Calculate the percentage #10

Open ceccadroid opened 2 years ago

ceccadroid commented 2 years ago

Hi. I wonder if there's a way to automatically calculate the percentage of completion from note's frontmatter. In my case I have, with other keys,: Total: Seen: for the total number of episodes in my series and how many I've already seen. So I wish to pass to the progress bar the result of (round(seen/Total*100)) I hope you can understand what I mean Thanks in advance for any help

fredericojordan commented 2 years ago

Hello! I have never used frontmatter, but I will try to help. Is there any way to create a new variable with the value round(seen/Total*100)? Or maybe you can calculate it directly in the link: https://progress-bar.dev/{100*seen/Total}/ Let me know if any of these options work.

johnkershaw commented 1 year ago

Given that this would normally be expressed as a fraction, ie seen/total, maybe the most logical way would to handle redirection of the form https://progress-bar.dev/seen/Total

ie https://progress-bar.dev/15/20 would display a 75% progress bar if you've watched 15 out of 20 (or maybe it should show 15 in the left half of the bar and 20 in the right half?)