toipe icon indicating copy to clipboard operation
toipe copied to clipboard

Store results and show past scores

Open Samyak2 opened this issue 3 years ago • 10 comments

What and why?

It would be nice if toipe stored the results of each test in a file or a DB on the local system. There could be a screen to display past results - maybe a local leaderboard or a graph tracking speed across time.

How?

TODO. Need to figure out the details.

Context

Suggestion from reddit - https://www.reddit.com/r/rust/comments/tvamfz/comment/i3bqomq/

Samyak2 avatar Apr 04 '22 09:04 Samyak2

Hi, What results specifically would you like to store? The most obvious and easily available metrics are the accuracy and wpm as they're already part of the ToipeResults structure

abaksy avatar Jun 11 '22 14:06 abaksy

@abaksy perhaps it would be good to store the whole of ToipeResults. Any required metric can then be derived from that.

Samyak2 avatar Jun 14 '22 04:06 Samyak2

I think CSV should work fine, easily parsable by toipe and is also available to the user for viewing (outside of the program).

grtcdr avatar Jun 17 '22 06:06 grtcdr

I'd be willing to take a crack at this. I just want to know if serialization is something that is open for discussion, or if manual parsing of the values into CSV is preferred.

  1. Use Serde and then something like a csv parser that can be used with Serde
  2. Make another function under display_results named save_csv and then do the manual conversion in that function.

I'm leaning towards using Serde just because it opens up future expansion for graphing etc. without much, if any, rewriting as most libraries support Serde pretty well. Only issue I know Serde will have is that the started_at and ended_at fields in ToipeResults will have to go because Serde can't serialize std::time::Instant without more external libraries or our own serialization/deserialization implementation. Could just be moved into a single duration: std::time::Duration field and then calculate the Duration before creating the struct.

I'm interested in any thoughts regarding this.

PriceHiller avatar Aug 08 '22 04:08 PriceHiller

@treatybreaker thank you for taking a crack at this. I prefer the serde solution. I'm assuming that each ToipeResults will be serialized individually and appended to the CSV.

Could just be moved into a single duration: std::time::Duration field and then calculate the Duration before creating the struct.

This is reasonable. Although, along with the duration I would also like to store the start timestamp of the test. Perhaps chrono::DateTime.

Samyak2 avatar Aug 09 '22 03:08 Samyak2