When I was deciding how many recent posts to display on the main age of Soylent Red I had two concerns: that each post should have its place for a certain minimum time period, and that the page should not empty of content for lack of recent enough posts. The minimum time period right now is one week. The minimum number of posts at any time is five. That means that if I don’t post for a week, the last five posts will still be here. If I post ten times in one day, there’ll be a whole load of posts on here until they drop off the front page a week hence (assuming they’re replaced with new content).
The SQL query for this is a straightforward union:
(SELECT * FROM entries WHERE posttime>'cutoff' AND status='published' ORDER BY posttime DESC) UNION (SELECT * FROM entries WHERE status='published' ORDER BY posttime DESC LIMIT 5); Here I’ve simplified the long list of fields to return to a simple "
*"—I don’t recommend using the universal selector in practice. Also, "cutoff" represents a datetime value for one week ago computed in the PHP source. This is (essentially) the code I had in place until just now, but there’s a bug in it.
This is a
UNION of two
SELECTs, each of which is ordered by descending timestamps, so the first item returned is the most recent post, as you would want it when displaying posts on a blog. But when the
UNION operator is applied to the two sets of results, the order is no longer guaranteed. The posts can come out in any order at all. Up until now they had always been returned in the order I wanted, or at least I hadn’t notced otherwise, but there had been no guarantee.
Nothing came of my listing on the site for some time. I got the occassional email or text message asking if I was available at such and such a date in such and such a place. Inevitably I wasn’t. It turned out that production companies don’t like to plan very far ahead. "Can you take the next week off to film with us? Including today? What college work?"
Fast forward—that’s an industry term for running a film at faster than real time in order to skip quickly into the future—to this Monday, when I got a call from Coco television to play a bank raider in a re-enactment of of a robbery in Monasterevan for RTÉ’s Crime Call. I accepted the offer, at the same time composing the beginning of my inevitable Oscar acceptance speech some years down the line. Short red hair and a pair of blue jeans were the requirements as stated. But they found in me something that they hadn’t expected. The ‘X’ factor.
By fortuitous coincidence, the show’s producer (I think; I never did ask her actual title. It seemed to be anything between casting director and coffee-fetcher) lives around the corner from me. She drove me in for a pre-eight o’clock start. We filmed from eight until 10 inside the bank. When the bank opened for business we moved outside to get the approach and our wild dash to freedom. Then we took a series of shots of the getaway car speeding away. Though it seems the escape can’t be described in those terms in the show’s voice-over, as there are no witness statements that say the robbers sped away. It’s an educated guess. Perhaps they took a leisurely drive.
I was the lead robber, so I got the most lines and the most screen time. Much of it was concealed under a balaclava, but I think there’s enough un-obscured footage that I’m likely to be lynched once the show goes out next Tuesday night. Such are the tribulations we screen celebrities must endure for our art.
I’ll be interested to see how it all came together in the editing room. No doubt I’ll be cringing and peeking between my fingers at the TV screen.