Merge branch 'fix/tags_many' into 'develop'

Fix/tags many

See merge request gm/gm-backend!143
This commit is contained in:
d.kuzmenko 2019-11-20 12:43:05 +00:00
commit 62d7f13f80
2 changed files with 11 additions and 3 deletions

View File

@ -67,8 +67,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 +102,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 +152,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()

View File

@ -503,4 +503,4 @@ ESTABLISHMENT_CHOSEN_TAGS = ['gastronomic', 'en_vogue', 'terrace', 'streetfood',
NEWS_CHOSEN_TAGS = ['eat', 'drink', 'cook', 'style', 'international', 'event', 'partnership']
INTERNATIONAL_COUNTRY_CODES = ['www', 'main', 'next']
#ELASTICSEARCH_DSL_AUTOSYNC = False
ELASTICSEARCH_DSL_AUTOSYNC = False