[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819

Sebastian Krzyszkowiak seba.dos1 at gmail.com
Sat Aug 6 08:18:06 UTC 2011


The following commit has been merged in the debian branch:
commit fdad05603d63fb38cf1c0c37cf0979f2527c7fd5
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date:   Wed Aug 26 11:47:58 2009 +0200

    opimd: add new mode in quering: at least one
    
    To use it, set _at_least_one field to non-false value.
    In this mode returned entries match to at least one field in query.

diff --git a/framework/subsystems/opimd/docs/TODO b/framework/subsystems/opimd/docs/TODO
index 7a712df..78003e9 100644
--- a/framework/subsystems/opimd/docs/TODO
+++ b/framework/subsystems/opimd/docs/TODO
@@ -10,7 +10,6 @@ After that:
 * RSS-Messages backend (handler)
 * Messages on GenericDomain
 Think about:
-* way for quering using all or multiple fields?
 * more domains?
 Finishing:
 * faster merging and avoiding duplicates
diff --git a/framework/subsystems/opimd/pimd_generic.py b/framework/subsystems/opimd/pimd_generic.py
index c0e8848..d6d15c5 100644
--- a/framework/subsystems/opimd/pimd_generic.py
+++ b/framework/subsystems/opimd/pimd_generic.py
@@ -323,6 +323,11 @@ class GenericEntry():
 
         overall_match = 1.0
 
+        atleast = query_obj.get('_at_least_one')
+
+        if atleast:
+            overall_match = 0.0
+
         for field_name in query_obj.keys():
 
             if field_name.startswith('_') and (field_name.startswith('_int_') or field_name.startswith('_float_') or field_name.startswith('_gt_') or field_name.startswith('_lt_')):
@@ -351,22 +356,32 @@ class GenericEntry():
                         if comp_value:
                             comp_value = mytype(comp_value)
                         else:
-                            overall_match *= 0.0
+                            if not atleast:
+                                overall_match *= 0.0
                             continue
 
                         if operator == 'gt':
                             if comp_value > field_value:
-                                overall_match *= 1.0
+                                if not atleast:
+                                    overall_match *= 1.0
+                                else:
+                                    overall_match += 1.0
                             else:
-                                overall_match *= 0.0
+                                if not atleast:
+                                    overall_match *= 0.0
                         elif operator == 'lt':
                             if comp_value < field_value:
-                                overall_match *= 1.0
+                                if not atleast:
+                                    overall_match *= 1.0
+                                else:
+                                    overall_match += 1.0
                             else:
-                                overall_match *= 0.0
+                                if not atleast:
+                                    overall_match *= 0.0
 
                 except KeyError:
-                    overall_match *= 0.0
+                    if not atleast:
+                        overall_match *= 0.0
                 continue
 
             # Skip fields only meaningful to the parser
@@ -413,10 +428,13 @@ class GenericEntry():
             # Aggregate the field match value into the overall match
             # We don't use the average of all field matches as one
             # non-match *must* result in a final value of 0.0
-            overall_match *= best_field_match
-
-            # Stop comparing if there is too little similarity
-            if overall_match == 0.0: break
+            if not atleast:
+                overall_match *= best_field_match
+                # Stop comparing if there is too little similarity
+                if overall_match == 0.0: break
+            else:
+                overall_match += best_field_match
+                if overall_match > 0.0: break
 
         return overall_match
 

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list