Esempio n. 1
0
    def handle(self, *args, **options):
        verbosity = int(options.get('verbosity', 0))
        if options['verbose']:
            warnings.warn(
                'The `--verbose` option is being deprecated and it will be removed in the next release. Use `--verbosity` instead.',
                PendingDeprecationWarning)
            verbosity = 1

        if verbosity == 0:
            # avoids allocating the results
            recommends_precompute()
        else:
            self.stdout.write("\nCalculation Started.\n")
            start_time = datetime.now()
            results = recommends_precompute()
            end_time = datetime.now()
            if verbosity > 1:
                for r in results:
                    self.stdout.write(
                        "%d similarities and %d recommendations saved.\n" %
                        (r['similar_count'], r['recommend_count']))
            rd = dateutil.relativedelta.relativedelta(end_time, start_time)
            self.stdout.write(
                "Calculation finished in %d years, %d months, %d days, %d hours, %d minutes and %d seconds\n"
                % (rd.years, rd.months, rd.days, rd.hours, rd.minutes,
                   rd.seconds))
    def handle(self, *args, **options):
        verbosity = int(options.get("verbosity", 0))
        if options["verbose"]:
            warnings.warn(
                "The `--verbose` option is being deprecated and it will be removed in the next release. Use `--verbosity` instead.",
                PendingDeprecationWarning,
            )
            verbosity = 1

        if verbosity == 0:
            # avoids allocating the results
            recommends_precompute()
        else:
            self.stdout.write("\nCalculation Started.\n")
            start_time = datetime.now()
            results = recommends_precompute()
            end_time = datetime.now()
            if verbosity > 1:
                for r in results:
                    self.stdout.write(
                        "%d similarities and %d recommendations saved.\n" % (r["similar_count"], r["recommend_count"])
                    )
            rd = dateutil.relativedelta.relativedelta(end_time, start_time)
            self.stdout.write(
                "Calculation finished in %d years, %d months, %d days, %d hours, %d minutes and %d seconds\n"
                % (rd.years, rd.months, rd.days, rd.hours, rd.minutes, rd.seconds)
            )
Esempio n. 3
0
    def setUp(self):
        self.client = Client()
        self.mug = RecProduct.objects.get(name='Coffee Mug')
        self.orange_juice = RecProduct.objects.get(name='Orange Juice')
        self.wine = RecProduct.objects.get(name='Bottle of Red Wine')
        self.steak = RecProduct.objects.get(name='1lb Tenderloin Steak')
        self.user1 = User.objects.get(username='******')

        self.provider = recommendation_registry.get_provider_for_content(RecProduct)

        recommends_precompute()
Esempio n. 4
0
    def setUp(self):
        self.client = Client()
        self.mug = RecProduct.objects.get(name='Coffee Mug')
        self.orange_juice = RecProduct.objects.get(name='Orange Juice')
        self.wine = RecProduct.objects.get(name='Bottle of Red Wine')
        self.steak = RecProduct.objects.get(name='1lb Tenderloin Steak')
        self.user1 = User.objects.get(username='******')

        self.provider = recommendation_registry.get_provider_for_content(
            RecProduct)

        recommends_precompute()
Esempio n. 5
0
     def setUp(self):
         self.client = Client()
         self.mug = RecProduct.objects.get(name='Coffee Mug')
         self.orange_juice = RecProduct.objects.get(name='Orange Juice')
         self.wine = RecProduct.objects.get(name='Bottle of Red Wine')
         RecProduct.objects.get(name='1lb Tenderloin Steak').delete()
         self.user1 = User.objects.get(username='******')
         from django.template import loader
         loader.template_source_loaders = None
 
         self.provider = recommendation_registry.get_provider_for_content(RecProduct)
         recommends_precompute()
Esempio n. 6
0
    def setUp(self):
        self.client = Client()
        self.mug = RecProduct.objects.get(name='Coffee Mug')
        self.orange_juice = RecProduct.objects.get(name='Orange Juice')
        self.wine = RecProduct.objects.get(name='Bottle of Red Wine')
        RecProduct.objects.get(name='1lb Tenderloin Steak').delete()
        self.user1 = User.objects.get(username='******')

        from django.template import loader
        loader.template_source_loaders = None

        self.provider = recommendation_registry.get_provider_for_content(
            RecProduct)
        recommends_precompute()
Esempio n. 7
0
 def tearDown(self):
     self.vote.delete()
     recommends_precompute()
Esempio n. 8
0
 def tearDown(self):
     self.vote.delete()
     recommends_precompute()
Esempio n. 9
0
 def handle(self, *args, **options):
     recommends_precompute()