Skip to content

Commit

Permalink
further fixes for rule matching
Browse files Browse the repository at this point in the history
added envoy dep
  • Loading branch information
yayann committed Jul 15, 2021
1 parent e62d4cf commit 5b6c0ee
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 18 deletions.
29 changes: 13 additions & 16 deletions app/Services/Rule/RuleFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,53 +100,50 @@ function ($job, $mapping) {
$mysgsValue = [$mysgsValue];
}

$matchedAtLeastOnce = false;
foreach ($mysgsValue as $index => $mysgsValue_single) {
if (empty($mysgsValue_single)) {
continue;
}
logger(sprintf('checking taxo %s for term "%s" against mysgs value: %s',
/*logger(sprintf('checking taxo "%s" for term "%s" against mysgs value: "%s"',
$term->taxonomy->name, $termValue, print_r($mysgsValue_single, true))
);
);*/
if (!(Str::is($termValue, Str::lower($mysgsValue_single))
|| (
isset($term->config['aliases'])
&& in_array(
Str::lower($mysgsValue_single),
array_map('Str::lower', $term->config['aliases'])
)
|| (isset($term->config['aliases'])
&& in_array( Str::lower($mysgsValue_single),
array_map('Str::lower', $term->config['aliases']))
)
)) {
logger(sprintf('rule %s dropped, term %s did not match with %s',
/*logger(sprintf('rule "%s": term "%s" did not match with "%s"',
$rule->id, $termValue, $mysgsValue_single)
);
);*/
$matched = false;
} else {
$matchedTaxonomies[$term->taxonomy->name] = true;
$matchedAtLeastOnce = true;

logger(sprintf('rule %s added, term %s matched with %s',
/*logger(sprintf('rule "%s": term "%s" matched with "%s"',
$rule->id, $termValue, $mysgsValue_single)
);
);*/

if (!in_array($term->name, $job_taxonomy_terms_matches[$term->taxonomy->name])) {
$job_taxonomy_terms_matches[$term->taxonomy->name][] = $term->name;
}
}
}

$matched = ($matched || $matchedAtLeastOnce);
}
}
}

$taxonomyMatch = true;
//logger('$matchedTaxonomies: ' . print_r($matchedTaxonomies, true));
foreach ($matchedTaxonomies as $taxonomy => $state) {
$taxonomyMatch &= $state;
}

if ($matched || $taxonomyMatch) {
$clientRules[] = $rule;
logger(sprintf('rule %s added, matched=%b taxoMatch=%b ',
$rule->id, $matched, $taxonomyMatch)
);
} else {
logger(sprintf('rule %s dropped, matched=%b taxoMatch=%b ',
$rule->id, $matched, $taxonomyMatch)
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laracademy/generators": "^3.0",
"laravel/envoy": "^2.7",
"laravel/sail": "^0.0.5",
"laravel/telescope": "^4.4",
"mockery/mockery": "^1.4.2",
Expand Down
66 changes: 64 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b6c0ee

Please sign in to comment.