27 May 2024


Chris Wales

Developing an easier way to report election results

In 2022, we undertook a project to create an election reporting application for the Cumberland Shadow Council Authority’s founding election.

The project had a short turnaround time, and the stakes were high because it was one of our first ventures into LocalGov Drupal. Our colleague, Rob Carr, did much of the original work, but then I came in to get it over the line. It was a fantastic project to work on, and the election results reporting was featured on the social media accounts of several national news outlets. 

At that point, we didn’t expect the application to be used by any other clients because it was tightly coupled to the original requirements. However, this changed when we later needed to migrate the custom application to open source. 

From bespoke to open source

Earlier this year, LocalGov Drupal asked us if we could contribute to their project and help integrate our election reporting application into their platform, with a few improvements to boot. 

It was an exciting challenge for us to get more involved in the LocalGov Drupal/open-source community. Our council partners, Cumberland Council and Westmorland & Furness Council, funded this. It’s not every day that a client wants to open up their work and contribute to the open-source community, so this was a wonderful opportunity. 

The overall task involved transforming our bespoke module into a truly open source one. Our original application was centred around the client’s needs, which doesn’t always work well when rolled out more widely. 

Users often have complex needs and don’t always use the software in ways you’d expect. It soon became apparent we needed an almost complete rewrite of the module. Some code was kept, but we scrapped or rewrote a good portion of it to allow for the changes needed. 

Embracing the plugin architecture

One of the biggest challenges during the development was allowing users to pull in geographic boundary data in the module. In the first incarnation, we had static geojson data that was part of the installation process. We knew the areas and their boundary information, so there was no need to have any kind of dynamic procedure. 

Now, we needed to provide a way for people to bring in their own geodata. The question was how? The answer was actually staring us in the face—the plugin architecture pattern, which Drupal makes massive use of.

The plugin architecture allowed us to create a boundary provider plugin which anyone could make use of by creating their own boundary provider plugins. We didn’t need to focus on where they got their data from, but only that it would create the necessary providers and correct election areas. It also meant we didn’t need to provide a one-size-fits-all solution. We only had to document enough so that people could create their own if required, and we even provided a demo plugin to help with this.

One of the issues I encountered with implementing our plugin architecture was that I’d never written my own plugin previously. Drupal has various types I’d implemented, e.g. blocks, fields, etc., but creating your own is much more involved and challenging. Drupal’s documentation can sometimes be pretty technical and not user-friendly for those unfamiliar with specific topics. Luckily, there were a fair amount of open-source examples to give me inspiration, and I typically pick up new topics quickly. 

Making life easier for comms teams

Social media integration was one of the main improvements we were asked to implement. In the last election, comms teams found it difficult to add results to the system and post them to social media. 

Their nights were often hectic, and reporting results was frustrating and fragmented. Our solution was to integrate with Twitter (now X) via the Drupal module ‘Social API’. This was implemented as a separate application submodule that people could use if they wanted the Twitter integration. It enabled them to link their accounts and post the latest results automatically. The main benefit of this was allowing people to post results from one place instead of constantly swapping between the application and Twitter.

One of the challenges faced with this integration was the underlying software we relied on was out of date and had bugs which our users wouldn’t be able to live with. We were able to help the open-source community with these projects in the form of a patch. It’s important not just to take but also to give back when possible. The patch should help those who come across a similar situation that we found ourselves in and may even be accepted into the main code base.

Catering for different elections

One issue with our previous application was that it was highly specific to our client and was built on our naive understanding of the various local council election types and how they work. 

We also didn’t support ‘not-all-out’ elections, where only a portion of seats are up for grabs. An ‘all-out’ election is when all available seats are contested in one go, but this isn’t always the case for every election. Sometimes, only a portion is contested, and the rest of the seats are not. An example of this is when elections are staggered, e.g. half the seats are voted on in one period, and then the rest are voted on at a later date. We added ‘not-all-out’ elections as a feature to our application fairly quickly and aim to support more in the future.

What’s next on the agenda? 

We’re also looking at adding a provider for UK Parliamentary elections. The one we have at the moment is for council electoral wards, and the boundaries are different. We also need to add some automated testing to the GitHub repository. 

Even with the remaining work to be done, we’re delighted with how things have turned out. We have a new plugin system for boundary providers, a social media integration, and functionality for ‘not-all-out’ elections. We aim to add more over the coming months to enhance the election reporting tool, and I’m excited to see how people use it. 

This is just one example of our custom applications work and expertise. Please contact us below to discuss your LocalGov Drupal project. 

Let's start a project together...

Simply fill in this form with your key details and we'll be in touch.