September 5, 2023
by Matt Raines

Looking back to 2010

« 2008 | 2009 | 2010 | 2011 | 2012 »

Tim with Nick Clegg in 2010

2010 marked the release of our ground-up rebuild of the Liberal Democrat website platform, this time built on top of Symfony, and this kept us busy most of the year. Folkestone web designer Dane Williams helped us put together a great and varied choice of new designs for the platform including custom designs for several MP clients and we migrated all existing customer content from the old system.

The sites provided custom mobile and accessible views, rich text editing, Facebook and Twitter integration (back when this was possible), in-browser image editing, and graphical reports.

Vince Cable's website in 2010At the General Election Naomi Long became the Alliance Party of Northern Ireland’s first MP and site traffic – already at many times its usual volume – increased a further 30-fold. The election returned a hung parliament as the polls had suggested and after 5 days the Lib Dems announced a coalition with the Conservative party. It was a tense week which kept us busy monitoring and reconfiguring servers to deal with the load. And typing election results into the system to put pretty bar charts on every site.

Prater Raines website in 2010Work with Seymour Transport shifted from building the user interface for their logistics platform to extracting reports from the increasing data available within the system, and websites for their Trident Commercials and Seymour Hire arms. Other sites included the Providence Inne in Sandgate and building HTML layouts for annual charity racing event The Full Monte.

Tools of the trade

Location, location, location

The year in tech

Sample code

<?php

class ElectionMigrator extends Foci1Migrator
{

  public function execute()
  {
    sfContext::getInstance()->getConfiguration()->loadHelpers("Colour");
    $fixtures = array("Party" => array(), "Election" => array(), "Ballot" => array(), "Candidate" => array());

    $parties = $this->fetchAll("SELECT * FROM parties WHERE id != 4");
    foreach ($parties as $party) {
      $fixtures["Party"][$party["id"]] = array(
        "legacy_id" => $party["id"],
        "name" => $this->convertEncoding(trim($party["name"]))
      );
      if ($party["red"] !== null && "$party[red]-$party[green]-$party[blue]" != "0-0-0") {
        $fixtures["Party"][$party["id"]]["colour"]
          = colour_rgb_to_hex($party["red"], $party["green"], $party["blue"]);
      }
    }

    $elections = $this->fetchAll(
      "SELECT DISTINCT type, election, electiondate FROM elections WHERE hasbeencounted = 1");
    foreach ($elections as $election) {
      $election_id = "$election[electiondate] $election[election]";
      $fixtures["Election"][$election_id] = array(
        "electoral_method" => $election["type"] == 1
          ? "First Past The Post" : "Party List Proportional Representation",
        "balloted_at" => $election["electiondate"],
        "Translation" => array(
          "en" => array(
            "name" => $this->convertEncoding(trim($election["election"]))
          )
        ),
        "Ballots" => array()
      );

      $ballots = $this->fetchAll(
        "SELECT * FROM elections WHERE type = :type AND election = :election "
        . "AND electiondate = :date AND hasbeencounted = 1",
        array(":type" => $election["type"], ":election" => $election["election"],
              ":date" => $election["electiondate"]));
      foreach ($ballots as $ballot) {
        $fixtures["Ballot"][$ballot["id"]] = array(
          "Election" => $election_id,
          "legacy_id" => $ballot["id"],
          "number_of_seats_contested" => $ballot["seats"],
          "number_of_votes_cast" => $ballot["total"],
          "turnout_as_percentage" => $ballot["turnout"],
          "Translation" => array(
            "en" => array(
              "location" => $this->convertEncoding(trim($ballot["name"]))
            )
          ),
          "Candidates" => array()
        );

        $candidates = $this->fetchAll(
          "SELECT * FROM electionresults WHERE election = :election",
          array(":election" => $ballot["id"]));
        foreach ($candidates as $candidate) {
          $slug = "$candidate[election]_$candidate[party]_"
            . preg_replace("/\W+/", "_", $candidate["candidate"]);
          $fixtures["Candidate"][$slug] = array(
            "Ballot" => $ballot["id"],
            "candidate_name" => $this->convertEncoding(trim($candidate["candidate"])) ?: null,
            "votes_received" => $candidate["votes"],
            "vote_change_as_percentage" => $candidate["votechange"],
            "seats_returned" => $candidate["seats"],
            "seat_change" => $candidate["seatchange"]
          );
          if ($candidate["party"] != 4) {
            // 4 = Independent
            $fixtures["Candidate"][$slug]["Party"] = $candidate["party"];
          }
        }
      }
    }
    return $fixtures;
  }
  
}