Skip to content

Commit

Permalink
chg: [rearrange parameters] improve the way we allow users to rearran…
Browse files Browse the repository at this point in the history
…ge data

- tie more endpoints into the new findOrder() functionality
- allow for new context specific ordering rules
  • Loading branch information
iglocska committed Nov 28, 2022
1 parent afbe08d commit a73c1c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/Model/GalaxyCluster.php
Expand Up @@ -1063,8 +1063,12 @@ public function fetchGalaxyClusters(array $user, array $options, $full=false, $i
if (isset($options['group'])) {
$params['group'] = $options['group'];
}
if (isset($options['order'])) {
$params['order'] = $options['order'];
if (!empty($options['order'])) {
$options['order'] = $this->findOrder(
$options['order'],
'GalaxyCluster',
['id', 'event_id', 'version', 'type', 'value', 'distribution', 'orgc_id', 'org_id', 'tag_name', 'galaxy_id']
);
}
if (isset($options['page'])) {
$params['page'] = $options['page'];
Expand Down
11 changes: 9 additions & 2 deletions app/Model/Workflow.php
Expand Up @@ -1156,9 +1156,16 @@ public function fetchWorkflows(array $options = array(), $full = false)
if (isset($options['contain'])) {
$params['contain'] = !empty($options['contain']) ? $options['contain'] : [];
}
if (isset($options['order'])) {
$params['order'] = !empty($options['order']) ? $options['order'] : [];

$params['order'] = [];
if (!empty($options['order'])) {
$options['order'] = $this->findOrder(
$options['order'],
'Workflow',
['id', 'name', 'timestmap', 'trigger_id', 'counter']
);
}

$workflows = $this->find('all', $params);
return $workflows;
}
Expand Down
11 changes: 9 additions & 2 deletions app/Plugin/Assets/models/behaviors/LogableBehavior.php
Expand Up @@ -161,10 +161,17 @@ function findLog(&$Model, $params = array()) {
'limit' => 50);
$params = array_merge($defaults, $params);
$options = array(
'order' => $params['order'],
'conditions' => $params['conditions'],
'fields' => $params['fields'],
'limit' => $params['limit']);
'limit' => $params['limit']
);
if (!empty($options['order'])) {
$options['order'] = $Model->findOrder(
$options['order'],
'Attribute',
['id', 'action', 'model_id', 'model', 'ip', 'org', 'email']
);
}
if ($params[$this->settings[$Model->alias]['classField']] === NULL) {
$params[$this->settings[$Model->alias]['classField']] = $Model->alias;
}
Expand Down

0 comments on commit a73c1c4

Please sign in to comment.