def get_search_results(self, req, terms, filters): """ Search through requirements. The search term may be <x y z> or x-y-z; both are interpreted as component, fp, and object. """ if not 'requirement' in filters: return if re.match(r'^([a-zA-Z_\d]+)-([a-zA-Z_\d]+)-([a-zA-Z_\d]+)$', terms[0]): terms = string.split(terms[0], '-') db = self.env.get_db_cnx() sql, args = search_to_sql(db, ['b.newvalue'], terms) sql2, args2 = search_to_sql(db, ['a.component', 'a.fp', 'a.object', 'a.description', 'a.creator'], terms) cursor = db.cursor() cursor.execute("SELECT DISTINCT a.component, a.fp, a.object, " "a.description, a.creator, a.time " "FROM requirement a " "LEFT JOIN requirement_change b " "ON a.component = b.component AND a.fp = b.fp AND a.object = b.object " "WHERE (b.field='comment' AND %s ) OR %s" % (sql, sql2), args + args2) for component, fp, object, desc, creator, date in cursor: requirement = '<%s %s %s> ' % (component, fp, object) yield (req.href.requirement('%s-%s-%s' % (component, fp, object)), requirement + shorten_line(desc), date, creator, shorten_result(desc, terms))
def get_search_results(self, req, terms, filters): if not "ticket" in filters: return db = self.env.get_db_cnx() sql, args = search_to_sql(db, ["b.newvalue"], terms) sql2, args2 = search_to_sql(db, ["summary", "keywords", "description", "reporter", "cc"], terms) cursor = db.cursor() cursor.execute( "SELECT DISTINCT a.summary,a.description,a.reporter, " "a.keywords,a.id,a.time,a.status FROM ticket a " "LEFT JOIN ticket_change b ON a.id = b.ticket " "WHERE (b.field='comment' AND %s ) OR %s" % (sql, sql2), args + args2, ) for summary, desc, author, keywords, tid, date, status in cursor: ticket = "#%d: " % tid if status == "closed": ticket = Markup('<span style="text-decoration: line-through">' "#%s</span>: ", tid) yield (req.href.ticket(tid), ticket + shorten_line(summary), date, author, shorten_result(desc, terms))
def get_search_results(self, req, terms, filters): if not 'ticket' in filters: return db = self.env.get_db_cnx() sql, args = search_to_sql(db, ['b.newvalue'], terms) sql2, args2 = search_to_sql(db, ['summary', 'keywords', 'description', 'reporter', 'cc'], terms) cursor = db.cursor() cursor.execute("SELECT DISTINCT a.summary,a.description,a.reporter, " "a.keywords,a.id,a.time,a.status FROM ticket a " "LEFT JOIN ticket_change b ON a.id = b.ticket " "WHERE (b.field='comment' AND %s ) OR %s" % (sql, sql2), args + args2) for summary, desc, author, keywords, tid, date, status in cursor: ticket = '#%d: ' % tid if status == 'closed': ticket = Markup('<span style="text-decoration: line-through">' '#%s</span>: ', tid) yield (req.href.ticket(tid), ticket + shorten_line(summary), date, author, shorten_result(desc, terms))
def get_search_results(self, req, terms, filters): if not 'changeset' in filters: return repos = self.env.get_repository(req.authname) db = self.env.get_db_cnx() sql, args = search_to_sql(db, ['message', 'author'], terms) cursor = db.cursor() cursor.execute("SELECT rev,time,author,message " "FROM revision WHERE " + sql, args) for rev, date, author, log in cursor: if not repos.authz.has_permission_for_changeset(rev): continue yield (req.href.changeset(rev), '[%s]: %s' % (rev, shorten_line(log)), date, author, shorten_result(log, terms))
def get_search_results(self, req, terms, filters): if not 'wiki' in filters: return db = self.env.get_db_cnx() sql_query, args = search_to_sql(db, ['w1.name', 'w1.author', 'w1.text'], terms) cursor = db.cursor() cursor.execute("SELECT w1.name,w1.time,w1.author,w1.text " "FROM wiki w1," "(SELECT name,max(version) AS ver " "FROM wiki GROUP BY name) w2 " "WHERE w1.version = w2.ver AND w1.name = w2.name " "AND " + sql_query, args) for name, date, author, text in cursor: yield (req.href.wiki(name), '%s: %s' % (name, shorten_line(text)), date, author, shorten_result(text, terms))
def get_search_results(self, req, terms, filters): if not 'wiki' in filters: return db = self.env.get_db_cnx() sql_query, args = search_to_sql(db, ['w1.name', 'w1.author', 'w1.text'], terms) cursor = db.cursor() cursor.execute( "SELECT w1.name,w1.time,w1.author,w1.text " "FROM wiki w1," "(SELECT name,max(version) AS ver " "FROM wiki GROUP BY name) w2 " "WHERE w1.version = w2.ver AND w1.name = w2.name " "AND " + sql_query, args) for name, date, author, text in cursor: yield (req.href.wiki(name), '%s: %s' % (name, shorten_line(text)), date, author, shorten_result(text, terms))