correct popularity import. close bug #17 - again
Binary file web/hdabo/fixtures/datasheet_10.yaml.bz2 has changed
Binary file web/hdabo/fixtures/datasheet_347.yaml.bz2 has changed
Binary file web/hdabo/fixtures/datasheet_all.yaml.bz2 has changed
--- a/web/hdabo/management/commands/import_tag_popularity.py Fri Jul 08 21:22:10 2011 +0200
+++ b/web/hdabo/management/commands/import_tag_popularity.py Fri Jul 08 23:28:33 2011 +0200
@@ -60,6 +60,12 @@
dest='lines',
default=0,
help='Number of lines to read. 0 means all.'),
+ make_option('--preserve',
+ action='store_true',
+ dest='preserve',
+ default=False,
+ help='preserve'),
+
)
@@ -114,6 +120,8 @@
if dialect is not None:
dr_kwargs['dialect'] = dialect
+ if not options.get('preserve',False):
+ Tag.objects.update(popularity=0)
reader = csv.DictReader(csv_file, **dr_kwargs)
for j, row in enumerate(reader):
@@ -134,6 +142,8 @@
if not label or not popularity_str:
continue
- for tag in Tag.objects.filter(normalized_label__icontains=label):
+
+
+ for tag in Tag.objects.filter(normalized_label=label, popularity=0):
tag.popularity = int(row['popularity'])
tag.save()