allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [16/50] [abbrv] git commit: [#2053] Set correct indexing default for custom fields
Date Thu, 16 May 2013 22:30:07 GMT
[#2053] Set correct indexing default for custom fields

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d76add9d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d76add9d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d76add9d

Branch: refs/heads/db/6208
Commit: d76add9d7a344043b4b6b08b4edcd0d8ee440e9a
Parents: 1da9c34
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue May 7 16:46:32 2013 -0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri May 10 21:39:39 2013 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d76add9d/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 3e2fde2..591495f 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -48,6 +48,11 @@ from forgetracker.plugins import ImportIdConverter
 log = logging.getLogger(__name__)
 
 CUSTOM_FIELD_SOLR_TYPES = dict(boolean='_b', number='_i')
+SOLR_TYPE_DEFAULTS = dict(_b=False, _i=0)
+
+
+def get_default_for_solr_type(solr_type):
+    return SOLR_TYPE_DEFAULTS.get(solr_type, u'')
 
 config = utils.ConfigProxy(
     common_suffix='forgemail.domain',
@@ -365,16 +370,16 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             import_id_s=ImportIdConverter.get().simplify(self.import_id)
             )
         for k, v in self.custom_fields.iteritems():
-            field_value = unicode(v)
             # Pre solr-4.2.1 code expects all custom fields to be indexed
             # as strings.
             if not config.get_bool('new_solr'):
-                result[k + '_s'] = field_value
+                result[k + '_s'] = unicode(v)
 
             # Now let's also index with proper Solr types.
             solr_type = self.app.globals.get_custom_field_solr_type(k)
             if solr_type:
-                result[k + solr_type] = field_value
+                result[k + solr_type] = (v or
+                        get_default_for_solr_type(solr_type))
 
         if self.reported_by:
             result['reported_by_s'] = self.reported_by.username


Mime
View raw message