# HG changeset patch # User ymh # Date 1310160513 -7200 # Node ID 0f2844b9ae414c0ea9be3027343fb511ab9f0397 # Parent 955f1b6fa9c57213320d37f50b81f99246d3b82f correct popularity import. close bug #17 - again diff -r 955f1b6fa9c5 -r 0f2844b9ae41 web/hdabo/fixtures/datasheet_10.yaml.bz2 Binary file web/hdabo/fixtures/datasheet_10.yaml.bz2 has changed diff -r 955f1b6fa9c5 -r 0f2844b9ae41 web/hdabo/fixtures/datasheet_347.yaml.bz2 Binary file web/hdabo/fixtures/datasheet_347.yaml.bz2 has changed diff -r 955f1b6fa9c5 -r 0f2844b9ae41 web/hdabo/fixtures/datasheet_all.yaml.bz2 Binary file web/hdabo/fixtures/datasheet_all.yaml.bz2 has changed diff -r 955f1b6fa9c5 -r 0f2844b9ae41 web/hdabo/management/commands/import_tag_popularity.py --- 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()