Index: view/sites/all/modules/scan_api/scan_api.module =================================================================== --- view/sites/all/modules/scan_api/scan_api.module (revision 34365) +++ view/sites/all/modules/scan_api/scan_api.module (working copy) @@ -187,6 +187,11 @@ 'type' => MENU_CALLBACK, 'page callback' => 'scan_archive_velocity', ); + $items['scan.ex2.topics'] = array( + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + 'page callback' => 'scan_ex2_topics', + ); return $items; } @@ -262,6 +267,14 @@ if (!empty($_GET['snapshot_id']) && is_numeric($_GET['snapshot_id'])) { $snapshot_id = $_GET['snapshot_id']; } + $ex2_edition = ''; + if (!empty($_GET['ex2_edition'])) { + $ex2_edition = $_GET['ex2_edition']; + } + $ex2_channel = ''; + if (!empty($_GET['ex2_channel'])) { + $ex2_channel = $_GET['ex2_channel']; + } return array( 'scan_id' => $scan_id, 'client_id' => $client_id, @@ -281,6 +294,8 @@ 'loc_includes' => $loc_includes, 'loc_excludes' => $loc_excludes, 'snapshot_id' => $snapshot_id, + 'ex2_edition' => $ex2_edition, + 'ex2_channel' => $ex2_channel, ); } @@ -2129,6 +2144,70 @@ print _scan_api_format($return, $format); } +/** + * Get examiner 2 scans from topic group. + */ +function scan_ex2_topics() { + // ex2_edition, ex2_channel + extract(_scan_get_args()); + + $scans = array(); + $scan_ids = array(); + $return = array(); + + $edition = db_fetch_object(db_query("SELECT n.title, n.nid, s.scan_id FROM {node} n INNER JOIN {scan_destination} d ON n.nid = d.nid INNER JOIN {og_ancestry} o ON d.nid = o.nid INNER JOIN {scan_settings} ss ON n.nid = ss.nid INNER JOIN {scan} s ON ss.active_vid = s.vid WHERE d.page_id = '%s' AND o.group_nid = %d", $ex2_edition, 20535)); + $channel = db_fetch_object(db_query("SELECT n.title, n.nid, s.scan_id FROM {node} n INNER JOIN {scan_destination} d ON n.nid = d.nid INNER JOIN {og_ancestry} o ON d.nid = o.nid INNER JOIN {scan_settings} ss ON n.nid = ss.nid INNER JOIN {scan} s ON ss.active_vid = s.vid WHERE d.page_id = '%s' AND o.group_nid = %d", $ex2_channel, 40169)); + + $scans[$edition->scan_id] = $edition; + $scan_ids[] = $edition->scan_id; + $scans[$channel->scan_id] = $channel; + $scan_ids[] = $channel->scan_id; + + $result = db_query_range("SELECT n.title, n.nid, s.scan_id + FROM {content_type_scan} c + INNER JOIN {scan_settings} ss ON ss.active_vid = c.vid + INNER JOIN {node_revisions} n ON n.vid = c.vid + INNER JOIN {scan} s ON s.vid = c.vid + WHERE ss.status = 1 AND c.field_ex2_channel_value = %d ORDER BY c.vid DESC", $channel->nid, 0, 10); + + while ($row = db_fetch_object($result)) { + $scans[$row->scan_id] = $row; + $scan_ids[] = $row->scan_id; + } + + if ($cursor = scan_api_get_mongo('scan')) { // V2r15 / scan / scan_id[] / none + $query = array( +// 'velocity.minutes_scan' => array('$gt' => 0), + 'scan_id' => array('$in' => $scan_ids), + ); + $fields = array( + 'scan_id' => 1, + 'velocity.minutes_scan' => 1, + ); + try { + $cursor + ->find($query, $fields) + ->timeout(scan_api_get_mongo_timeout()); + foreach ($cursor as $row) { + $scans[$row['scan_id']]->velocity = $row['velocity']['minutes_scan']; + } + } + catch (MongoCursorTimeoutException $e) { + } + } + + foreach ($scans as $scan) { + if ($scan->velocity > 0 || count($return) <= 2) { + $return[] = $scan; + } + if (count($return) >= 7) { + break; + } + } + + print _scan_api_format($return, $format); +} + function _scan_api_format($return, $format = NULL) { _scan_get_format($format); $prefix = $postfix = '';