Andy Burnham declares 'change is coming' to British politics as he holds eve-of-poll rally ahead of Makerfield by-election - while Hugh Grant lends his support to PM hopeful
Tax hikes and uncertainty make life in Britain less appealing to the wealthy
Price gap between flats and houses hits 30 year high as buyers swerve leasehold properties
Major US carrier stored credit card info in the clear, employee learned on first day
China's EV Price War Was Built On Cars Sold At a Loss
Read more of this story at Slashdot.
Moment woman cyclist with THREE children riding on back pedals through a red light and holds up her hand to try and stop cars as she dodges traffic
Jude Bellingham's American girlfriend cheers on England alongside his mother - amid feud with her homeless mum
Every emotional moment from the Gilgo Beach killer's sentencing: Rex Heuermann's shocking first words... and the chilling exchange that silenced the room
'Regime change' on hold as new Federal Reserve boss Kevin Walsh takes the reins
A.N. WILSON: The unmistakable link between the depraved sex life of the Left's favourite economist and his ruinous spend, spend, spend policies
Trump turns on the charm after extended 'alpha' handshake with Macron and kisses for Brigitte at Palace of Versailles
Representative Line: Sort This Out
Today's anonymous submitter has spent a long time toiling through many, many tickets. Their effort has been an attempt to "save" their employer from the disaster left behind by by a highly-paid consultant. As one does, our submitter started with the highest priority tickets with the highest severity. Eventually, they whittled down that list, and had some bandwidth to start looking at the pieces of the code which clearly weren't exploding right now (because there were no tickets), but were likely to explode at some point in the future (creating a storm of tickets).
Scanning through the JavaScript, our submitter found a sort function. That was automatically concerning- why was that particular wheel being reinvented?
The first line of the sort function was this:
obj[x._id.account_id] = x.count_totalIn this case, x._id is meant to be the unique identifier from their Mongo DB. That, uh, should be not precisely a UUID (Mongo does its own weird version), but it definitely shouldn't have an account_id field on it. They are storing an arbitrary object as their unique identifier in the database. Which, I'm no Mongo expert, but I don't need to be Flash Gordon to know that's a bad idea.
But setting aside the choice of using random objects as unique identifiers, there's also the other question: how is this furthering the goal of sorting? Why on Earth am I building an object in the form: {"id0": 5, "id1": 7, "id2": 11}? Or am I even doing that? This is the first line of the function, so we're not even doing a loop, it's just {"id0": 5}.
This isn't just an unexploded bomb, it's a mystery: the primary mystery being why hasn't this exploded already? The second mystery is: what's going to happen when your luck runs out?