Closed librarianmage closed 2 years ago
We'd probably need to introduce threading so the image generation doesn't block other commands (I'm not even sure whether JDA does threading or not, it might already do so by default). Furthermore, we need to figure out what we want everything to look like (@DiabeticTurtle ??) and then draw it in Java.
Been trying out some mocks. Open for feedback. Colors, data, info, dots, etc.
graph height is the only real annoyance with this, not sure about other data sources but a G4/5/6 will only go from 40-400mg/dl (2.22~-22.22~) so not sure there is much point in going higher/lower not sure what kind of processing power it takes to generate these though, thats a question for @cascer1 as to what kind of resources this takes/needs.
I can work on this c:
@stavlor I don't think varying the graph range is a very intensive operation.
Ideally we would take a look at the NS settings and draw lines to indicate their ranges, and also respect the color settings.
Note that just for a 3h graph we are looking at data like this 36 points for 3h 72 points for 6h 144 for 12h And 288 for 24h We would probably just want sgv records When running the bot locally the other day I noticed my local copy had 7 or so threads getting the data isn't terribly hard processing it and dealing with gaps can be
[{"_id":"5bdbdad13b6e35e9e96809e2","sgv":80,"date":1541135049000,"dateString":"2018-11-02T05:04:09.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd9c33b6e35e9e96806cf","sgv":81,"date":1541134750000,"dateString":"2018-11-02T04:59:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd8883b6e35e9e9680357","sgv":81,"date":1541134450000,"dateString":"2018-11-02T04:54:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd74e3b6e35e9e967ffcc","sgv":82,"date":1541134150000,"dateString":"2018-11-02T04:49:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd63f3b6e35e9e967fcbb","sgv":81,"date":1541133850000,"dateString":"2018-11-02T04:44:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd5043b6e35e9e967f92c","sgv":81,"date":1541133550000,"dateString":"2018-11-02T04:39:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd3f63b6e35e9e967f60f","sgv":83,"date":1541133249000,"dateString":"2018-11-02T04:34:09.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd2bb3b6e35e9e967f267","sgv":83,"date":1541132950000,"dateString":"2018-11-02T04:29:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd1803b6e35e9e967eef5","sgv":82,"date":1541132650000,"dateString":"2018-11-02T04:24:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbd0723b6e35e9e967ebf2","sgv":82,"date":1541132350000,"dateString":"2018-11-02T04:19:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbcf373b6e35e9e967e862","sgv":83,"date":1541132050000,"dateString":"2018-11-02T04:14:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbcdfc3b6e35e9e967e4dc","sgv":85,"date":1541131750000,"dateString":"2018-11-02T04:09:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbccc13b6e35e9e967e14b","sgv":88,"date":1541131450000,"dateString":"2018-11-02T04:04:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbcbb43b6e35e9e967de3f","sgv":89,"date":1541131150000,"dateString":"2018-11-02T03:59:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbca783b6e35e9e967dac5","sgv":90,"date":1541130850000,"dateString":"2018-11-02T03:54:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbc96a3b6e35e9e967d7b2","sgv":91,"date":1541130550000,"dateString":"2018-11-02T03:49:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbc82f3b6e35e9e967d411","sgv":92,"date":1541130250000,"dateString":"2018-11-02T03:44:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbc7213b6e35e9e967d12f","sgv":90,"date":1541129950000,"dateString":"2018-11-02T03:39:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbc5e63b6e35e9e967cd94","sgv":88,"date":1541129650000,"dateString":"2018-11-02T03:34:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbc4ab3b6e35e9e967ca0c","sgv":81,"date":1541129350000,"dateString":"2018-11-02T03:29:10.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbc3703b6e35e9e967c693","sgv":74,"date":1541129050000,"dateString":"2018-11-02T03:24:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbc2353b6e35e9e967c307","sgv":72,"date":1541128750000,"dateString":"2018-11-02T03:19:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbc1273b6e35e9e967bff6","sgv":79,"date":1541128451000,"dateString":"2018-11-02T03:14:11.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbbfec3b6e35e9e967bc70","sgv":87,"date":1541128150000,"dateString":"2018-11-02T03:09:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbbede3b6e35e9e967b94f","sgv":96,"date":1541127850000,"dateString":"2018-11-02T03:04:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbbda33b6e35e9e967b5c4","sgv":105,"date":1541127550000,"dateString":"2018-11-02T02:59:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbbc683b6e35e9e967b24b","sgv":110,"date":1541127250000,"dateString":"2018-11-02T02:54:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbbb2d3b6e35e9e967aec6","sgv":114,"date":1541126950000,"dateString":"2018-11-02T02:49:10.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbba1f3b6e35e9e967abab","sgv":118,"date":1541126649000,"dateString":"2018-11-02T02:44:09.000Z","trend":6,"direction":"SingleDown","device":"share2","type":"sgv"},{"_id":"5bdbb8e43b6e35e9e967a832","sgv":126,"date":1541126350000,"dateString":"2018-11-02T02:39:10.000Z","trend":6,"direction":"SingleDown","device":"share2","type":"sgv"},{"_id":"5bdbb7a93b6e35e9e967a4a2","sgv":134,"date":1541126049000,"dateString":"2018-11-02T02:34:09.000Z","trend":6,"direction":"SingleDown","device":"share2","type":"sgv"},{"_id":"5bdbb69b3b6e35e9e967a193","sgv":150,"date":1541125749000,"dateString":"2018-11-02T02:29:09.000Z","trend":6,"direction":"SingleDown","device":"share2","type":"sgv"},{"_id":"5bdbb5603b6e35e9e9679e04","sgv":163,"date":1541125449000,"dateString":"2018-11-02T02:24:09.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbb4523b6e35e9e9679b00","sgv":177,"date":1541125149000,"dateString":"2018-11-02T02:19:09.000Z","trend":5,"direction":"FortyFiveDown","device":"share2","type":"sgv"},{"_id":"5bdbb3173b6e35e9e967976e","sgv":187,"date":1541124849000,"dateString":"2018-11-02T02:14:09.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"},{"_id":"5bdbb1dc3b6e35e9e96793f8","sgv":193,"date":1541124549000,"dateString":"2018-11-02T02:09:09.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv"}]
If you're looking for more than sgv, some of the watchface implementations have their information condensed pretty neatly.
There's also the possbility of just using some sparklines: https://rosettacode.org/wiki/Sparkline_in_unicode#Kotlin
e.g.:
curl -s 'https://kitt3000.herokuapp.com/api/v1/entries/sgv.json?count=10' | jq 'sort_by(.date) | .[].sgv' | sparklines
█▅▃▂▂▁▃▅▅▄
It looks like this issue was moved from "In Progress" to "Done" for the v2 project. Is that accurate?
Yes, the graphing functionality is done in the branch https://github.com/reddit-diabetes/diabot/tree/feature/ns-graph and is included in #128, but is currently blocked by #132 as we want to allow server owners the ability to disable the NS graph command. I gave myself a lot of work by steering towards a full RBAC system to avoid having to deprecate a dedicated "disable nightscout graphs" command in the future.
I'd like to be able to see a small graph embedded into Discord when I get data from the bot, as then it would be easier (for the user) than taking screenshots and uploading