function execute() { global $wgOut, $wgRequest; require_once 'dedupQuery.php'; $action = $wgRequest->getVal('act'); if ($action == NULL) { EasyTemplate::set_path(dirname(__FILE__)); $wgOut->addHTML(EasyTemplate::html('CommunityExpert.tmpl.php')); } elseif ($action == "get") { $url = $wgRequest->getVal('url'); $query = $this->getQueryFromUrl($url); if ($query) { dedupQuery::addQuery($query); dedupQuery::matchQueries(array($query)); $dbr = wfGetDB(DB_SLAVE); $sql = "select user_name,tq.tq_title as title, sum(ct) as score from firstedit join dedup.title_query tq on tq.tq_page_id=fe_page join dedup.query_match on tq.tq_query=query2 join wiki_shared.user on fe_user=user_id where query1=" . $dbr->addQuotes($query) . " group by fe_user order by score desc"; $dbr = wfGetDB(DB_SLAVE); $res = $dbr->query($sql, __METHOD__); header("Content-Type: text/tsv"); header('Content-Disposition: attachment; filename="Dedup.xls"'); print "User page\tRelated title\n"; foreach ($res as $row) { print "http://www.wikihow.com/User:"******"\thttp://www.wikihow.com/" . str_replace(" ", "-", $row->title) . "\n"; } exit; } else { print "NO URL"; exit; } } }
public function getBatch() { set_time_limit(0); require_once 'dedupQuery.php'; $queries = preg_split("@[\r\n]+@", $this->queriesR); $dbw = wfGetDB(DB_MASTER); $queryE = array(); foreach ($queries as $query) { dedupQuery::addQuery($query); $queryE[] = $dbw->addQuotes($query); } dedupQuery::matchQueries($queries); $dbr = wfGetDB(DB_SLAVE); $sql = "select query1, query2, ct, tq_title from dedup.query_match left join dedup.title_query on tq_query=query2 where query1 in (" . implode($queryE, ",") . ") order by query1, ct desc"; $res = $dbr->query($sql, __METHOD__); $query = false; header("Content-Type: text/tsv"); header('Content-Disposition: attachment; filename="Dedup.xls"'); print "Query\tWhat to do\tclosest URL match\tclosest URL score\tquery matches >= 35\tnext closest URL matches (max 5)\n"; $this->closestUrls = array(); $this->query = false; $this->queryMatches = array(); foreach ($res as $row) { if ($this->query != $row->query1) { if ($this->query) { $this->printLine(); } $this->queryMatches = array(); $this->closestUrls = array(); $this->query = $row->query1; } if ($row->ct >= 35 && $row->query1 != $row->query2) { $this->queryMatches[] = $row->query2; } if ($row->tq_title) { $this->closestUrls[] = array('url' => "http://www.wikihow.com/" . str_replace(" ", "-", $row->tq_title), 'score' => $row->ct); } } if ($this->query) { $this->printLine(); } exit; }