--- a/qmsk/irclogs/log_search.py Sun Sep 13 01:15:56 2009 +0300
+++ b/qmsk/irclogs/log_search.py Sun Sep 13 18:47:00 2009 +0300
@@ -286,22 +286,17 @@
# execute
return self.search_cond(cond)
- def search_simple (self, channel, query, count=None, offset=None, search_msg=True, search_nick=False) :
+ def search_simple (self, channel, query, count=None, offset=None) :
"""
Search for lines from the given channel for the given simple query.
- The search_* params define which attributes to search for (using fulltext search for the message, STROR for
- attributes).
+ The given text is searched for in the text of the given channel's entries, and the list of results in
+ reverse time order is returned.
"""
# search attributes
attrs = []
- # nickname target query
- if search_nick :
- attrs.append("source_nickname STRINC %s" % query)
-# attrs.append("target_nickname STRINC %s" % query)
-
# use search(), backwards
results = list(self.search(
# simplified phrase
@@ -311,7 +306,43 @@
channel = channel,
# given phrase
- phrase = query if search_msg else None,
+ phrase = query,
+
+ # attributes defined above
+ attrs = attrs,
+
+ # order by timestamp, descending (backwards)
+ order = "timestamp NUMD",
+
+ # count/offset
+ max = count,
+ skip = offset,
+ ))
+
+ # reverse
+ return reversed(results)
+
+ def search_advanced (self, channel, phrase=None, nick_query=None, count=None, offset=None) :
+ """
+ Search for lines from the given channel for the given full-featured query.
+
+ The given phrase is used to build the condition, or alternatively, the given extra *_query parameters can
+ be used to specific additional attributes to search.
+ """
+
+ attrs = []
+
+ if nick_query :
+ # search for messages from specific nickname
+ attrs.append("source_nickname STRINC %s" % nick_query)
+
+ # use search(), backwards
+ results = list(self.search(
+ # specific channel
+ channel = channel,
+
+ # given phrase
+ phrase = phrase,
# attributes defined above
attrs = attrs,