Commit d0cd9e35 authored by Ziwen Su's avatar Ziwen Su

Adjusted the backend of Jobtag.

parent 48515bb9
......@@ -18,7 +18,7 @@
'NODENAME' => ['(NODELIST LIKE :node1 OR CPULIST LIKE :node2)', [':node1', ':node2']],
'TAGS' => ['TAGS = :tags',':tags'],
'TAGS' => ['TAGS = :tag0', '( TAGS & :tag0 ) = :tag0', '( TAGS & :tag1 ) = :tag1', '( TAGS & :tag2 ) = :tag2', '( TAGS & :tag3 ) = :tag3', '( TAGS & :tag4 ) = :tag4', [':tag0', ':tag1', ':tag2', ':tag3', ':tag4']],
'NUM_NODES_INT' => ['NUM_NODES BETWEEN :min_nodes AND :max_nodes', 'NUM_NODES >=:min_nodes', 'NUM_NODES <=:max_nodes', [':min_nodes', ':max_nodes']],
'NUM_CORES_INT' => ['NUM_CORES BETWEEN :min_cores AND :max_cores', 'NUM_CORES >=:min_cores', 'NUM_CORES <=:max_cores', [':min_cores', ':max_cores']],
'WALLTIME_INT' => ['WALLTIME BETWEEN :min_walltime AND :max_walltime', 'WALLTIME >=:min_walltime', 'WALLTIME <=:max_walltime', [':min_walltime', ':max_walltime']],
......@@ -52,13 +52,13 @@
if ( sizeof($items) == 3 ) {
$attribute_key1 = ":fp1_".$items[0];
$attribute_key2 = ":fp2_".$items[0];
if ( !is_numeric($items[2]) ){
if ( !is_numeric($items[2]) ) {
$sql .= "AND ".$column_name." >= ".$attribute_key1." ";
$attributes[$attribute_key1] = $items[1];
} elseif ( !is_numeric($items[1]) ){
} elseif ( !is_numeric($items[1]) ) {
$sql .= "AND ".$column_name." <= ".$attribute_key2." ";
$attributes[$attribute_key2] = $items[2];
} else{
} else {
$sql .= "AND ".$column_name." BETWEEN ".$attribute_key1." AND ".$attribute_key2." ";
$attributes[$attribute_key1] = $items[1];
$attributes[$attribute_key2] = $items[2];
......@@ -68,16 +68,28 @@
} elseif ( $key == "NODENAME" ) {
$sql .= "AND ".$filterArray[$key][0]." ";
$attributes[$filterArray[$key][1][0]] = $value;
$attributes[$filterArray[$key][1][1]] = $value;
$attributes[$filterArray[$key][1][1]] = $value;
} else if ( $key == "TAGS" ) {
$items = explode(" ", $value);
$n = sizeof($items);
if ( $n > 1 ) {
for ( $i=0; $i<$n; $i++ ){
$sql .= "AND ".$filterArray[$key][$i+1]." ";
$attributes[$filterArray[$key][6][$i]] = $items[$i];
}
} else {
$sql .= "AND ".$filterArray[$key][0]." ";
$attributes[$filterArray[$key][6][0]] = $items[0];
}
} elseif ( strpos($key, '_INT') !== false ) {
$items = explode(" ", $value);
if ( !is_numeric($items[1]) ){
if ( !is_numeric($items[1]) ) {
$sql .= "AND ".$filterArray[$key][1]." ";
$attributes[$filterArray[$key][3][0]] = $items[0];
} elseif( !is_numeric($items[0]) ){
} elseif( !is_numeric($items[0]) ) {
$sql .= "AND ".$filterArray[$key][2]." ";
$attributes[$filterArray[$key][3][1]] = $items[1];
} else{
} else {
$sql .= "AND ".$filterArray[$key][0]." ";
$attributes[$filterArray[$key][3][0]] = $items[0];
$attributes[$filterArray[$key][3][1]] = $items[1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment