Showing posts with label react. Show all posts
Showing posts with label react. Show all posts

Friday, 14 July 2023

Collation of livetime (liverc) results for a user

I race little toy cars for plastic trophies! 

In all, i've got 6 RC cars. Not just your average kmart, warehouse, wallmart put some AA batteries in and watch them crawl along at a top speed of "walking pace", no way.

My 1/10th on-road car will do at least 60km/h (38mph) down our back straight, and it's 1/8th big brother will do something like 80-85km/h (50mph-ish). Some of our club members have cars, on our 85m back straight, will top 109km/h... impressive right!

Our results are collected via a transponder system from mylaps, everytime our cars passes over a wire, the transponder communicates with the timing computer and it logs its lap. 
Now this is where my problem started.... 

The results were hard to read on the website. All the data was there but it was hard to compare your first qualifying round to the second and then to your finals, because they showed on different pages. Therefor you needed lots of tabs open if you didn't want to go back and forth.

Initially i started writing this in PHP, i have a server that is always on the internet, so i just lodged it as part of my site. Using a fetch routine, i would go and get the page that had results on it, and then parse the page, looking for the results, collate them and then just show all the results in one hit. It wasn't the most elegant thing, but it worked. 

As you can guess i ran into a few problems, but i got there in the end. 

With that done, my thought was that now every time someone wanted to use this, my server was the one fetching all the results, and that could be quite taxing on page responses. 

So idea 2 then came to mind, lets write this in Javascript! The server would serve up the site, and the javascript would essentially do all the heavy lifting locally, it would be more or less like the user was browsing the site as it was coming from their computer. 
Ran into lots of issues here, the big one was CORS or Cross-origin resource sharing. Basically i couldn't grab the site locally then serve it up to you. This is pretty much how scammers work lol. 

I had been talking to a friend at work randomly about being able to get data from pages that didn't have any sort of API. He had recently come across a project that turned any website into an API! In walks wrapAPI!

So this ended up being magic, wrote the whole thing out to be just fetch and parsing data. 

Work pivoted for me, and i started working with react, which mean't i needed a project to work on, so i thought i would further refine this tool to be written in react, javascript worked, but it was very cumbersome.

Anyhow - long story short, i got practice with react, racers at our local clubs now get to enjoy a tool that shows all their race data in one hit, not having to have multiple tabs open, everyone wins!

Check out my collation tool