<?php apf_require_class('Util_SolrFactory'); apf_require_class('Bll_TicketBiz'); apf_require_class('Model_Ticket'); apf_require_class('Bll_TicketLogBiz'); apf_require_class('Bll_TicketCcBiz'); apf_require_class('GlobalFunc'); apf_require_class('Bll_TicketRelationBiz'); $solr = Util_SolrFactory::get_instance()->get_solr(); $id = @intval($argv[2]); if (empty($id)) { $id = @intval(file_get_contents('/tmp/ibug_ticket_log_id')); } $logs = Bll_TicketLogBiz::get_instance()->get_ticket_ids_great_than_id($id, 500); if (empty($logs)) { echo date('c ') . "No tickets to update\n"; exit(0); } $ticket_ids = array(); foreach ($logs as $ticket_log) { $ticket_ids[] = $ticket_log->ticket_id; } $id = $ticket_log->id; $dao = Model_Ticket::data_access(); $ticket_ids = array_unique($ticket_ids); $tickets = $dao->find_by_pks($ticket_ids); $tickets = Bll_TicketBiz::get_instance()->process_solr_field($tickets); $_ticket_ccs = Bll_TicketCcBiz::get_instance()->get_ticket_cc_by_ticket_ids($ticket_ids); $ticket_ccs = array(); if (!empty($_ticket_ccs)) {
protected function get_results() { $q = $this->request->get_parameter('q'); $sort_by = @$this->request->get_parameter('sort_by'); $sort_by = empty($sort_by) ? 'id' : $sort_by; $this->sort = $sort_by; $sort_order = @$this->request->get_parameter('sort_order'); $sort_order = empty($sort_order) ? 'desc' : $sort_order; $this->group_order = $sort_order; $sort_c = @$this->request->get_parameter('sort_c'); $sort_c = empty($sort_c) ? 'id' : $sort_c; $this->sort_c = $sort_c; $sort_o = @$this->request->get_parameter('sort_o'); $sort_o = empty($sort_o) ? 'desc' : $sort_o; $this->sort_o = $sort_o; if ($sort_by != 'id') { if (!empty($sort_c)) { $sort = "{$sort_by} {$sort_order}, {$sort_c} {$sort_o}"; } else { $sort = "{$sort_by} {$sort_order}, id desc"; } } else { $sort = "{$sort_c} {$sort_o}"; } $rows = @intval($this->request->get_parameter('rows')); $rows = empty($rows) ? 300 : $rows; $start = 0; $params = $this->request->get_parameters(); $user_querys = array(); $fields = array_keys($this->fields); $user_inputs = array(); foreach ($fields as $field) { if (empty($params[$field])) { continue; } if (empty($params[$field]['v'])) { continue; } if ($field != 'component' && $field != 'created_at' && $field != 'closed_at' && $field != 'updated_at' && $params[$field]['v'][0] == '') { $user_inputs[$field]['t'] = $this->fields[$field]['type']; $user_inputs[$field]['o'] = $params[$field]['o']; $user_inputs[$field]['v'] = array(''); continue; } $user_inputs[$field]['t'] = $this->fields[$field]['type']; $user_inputs[$field]['o'] = $params[$field]['o']; $user_inputs[$field]['v'] = array(); $sub_querys = array(); foreach ($params[$field]['v'] as $v) { if (!is_array($v)) { $v = trim($v); } if ($v === '') { continue; } if ($this->fields[$field]['type'] == 'dateinput') { $v['b'] = trim($v['b']); $v['e'] = trim($v['e']); $_user_input = array(); $date_begin = '*'; $date_end = '*'; if ($v['b']) { $date_begin = strtotime($v['b']); if ($date_begin <= 0) { $date_begin = '*'; } $_user_input['b'] = $v['b']; } if ($v['e']) { $date_end = strtotime($v['e'] . ' 23:59:59'); if ($date_end <= 0) { $date_end = '*'; } $_user_input['e'] = $v['e']; } if ($date_begin == '*' && $date_end == '*') { continue; } $sub_querys[] = "{$field}:[{$date_begin} TO {$date_end}]"; $user_inputs[$field]['v'][] = $_user_input; } else { $user_inputs[$field]['v'][] = $v; if ($field == 'owner' || $field == 'assigned_qa' || $field == 'reporter') { $v_tmp = $v; $v = Bll_UserBiz::get_instance()->get_username_by_wholename($v); if (!$v) { $v = $v_tmp; } } else { if ($field == 'priority' || $field == 'environment' || $field == 'department' || $field == 'resolution' || $field == 'reason') { $v_tmp = $v; if ($v_tmp == '0') { $v = ""; } else { $v = Bll_DdCommonBiz::get_instance()->get_name_by_id($v_tmp); } } else { if ($field == 'component') { $v1 = Bll_DdComponentBiz::get_instance()->get_name_by_id($v['c']); $v2 = Bll_DdCommonBiz::get_instance()->get_name_by_id($v['d']); $sub_querys[] = "(department:\"{$v2}\" AND component:\"{$v1}\")"; continue; } else { if ($field == 'keyword') { if ($user_inputs[$field]['o'] == 'ticket title') { $sub_querys[] = "summary:({$v})"; } if ($user_inputs[$field]['o'] == 'ticket description') { $sub_querys[] = "description:({$v})"; } continue; } } } } $sub_querys[] = "{$field}:\"{$v}\""; } } if (empty($sub_querys)) { continue; } $sub_querys_str = "(" . join(' OR ', $sub_querys) . ")"; if ($params[$field]['o'] == 'is not') { $sub_querys_str = '-' . $sub_querys_str; } $user_querys[] = $sub_querys_str; } $q = join(" AND ", $user_querys); try { $solr = Util_SolrFactory::get_instance()->get_solr(); $results = $solr->search($q, array('wt' => 'json', 'sort' => $sort), $start, $rows); } catch (Exception $e) { $this->page_status = 'solrexception'; } return $results; }