def setUp(self): self.instance = make_instance(edge_length=1000) self.user = make_commander_user(self.instance) self.make_plots([(0, 100), (0, 101), (0, 200), (0, 201)]) recompute_hide_at_zoom(self.instance) # Two plots have hide_at_zoom == 14 # One plot has hide_at_zoom == 10 # One plot has hide_at_zoom == None self.assert_counts({14: 2, 10: 1})
def _update_all_instances(): instance_ids = MapFeature.objects \ .values('instance_id') \ .annotate(n=Count('instance_id')) \ .filter(n__gt=MIN_FEATURE_COUNT) \ .values_list('instance_id', flat=True) for id in instance_ids: instance = Instance.objects.get(id=id) recompute_hide_at_zoom(instance, verbose=True)
def setUp(self): self.instance = make_instance(edge_length=1000) self.user = make_commander_user(self.instance) self.make_plots([ (0, 100), (0, 101), (0, 200), (0, 201) ]) recompute_hide_at_zoom(self.instance) # Two plots have hide_at_zoom == 14 # One plot has hide_at_zoom == 10 # One plot has hide_at_zoom == None self.assert_counts({14: 2, 10: 1})
def handle(self, *args, **options): if options['instance_url_name'] is None: _update_all_instances() else: url_name = options['instance_url_name'] try: instance = Instance.objects.get(url_name=url_name) except ObjectDoesNotExist: raise CommandError('Instance "%s" not found' % url_name) recompute_hide_at_zoom(instance, verbose=True)
def handle(self, *args, **options): if len(args) > 1: raise CommandError('Command takes 0 or 1 argument') elif len(args) == 0: _update_all_instances() else: url_name = args[0] try: instance = Instance.objects.get(url_name=url_name) except ObjectDoesNotExist: raise CommandError('Instance "%s" not found' % url_name) recompute_hide_at_zoom(instance, verbose=True)