Fix
This commit is contained in:
parent
b42b75609a
commit
c570cfdadd
|
|
@ -1,6 +1,7 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.db import connections
|
||||
from establishment.management.commands.add_position import namedtuplefetchall
|
||||
from django.db.models import Q
|
||||
from tag.models import Tag, TagCategory
|
||||
from product.models import Product, ProductType
|
||||
from tqdm import tqdm
|
||||
|
|
@ -67,8 +68,7 @@ class Command(BaseCommand):
|
|||
with connections['legacy'].cursor() as cursor:
|
||||
cursor.execute('''
|
||||
select
|
||||
DISTINCT
|
||||
m.id as old_id,
|
||||
DISTINCT
|
||||
trim(CONVERT(m.value USING utf8)) as tag_value,
|
||||
trim(CONVERT(v.key_name USING utf8)) as tag_category
|
||||
FROM product_metadata m
|
||||
|
|
@ -103,6 +103,14 @@ class Command(BaseCommand):
|
|||
p.tags.clear()
|
||||
print('End clear tags product')
|
||||
|
||||
|
||||
def remove_tags(self):
|
||||
print('Begin delete many tags')
|
||||
Tag.objects.\
|
||||
filter(news__isnull=True, establishments__isnull=True).delete()
|
||||
print('End delete many tags')
|
||||
|
||||
|
||||
def product_sql(self):
|
||||
with connections['legacy'].cursor() as cursor:
|
||||
cursor.execute('''
|
||||
|
|
@ -145,6 +153,7 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.remove_tags_product()
|
||||
self.remove_tags()
|
||||
self.add_category_tag()
|
||||
self.add_type_product_category()
|
||||
self.add_tag()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user