Skip to content

Commit

Permalink
Add testing of pkg_prefix_sort
Browse files Browse the repository at this point in the history
Now I realize I could optimize it by only invoking it for ports
which have package information recorded.
  • Loading branch information
dlangille committed Sep 15, 2024
1 parent f8593dc commit 816c81a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions testing/interate-all-ports-pkg_prefix_sort.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

$_SERVER['DOCUMENT_ROOT'] = "/usr/local/www/freshports/www";

require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/common.php');
require_once('include/constants.php');
require_once('include/freshports.php');
require_once('include/databaselogin.php');
require_once('classes/port-display.php');
require_once('classes/ports.php');


$sql = "
select P.id, E.name as port, C.name as category
FROM ports P join element E on P.element_id = E.id
JOIN categories C on P.category_id = C.id
ORDER by category, port
";

$result = pg_query_params($db, "set client_encoding = 'ISO-8859-15'", array()) or die('query failed ' . pg_last_error($db));

$result = pg_query_params($db, $sql, array()) or die('query failed ' . pg_last_error($db));

$numrows = pg_num_rows($result);

echo "We have $numrows ports for testing\n";

$rows = pg_fetch_all($result);

foreach ($rows as $key => $row) {
echo $key . ' ' . $row['category'] . '/' . $row['port'] . "\n";
$port = new Port($db);
$port->FetchByID($row['id']);
$port_display = new port_display($db);
$port_display->SetPort($port);
$port_display->SetDetailsPackages();

$HTMLPortPackages = $port_display->Display();

unset($HTMLPortPackages);
unset($port_display);
unset($port);
}

0 comments on commit 816c81a

Please sign in to comment.