Today’s hat tip goes to Twitter user @AllieNovakk who asked a super reasonable question.
Year was the sticking point. All the rest? Super easy. But not years.
Now technically, yes, you could totally do that via our API and some skillful use of spreadsheets, but honestly the API is great nerd level stuff and it’s not great for a casual viewer who just wants to see the list and maybe drill down and find all the non-binary characters from a specific year.
What’s the Hold Up?
For about 7 months, I’ve been kicking the code around, and having a hard time due to the ‘intelligent’ way I nested the data.
Nerd Alert: This next bit is a little code concept heavy.
The way we structure our data is a tripod:
But as anyone can tell you, they all interrelate. An Actor plays a character on a show, and all three points are directions from which someone would come to our site to look up things. Maybe you’re watching Family Law and wonder who the super cute wife is of one of the main characters. Maybe you saw the character on a Tumblr gif but can’t figure the show name. Maybe you just want to know what Ali Liebert’s up to in general.
In order to relate all the data, it’s the character that is the central source of truth. When we add a character, we have two custom sections.
First there’s the very basic ‘actor’ section. It’s simply an array of data, listing all the actors who have played the character. When we make an actor page, the list of their characters is populated from a search that’s basically “Find me all characters played by actor X.” We did some tweaks to make it faster and more stable, so every time we add or update an actor, it actually does that search. And then when we add a new character, since we’re telling it “Played by Actor X” it knows to directly edit the actor page with the new character.
That’s all easy compared to shows. For each show, we create a new ‘show section’ that lists the name of the show, the ‘type’ of role, and then … the years. Yes, in addition to our regular curation (where anyone on the editorial team watching a show updates characters as they appear), we also manually review all active shows 3-4 times a year, checking the ‘current’ characters, and updating the years if needed. For some shows (like Neighbours) that have a ‘everyone who was here come back for a fare-the-well, that can get time consuming. Similar to the actors, when a new show is added, the show is updated with the new data.
The problem is I was ‘clever’ and made the years an array. But the show section was already an array. Meaning I put an array in an array, and that meant all the normal code I’d written for extracting the show data for the character search and facets (that’s what it’s called when you tell the page ‘list all characters who are cis…’ – cis would be a faceted term, and there’s a whole ‘faceting the gem’ concept in there).
Nerd Alert Over: Non techie/math nerds rejoice.
tl;dr? In making the data related to the right parts of the site, I made it harder to extract. Whoops.
But it works now!
After I was asked, I made a note to look back into it. And after 1 entire afternoon of it just not working, I deleted all the new search code and started over. Turns out I was trying to break apart the data in a wrong way. It was really just a simple error, but it had been driving me nutty. That Sunday afternoon, I took all of 2 hours and it worked.
You have to laugh at yourself sometimes.
And now we have “Years Appears”:
And if you wanted to know who is the one trans character on-air from 2008?
Are there features you’d like?
Let me know! I’m always happy to see if we can make all this better for readers like you.