function get_gpu_list($vendor, $alt_vendor = null) { $clause = "plan_class like '%{$vendor}%'"; if ($alt_vendor) { $clause .= " or plan_class like '%{$alt_vendor}%'"; } $avs = BoincAppVersion::enum($clause); if (count($avs) == 0) { return null; } $av_ids = ""; foreach ($avs as $av) { $av_ids .= "{$av->id}, "; } $av_ids .= "0"; $t = time() - 30 * 86400; //echo "start enum $vendor $av_ids\n"; $results = BoincResult::enum("app_version_id in ({$av_ids}) and create_time > {$t} and elapsed_time>100 limit 500"); //echo "end enum\n"; $total = array(); $win = array(); $linux = array(); $mac = array(); foreach ($results as $r) { $h = BoincHost::lookup_id($r->hostid); if (!$h) { continue; } $wu = BoincWorkunit::lookup_id($r->workunitid); if (!$wu) { continue; } $v = ""; if ($vendor == "cuda") { $v = "CUDA"; } else { if ($vendor == "intel_gpu") { $v = "INTEL"; } else { $v = "CAL"; } } $model = get_gpu_model($h->serialnum, $v); if (!$model) { continue; } add_model($model, $r, $wu, $total); if (strstr($h->os_name, "Windows")) { add_model($model, $r, $wu, $win); } if (strstr($h->os_name, "Linux")) { add_model($model, $r, $wu, $linux); } if (strstr($h->os_name, "Darwin")) { add_model($model, $r, $wu, $mac); } } $x = new StdClass(); $x->total = $total; $x->win = $win; $x->linux = $linux; $x->mac = $mac; return $x; }
error("\n Missing model name\n"); } else { $fields = array(); foreach ($params as $i => $one) { if (strpos($one, ':')) { @(list($field, $type) = explode(':', $one)); if (!field_for($type)) { return error("\n Unknown '{$type}' type on '{$field}' field\n"); } else { $fields[$field] = compact('type'); } } } if (!$fields) { error("\n Missing columns for '{$name}' model\n"); } else { $out_file = path(APP_PATH, 'app', 'models', "{$name}.php"); if (arg('t timestamps')) { $fields['created_at'] = $fields['modified_at'] = array('type' => 'timestamp'); } if (!is_file($out_file) or arg('f force')) { $table = arg('n table'); $extends = arg('x extends') ?: 'database'; $conn = arg('c connection') ?: 'default'; $idx = array_filter(explode(',', arg('i indexes'))); add_model($name, $table, $fields, $idx, $extends, $conn); } else { error("\n Model '{$name}' already exists\n"); } } }