#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2019/5/15


from django.core.management import BaseCommand
from api.models import ServiceRegister, ServiceRelatedRecommendService

serviceregister_ids = [

]


class Command(BaseCommand):
    def handle(self, *args, **options):
        for serviceregister_id in serviceregister_ids:
            print("============>>>>>>serviceregister_id: %s" % serviceregister_id)
            serviceregister = ServiceRegister.objects.get(pk=serviceregister_id)
            recommend_service_ids = [item.get('id') for item in serviceregister.get_recommend_services()]
            print("============>>>>>>recommend_service_ids:", recommend_service_ids)
            ServiceRelatedRecommendService.objects.filter(
                service_id=serviceregister.id, recommend_service_id__in=recommend_service_ids
            ).delete()

