allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [48/50] [abbrv] git commit: [#2053] Set correct indexing default for custom fields
Date Tue, 07 May 2013 22:30:18 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/6491901b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6491901b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6491901b

Branch: refs/heads/tv/2053
Commit: 6491901bcf349e5acba9ece6ff13a901945718a6
Parents: 6bde6ad
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue May 7 16:46:32 2013 -0400
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue May 7 18:28:56 2013 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6491901b/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