Skip to content

Commit

Permalink
Merge pull request #1856 from usagov/USAGOV-1856-datalayer-twig
Browse files Browse the repository at this point in the history
Usagov 1856 datalayer twig
  • Loading branch information
akf authored Sep 27, 2024
2 parents fdb33c9 + 66939f8 commit da7612c
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 258 deletions.
23 changes: 19 additions & 4 deletions scripts/drush/verify-pagelayer-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/*
* Can pass as args:
* --sample if set, samples up to 30 paths of each content type+language combo
* --sample <size> if set, samples up to the specified paths of each content type+language combo
* --file <filename> Complete path to CSV file, or path relative to /var/www/web
*/
[$csv, $samplePaths] = parse_args($extra);
Expand All @@ -31,7 +31,7 @@
$counts[$countKey] = 0;
}

if ($samplePaths && $counts[$line->language . '/' . $line->pageType] > 10) {
if ($samplePaths > 0 && $counts[$line->language . '/' . $line->pageType] > $samplePaths) {
continue;
}

Expand All @@ -49,7 +49,7 @@
* Parse command line arguments.
*/
function parse_args(array $extra): array {
$samplePaths = FALSE;
$samplePaths = 0;
$csv = realpath(__DIR__ . '/../../web/modules/custom/usagov_ssg_postprocessing/files/published-pages.csv');

while ($arg = array_shift($extra)) {
Expand All @@ -64,7 +64,16 @@ function parse_args(array $extra): array {
break;

case '--sample':
$samplePaths = TRUE;
$size = array_shift($extra);
if (!ctype_digit($size)) {
throw new \InvalidArgumentException("Sample size must be numeric.");
}
$size = (int) $size;
if ($size <= 0) {
throw new \InvalidArgumentException("Sample size must be a positive integer.");
}

$samplePaths = $size;
break;

default:
Expand Down Expand Up @@ -110,6 +119,12 @@ function compare_data(array $datalayer, CSVRow $row): void {
}
}

if (isset($datalayer['Taxonomy_Text_7'])) {
Drush::output()->writeln(
"<error>... More than 6 levels returned</error>");
var_dump($datalayer);
}

switch ($datalayer['language']) {
case 'en':
if ($datalayer['Taxonomy_Text_1'] !== 'Home') {
Expand Down
Loading

0 comments on commit da7612c

Please sign in to comment.