Ejemplo n.º 1
0
    def handle(self, *args, **options):
        hour = int(timezone.now().strftime('%H'))
        day = int(timezone.now().weekday())
        print(hour, day)

        # hourly all the time
        # daily once a day
        # weekly once a week
        breakdowns = ['hourly']
        if hour <= 0:
            breakdowns.append('daily')
            if day <= 0:
                breakdowns.append('weekly')

        with transaction.atomic():
            items = []
            for breakdown in breakdowns:
                JSONStore.objects.filter(
                    key__startswith=breakdown).all().delete()
                for i, __ in lines.items():
                    view = 'gas_history'
                    key = f"{breakdown}:{i}"
                    print(f"- executing {breakdown} {key}")
                    data = gas_history(breakdown, i)
                    print("- creating")
                    items.append(JSONStore(
                        view=view,
                        key=key,
                        data=data,
                    ))
            JSONStore.objects.bulk_create(items)
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        keywords = [''] + programming_languages
        type_options = get_all_type_options()
        # DEBUG OPTIONS
        # keywords = [''] 
        # type_options = ['all']
        with transaction.atomic():
            items = []
            JSONStore.objects.filter(view__startswith='d3').all().delete()

            ## Scatterplot
            for keyword in keywords:
                for hide_username in [True, False]:
                    view = 'd3_scatterplot'
                    key = f"{keyword}_{hide_username}"
                    print(f"- executing {view} {key}")
                    data = viz_scatterplot_data_helper(keyword, hide_username)
                    print("- creating")
                    items.append(JSONStore(
                        view=view,
                        key=key,
                        data=data,
                        ))

            ## Graph
            for keyword in keywords:
                for _type in type_options:
                    for hide_pii in [True, False]:
                        view = 'd3_graph'
                        key = f"{_type}_{keyword}_{hide_pii}"
                        print(f"- executing {view} {key}")
                        data = viz_graph_data_helper(_type, keyword, hide_pii)
                        print("- creating")
                        items.append(JSONStore(
                            view=view,
                            key=key,
                            data=data,
                            ))

            JSONStore.objects.bulk_create(items)
Ejemplo n.º 3
0
def create_contributor_landing_page_context():
    print('create_contributor_landing_page_context')
    keywords = [''] + programming_languages
    if settings.DEBUG:
        keywords = ['']
    view = 'contributor_landing_page'
    with transaction.atomic():
        items = []
        JSONStore.objects.filter(view=view).all().delete()
        for keyword in keywords:
            print(f"- executing {keyword}")
            data = get_contributor_landing_page_context(keyword)
            print("- creating")
            items.append(JSONStore(
                view=view,
                key=keyword,
                data=json.loads(json.dumps(data, cls=EncodeAnything)),
                ))
        JSONStore.objects.bulk_create(items)
Ejemplo n.º 4
0
def create_results_cache():
    print('results')
    keywords = ['']
    if settings.DEBUG:
        keywords = ['']
    view = 'results'
    with transaction.atomic():
        items = []
        JSONStore.objects.filter(view=view).all().delete()
        for keyword in keywords:
            print(f"- executing {keyword}")
            data = build_stat_results(keyword)
            print("- creating")
            items.append(JSONStore(
                view=view,
                key=keyword,
                data=json.loads(json.dumps(data, cls=EncodeAnything)),
                ))
        JSONStore.objects.bulk_create(items)
Ejemplo n.º 5
0
 def handle(self, *args, **options):
     keywords = [''] + programming_languages
     # DEBUG OPTIONS
     # keywords = ['']
     view = 'results'
     with transaction.atomic():
         items = []
         JSONStore.objects.filter(view=view).all().delete()
         for keyword in keywords:
             key = keyword
             print(f"- executing {keyword}")
             data = build_stat_results(keyword)
             print("- creating")
             items.append(
                 JSONStore(
                     view=view,
                     key=key,
                     data=json.loads(json.dumps(data, cls=LazyEncoder)),
                 ))
     JSONStore.objects.bulk_create(items)