Correction bug #20. The solution is mainly to make sure that the index is recalculated
authorymh <ymh.work@gmail.com>
Mon, 11 Jul 2011 17:03:23 +0200
changeset 83 1c4729b3dac1
parent 82 0f2844b9ae41
child 84 84dc6383323d
Correction bug #20. The solution is mainly to make sure that the index is recalculated
web/hdabo/.htaccess.mod_wsgi.tmpl
web/hdabo/management/commands/import_tag_popularity.py
web/hdabo/modwsgi.wsgi
web/hdabo/wp_utils.py
--- a/web/hdabo/.htaccess.mod_wsgi.tmpl	Fri Jul 08 23:28:33 2011 +0200
+++ b/web/hdabo/.htaccess.mod_wsgi.tmpl	Mon Jul 11 17:03:23 2011 +0200
@@ -1,7 +1,8 @@
 
 SetEnv DJANGO_SETTINGS_MODULE hdabo.settings
 SetEnv PROJECT_PATH /Users/ymh/dev/workspace/hdabo/web
-SetEnv PYTHON_PATH /Users/ymh/dev/workspace/hdabo/virtualenv/web/env/hdabo/lib/python2.6/site-packages
+SetEnv PYTHON_PATH /Users/ymh/dev/workspace/hdabo/virtualenv/web/env/hdabo/lib/python2.6/site-packages:/Applications/Dev/eclipse/plugins/org.python.pydev.debug_2.2.0.2011062419/pysrc/
+SetEnv PYDEV_DEBUG False
 
 Options ExecCGI FollowSymLinks
 SetHandler wsgi-script
--- a/web/hdabo/management/commands/import_tag_popularity.py	Fri Jul 08 23:28:33 2011 +0200
+++ b/web/hdabo/management/commands/import_tag_popularity.py	Mon Jul 11 17:03:23 2011 +0200
@@ -122,6 +122,7 @@
                
             if not options.get('preserve',False):
                 Tag.objects.update(popularity=0)
+                
             reader = csv.DictReader(csv_file, **dr_kwargs)
 
             for j, row in enumerate(reader):
@@ -144,6 +145,6 @@
                     continue
                 
                 
-                for tag in Tag.objects.filter(normalized_label=label, popularity=0):
-                    tag.popularity = int(row['popularity'])
+                for tag in Tag.objects.filter(normalized_label=label):
+                    tag.popularity += int(row['popularity'])
                     tag.save()
--- a/web/hdabo/modwsgi.wsgi	Fri Jul 08 23:28:33 2011 +0200
+++ b/web/hdabo/modwsgi.wsgi	Mon Jul 11 17:03:23 2011 +0200
@@ -3,6 +3,7 @@
 import site
 
 
+
 def application(environ, start_response):
     
     global g_env_set
@@ -29,5 +30,9 @@
 
     _application = django.core.handlers.wsgi.WSGIHandler()
 
+    if environ.get('PYDEV_DEBUG', "False").lower() in ["true", "1", "t"]:
+        import pydevd #@UnresolvedImport
+        pydevd.settrace(suspend=False)
+
     return _application(environ, start_response)
         
--- a/web/hdabo/wp_utils.py	Fri Jul 08 23:28:33 2011 +0200
+++ b/web/hdabo/wp_utils.py	Mon Jul 11 17:03:23 2011 +0200
@@ -172,11 +172,17 @@
 def reorder_datasheet_tags(ds):
     ts_list = []
     for ts in ds.taggedsheet_set.all():
+        ts.index_note = 0
         kwargs = {DJANGO_ID + "__exact": unicode(ds.pk)}
+
         results = SearchQuerySet().filter(title=ts.tag.label).filter_or(description=ts.tag.label).filter(**kwargs)
         if len(results) > 0:
-            ts.index_note = results[0].score
-            ts.save()
+            ts.index_note += results[0].score
+#        results = SearchQuerySet().filter(description=ts.tag.label).filter(**kwargs)
+#        if len(results) > 0:
+#            ts.index_note += results[0].score
+
+        ts.save()
         ts_list.append(ts)
     ts_list.sort(key=lambda t: (-t.index_note, t.order))
     for k, ts in enumerate(ts_list):