Check Data Availability with 0 % when data is not received on the date

I've created Data Availability (Which means if you select dates from_date to to_date, you'll get a table on that date on how much % of data will be received). If data is available on that selected date then I got that data in %.

but if data is not received on a selected date then I want to add 0% data received.

enter image description here

In the above Image, I've selected from date (03-09-2022) and to date (06-09-2022) but received only those dates for which data is available. In the table, I want to add 03-09-2022, and 04-09-2022 dates with 0% data.

I've written this code in views.py

final_data = dict()
        for key, values in data.items():
            final_data[key]= dict()
            for key1, value in values.items():
                total_data_count = len(value)
                percentage_data = (total_data_count * 100)/1440
                available_data = str(percentage_data)[:5]
                final_data[key].setdefault(key1,available_data)

Here key1 is the date and available_data is the calculated data in %.

How can I get the selected date if data is not available?

Back to Top