Author: enrico
Date: 2007-07-02 09:11:18 +0000 (Mon, 02 Jul 2007)
New Revision: 3179

Modified:
   software/ui/src/Engine.cpp
Log:
Engine now does the right thing with tags

Modified: software/ui/src/Engine.cpp
===================================================================
--- software/ui/src/Engine.cpp  2007-07-02 08:46:34 UTC (rev 3178)
+++ software/ui/src/Engine.cpp  2007-07-02 09:11:18 UTC (rev 3179)
@@ -26,6 +26,16 @@
 using namespace ept::apt;
 using namespace ept::debtags;
 
+static Xapian::Query allGames(Vocabulary& voc)
+{
+       set<Tag> games = voc.tags("game");
+       vector<string> terms;
+       for (set<Tag>::const_iterator i = games.begin();
+                       i != games.end(); ++i)
+               terms.push_back("T" + i->fullname());
+       return Xapian::Query(Xapian::Query::OP_OR, terms.begin(), terms.end());
+}
+
 Xapian::Query Engine::makeQuery()
 {
        Xapian::Query query;
@@ -45,15 +55,13 @@
                        if (ifacequery.empty())
                        {
                                // If there is no query, default to querying 
all games
-                               set<Tag> games = voc().tags("game");
-                               vector<string> terms;
-                               for (set<Tag>::const_iterator i = games.begin();
-                                               i != games.end(); ++i)
-                                       terms.push_back("T" + i->fullname());
-                               query = Xapian::Query(Xapian::Query::OP_OR, 
terms.begin(), terms.end());
+                               query = allGames(voc());
                        }
                        else
-                               query = ifacequery;
+                       {
+                               // Otherwise, all games with given interface
+                               query = Xapian::Query(Xapian::Query::OP_AND, 
ifacequery, allGames(voc()));
+                       }
                else
                        if (ifacequery.empty())
                                query = typequery;
@@ -62,9 +70,10 @@
        else
                if (typequery.empty())
                        if (ifacequery.empty())
-                               query = kwquery;
+                               query = Xapian::Query(Xapian::Query::OP_AND, 
kwquery, allGames(voc()));
                        else
-                               query = Xapian::Query(Xapian::Query::OP_AND, 
kwquery, ifacequery);
+                               query = Xapian::Query(Xapian::Query::OP_AND, 
kwquery,
+                                                       
Xapian::Query(Xapian::Query::OP_AND, ifacequery, allGames(voc())));
                else
                        if (ifacequery.empty())
                                query = Xapian::Query(Xapian::Query::OP_AND, 
kwquery, typequery);
@@ -86,9 +95,12 @@
        m_interfaces.clear();
        m_res_max = 0;
 
+       cerr << "Engine recompute:" << endl;
+
        // Compute the types
        if (m_filter_type.valid())
        {
+               cerr << "  filter type: " << m_filter_type.fullname() << endl;
                Tag tmp = m_filter_type;
                m_filter_type = Tag();
                Xapian::Enquire enquire(m_textsearch.db());
@@ -106,11 +118,14 @@
                                        m_types.insert(*j);
                }
                m_filter_type = tmp;
+       } else {
+               cerr << "  no filter type" << endl;
        }
 
        // Compute the interfaces
        if (m_filter_iface.valid())
        {
+               cerr << "  filter iface: " << m_filter_iface.fullname() << endl;
                Tag tmp = m_filter_iface;
                m_filter_iface = Tag();
                Xapian::Enquire enquire(m_textsearch.db());
@@ -128,13 +143,15 @@
                                        m_interfaces.insert(*j);
                }
                m_filter_iface = tmp;
+       } else {
+               cerr << "  no filter iface" << endl;
        }
 
        Xapian::Enquire enquire(m_textsearch.db());
        // We always want programs, so always AND it here
        enquire.set_query(makeQuery());
 
-       //cerr << "QUERY: " << enquire.get_query().get_description() << endl;
+       cerr << "  filter query: " << enquire.get_query().get_description() << 
endl;
 
        // Get the 100 top matches
        Xapian::MSet matches = enquire.get_mset(0, 100);


_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-games-commits

Reply via email to