chg: [decaying:tool] Filter taxonomies not having numerical score

pull/5032/head
mokaddem 2019-06-25 11:46:23 +02:00
parent 825fd25834
commit eb21705fc5
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 72 additions and 5 deletions

View File

@ -180,8 +180,8 @@ class DecayingModelController extends AppController
}
public function decayingToolBasescore() {
$this->loadModel('Taxonomy');
$taxonomies = $this->Taxonomy->listTaxonomies();
$this->set('taxonomies', $taxonomies);
$taxonomies = $this->DecayingModel->listTaxonomiesWithNumericalValue();
$this->set('taxonomies', $taxonomies['taxonomies']);
$this->set('taxonomies_not_having_numerical_value', $taxonomies['not_having_numerical_value']);
}
}

View File

@ -164,4 +164,39 @@ class DecayingModel extends AppModel
return false;
}
// filter out taxonomies and entries not having a numerical value
public function listTaxonomiesWithNumericalValue()
{
$this->Taxonomy = ClassRegistry::init('Taxonomy');
$taxonomies = $this->Taxonomy->listTaxonomies(array('full' => true, 'enabled' => true));
$start_count = count($taxonomies);
foreach ($taxonomies as $namespace => $taxonomy) {
if(!empty($taxonomy['TaxonomyPredicate'])) {
foreach($taxonomy['TaxonomyPredicate'] as $p => $predicate) {
if(!empty($predicate['TaxonomyEntry'])) {
foreach ($predicate['TaxonomyEntry'] as $e => $entry) {
if (!is_numeric($entry['numerical_value'])) {
unset($taxonomies[$namespace]['TaxonomyPredicate'][$p]['TaxonomyEntry'][$e]);
}
}
if (empty($taxonomies[$namespace]['TaxonomyPredicate'][$p]['TaxonomyEntry'])) {
unset($taxonomies[$namespace]['TaxonomyPredicate'][$p]);
}
} else {
unset($taxonomies[$namespace]['TaxonomyPredicate'][$p]);
}
}
if (empty($taxonomies[$namespace]['TaxonomyPredicate'])) {
unset($taxonomies[$namespace]);
}
} else {
unset($taxonomies[$namespace]);
}
}
return array(
'taxonomies' => $taxonomies,
'not_having_numerical_value' => $start_count - count($taxonomies)
);
}
}

View File

@ -2,6 +2,7 @@
<div class="span8" style="height: calc(90vh); overflow-y: scroll; border: 1px solid #ddd;">
<input id="table_taxonomy_search" class="input" style="width: 250px; margin: 0px;" type="text" placeholder="<?php echo _('Search Taxonomy'); ?>"></input>
<it class="fa fa-times useCursorPointer" title="<?php echo __('Clear search field'); ?>" onclick="$('#table_taxonomy_search').val('').trigger('input');"></it>
<span style="float: right;"><b><?php echo h($taxonomies_not_having_numerical_value); ?></b><?php echo __(' not having numerical value'); ?></span>
<table id="tableTaxonomy" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
@ -28,18 +29,49 @@
<div style="margin-bottom: 5px;">
<div id="treemapGraphTax" style="border: 1px solid #dddddd; border-radius: 4px; text-align: center;"></div>
</div>
<div style="margin-bottom: 5px; border: 1px solid #dddddd; border-radius: 4px; text-align: center; background-color: white;">
<?php echo __('Placeholder for `Organisation source confidence`') ?>
</div>
<div>
<h3><?php echo __('Example') ?></h3>
<table id="tableTaxonomy" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th><?php echo __('Example') ?></th>
<th>Attribute</th>
<th>Tags</th>
<th>Base score</th>
</tr>
</thead>
<tbody>
<tr>
<td>
cscsc
Tag your attribute
</td>
<td>
<div style="width:100%;display:inline-block;" data-original-title="" title="">
<div style="float:left" data-original-title="" title="">
<button id="basescore-example-score-addTagButton" class="btn btn-inverse noPrint" style="line-height:10px; padding: 4px 4px;" title="Add tag" onclick="popoverPopup(this, '0', 'tags', 'selectTaxonomy');">+</button>
</div>
</div>
</td>
<td id="basescore-example-score-custom">
Base score
</td>
</tr>
<tr>
<td>Attribute 1</td>
<td id="basescore-example-tag-1">tags</td>
<td id="basescore-example-score-1">100</td>
</tr>
<tr>
<td>Attribute 2</td>
<td id="basescore-example-tag-2">tags</td>
<td id="basescore-example-score-2">100</td>
</tr>
<tr>
<td>Attribute 3</td>
<td id="basescore-example-tag-3">tags</td>
<td id="basescore-example-score-3">100</td>
</tr>
</tbody>
</table>