<commit_before><?php

	include('../config.php');
	include('../libraries/database.php');
	include('../libraries/template.php');

	$type = $_REQUEST['type'];
	if (!in_array($type, array('desktop', 'mobile', 'tablet', 'gaming', 'television', 'other'))) $type = 'desktop';

	if (in_array($type, array('gaming', 'television'))) {
		header('Location: /results/other.html#' . $type);
		exit;
	}

	$db = Factory::Database();

	if ($type == 'other') {
		$tpl = new Template('../templates/results-other.html');
		$tpl->set('type', $type);


		$consoles = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('gaming-console',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$consoles[] = $row;
		}

		$tpl->set('consoles', $consoles);

		$portables = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('gaming-portable',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$portables[] = $row;
		}

		$tpl->set('portables', $portables);

		$smarttvs = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('television-smart',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$smarttvs[$row->status][] = $row;
		}

		$tpl->set('smarttvs', $smarttvs);

		$settopboxes = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('television-box',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$settopboxes[] = $row;
		}

		$tpl->set('settopboxes', $settopboxes);

		$ereaders = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('ereader',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$ereaders[] = $row;
		}

		$tpl->set('ereaders', $ereaders);


		echo $tpl->fetch();
	}

	else {
		$tpl = new Template('../templates/results.html');
		$tpl->set('type', $type);


		$main = array();
		$names = array();

		$result = $db->query("
			SELECT
				v.status, pp.name, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, f.score
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN data_platforms AS pp ON (pp.platform = IFNULL(p.related,p.platform))
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				p.order > 0 AND
				v.visible = 1 AND
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('" . $type . "',v.type)
			ORDER BY
				p.order DESC, pp.name, !ISNULL(v.releasedate), v.releasedate DESC
		");

		$count = 0;

		while ($row = $result->fetch_object()) {
			$names[$row->name] = array($row->name, $row->id);

			if (!isset($main[$row->name])) {
				$main[$row->name] = array(null, null);
			}

			if ($row->status == 'upcoming') {
				$main[$row->name][0] = $row;
			}

			if ($row->status == 'current') {
				$main[$row->name][1] = $row;
			}

			if ($row->status == 'legacy' && count($main[$row->name]) < 8) {
				$main[$row->name][] = $row;
			}
<commit_msg>Use the nickname for the overview instead of the name of the platform<commit_after><?php

	include('../config.php');
	include('../libraries/database.php');
	include('../libraries/template.php');

	$type = $_REQUEST['type'];
	if (!in_array($type, array('desktop', 'mobile', 'tablet', 'gaming', 'television', 'other'))) $type = 'desktop';

	if (in_array($type, array('gaming', 'television'))) {
		header('Location: /results/other.html#' . $type);
		exit;
	}

	$db = Factory::Database();

	if ($type == 'other') {
		$tpl = new Template('../templates/results-other.html');
		$tpl->set('type', $type);


		$consoles = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('gaming-console',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$consoles[] = $row;
		}

		$tpl->set('consoles', $consoles);

		$portables = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('gaming-portable',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$portables[] = $row;
		}

		$tpl->set('portables', $portables);

		$smarttvs = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('television-smart',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$smarttvs[$row->status][] = $row;
		}

		$tpl->set('smarttvs', $smarttvs);

		$settopboxes = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('television-box',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$settopboxes[] = $row;
		}

		$tpl->set('settopboxes', $settopboxes);

		$ereaders = array();

		$result = $db->query("
			SELECT
				v.status, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, v.nickname, v.details, v.visible, f.score, f.points, f.results
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('ereader',v.type)
			ORDER BY
				score DESC
		");

		while ($row = $result->fetch_object()) {
			$ereaders[] = $row;
		}

		$tpl->set('ereaders', $ereaders);


		echo $tpl->fetch();
	}

	else {
		$tpl = new Template('../templates/results.html');
		$tpl->set('type', $type);


		$main = array();
		$names = array();

		$result = $db->query("
			SELECT
				v.status, IFNULL(pp.nickname,pp.name) as name, v.platform, IFNULL(p.related,p.platform) AS id, IFNULL(v.version,'') AS version, f.score
			FROM
				data_versions AS v
				LEFT JOIN data_platforms AS p ON (v.platform = p.platform)
				LEFT JOIN data_platforms AS pp ON (pp.platform = IFNULL(p.related,p.platform))
				LEFT JOIN scores AS s ON (v.platform = s.platform AND (v.version = s.version OR (v.version IS NULL AND s.version IS NULL)))
				LEFT JOIN fingerprints AS f ON (f.fingerprint = s.fingerprint)
			WHERE
				p.order > 0 AND
				v.visible = 1 AND
				s.release = '" . $GLOBALS['configuration']['release'] . "' AND
				FIND_IN_SET('" . $type . "',v.type)
			ORDER BY
				p.order DESC, IFNULL(pp.nickname,pp.name), !ISNULL(v.releasedate), v.releasedate DESC
		");

		$count = 0;

		while ($row = $result->fetch_object()) {
			$names[$row->name] = array($row->name, $row->id);

			if (!isset($main[$row->name])) {
				$main[$row->name] = array(null, null);
			}

			if ($row->status == 'upcoming') {
				$main[$row->name][0] = $row;
			}

			if ($row->status == 'current') {
				$main[$row->name][1] = $row;
			}

			if ($row->status == 'legacy' && count($main[$row->name]) < 8) {
				$main[$row->name][] = $row;
			}

{'fraction_non_alphanumeric': 0.17402508160109947, 'fraction_numerical': 0.0010307507301151005, 'mean_word_length': 3.285241074714759, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2466439', 'n_tokens_mistral': 4783, 'n_tokens_neox': 4061, 'n_words': 1068}