Skip to content

Commit

Permalink
remove usage of timezone because of issue with time change
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainFayolle authored and RignonNoel committed Mar 29, 2023
1 parent 155166c commit e1d9522
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 133 deletions.
260 changes: 130 additions & 130 deletions tomato/tests/tests_viewset_Tomato.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,19 +574,19 @@ def test_statistics_tomatoes_empty_data(self):
self.assertEqual(
result['graph']['labels'],
[
'2022-02-01T00:00:00-0500',
'2022-03-01T00:00:00-0500',
'2022-04-01T00:00:00-0500',
'2022-05-01T00:00:00-0500',
'2022-06-01T00:00:00-0500',
'2022-07-01T00:00:00-0500',
'2022-08-01T00:00:00-0500',
'2022-09-01T00:00:00-0500',
'2022-10-01T00:00:00-0500',
'2022-11-01T00:00:00-0500',
'2022-12-01T00:00:00-0500',
'2023-01-01T00:00:00-0500',
'2023-02-01T00:00:00-0500',
'2022-02-01T00:00:00',
'2022-03-01T00:00:00',
'2022-04-01T00:00:00',
'2022-05-01T00:00:00',
'2022-06-01T00:00:00',
'2022-07-01T00:00:00',
'2022-08-01T00:00:00',
'2022-09-01T00:00:00',
'2022-10-01T00:00:00',
'2022-11-01T00:00:00',
'2022-12-01T00:00:00',
'2023-01-01T00:00:00',
'2023-02-01T00:00:00',
],
)
self.assertEqual(
Expand All @@ -595,19 +595,19 @@ def test_statistics_tomatoes_empty_data(self):
{
'label': 'number_of_tomato',
'data': [
{'x': '2022-02-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-03-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-04-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-05-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-06-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-07-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-08-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-09-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-10-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-11-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-12-01T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-01T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-02-01T00:00:00', 'y': 0.0},
{'x': '2022-03-01T00:00:00', 'y': 0.0},
{'x': '2022-04-01T00:00:00', 'y': 0.0},
{'x': '2022-05-01T00:00:00', 'y': 0.0},
{'x': '2022-06-01T00:00:00', 'y': 0.0},
{'x': '2022-07-01T00:00:00', 'y': 0.0},
{'x': '2022-08-01T00:00:00', 'y': 0.0},
{'x': '2022-09-01T00:00:00', 'y': 0.0},
{'x': '2022-10-01T00:00:00', 'y': 0.0},
{'x': '2022-11-01T00:00:00', 'y': 0.0},
{'x': '2022-12-01T00:00:00', 'y': 0.0},
{'x': '2023-01-01T00:00:00', 'y': 0.0},
{'x': '2023-02-01T00:00:00', 'y': 0.0},
]
}
],
Expand Down Expand Up @@ -675,19 +675,19 @@ def test_statistics_tomatoes_year(self):
self.assertEqual(
result['graph']['labels'],
[
'2022-02-01T00:00:00-0500',
'2022-03-01T00:00:00-0500',
'2022-04-01T00:00:00-0500',
'2022-05-01T00:00:00-0500',
'2022-06-01T00:00:00-0500',
'2022-07-01T00:00:00-0500',
'2022-08-01T00:00:00-0500',
'2022-09-01T00:00:00-0500',
'2022-10-01T00:00:00-0500',
'2022-11-01T00:00:00-0500',
'2022-12-01T00:00:00-0500',
'2023-01-01T00:00:00-0500',
'2023-02-01T00:00:00-0500',
'2022-02-01T00:00:00',
'2022-03-01T00:00:00',
'2022-04-01T00:00:00',
'2022-05-01T00:00:00',
'2022-06-01T00:00:00',
'2022-07-01T00:00:00',
'2022-08-01T00:00:00',
'2022-09-01T00:00:00',
'2022-10-01T00:00:00',
'2022-11-01T00:00:00',
'2022-12-01T00:00:00',
'2023-01-01T00:00:00',
'2023-02-01T00:00:00',
],
)
self.assertEqual(
Expand All @@ -696,20 +696,20 @@ def test_statistics_tomatoes_year(self):
{
'label': 'number_of_tomato',
'data': [
{'x': '2022-02-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-03-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-04-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-05-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-06-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-07-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-08-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-09-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-10-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-11-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-12-01T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-01T00:00:00-0500', 'y': 0.0},
{'x': '2022-02-01T00:00:00', 'y': 0.0},
{'x': '2022-03-01T00:00:00', 'y': 0.0},
{'x': '2022-04-01T00:00:00', 'y': 0.0},
{'x': '2022-05-01T00:00:00', 'y': 0.0},
{'x': '2022-06-01T00:00:00', 'y': 0.0},
{'x': '2022-07-01T00:00:00', 'y': 0.0},
{'x': '2022-08-01T00:00:00', 'y': 0.0},
{'x': '2022-09-01T00:00:00', 'y': 0.0},
{'x': '2022-10-01T00:00:00', 'y': 0.0},
{'x': '2022-11-01T00:00:00', 'y': 0.0},
{'x': '2022-12-01T00:00:00', 'y': 0.0},
{'x': '2023-01-01T00:00:00', 'y': 0.0},
{
'x': '2023-02-01T00:00:00-0500',
'x': '2023-02-01T00:00:00',
'y': 60.0
},
]
Expand Down Expand Up @@ -779,38 +779,38 @@ def test_statistics_tomatoes_month(self):
self.assertEqual(
result['graph']['labels'],
[
'2023-01-25T00:00:00-0500',
'2023-01-26T00:00:00-0500',
'2023-01-27T00:00:00-0500',
'2023-01-28T00:00:00-0500',
'2023-01-29T00:00:00-0500',
'2023-01-30T00:00:00-0500',
'2023-01-31T00:00:00-0500',
'2023-02-01T00:00:00-0500',
'2023-02-02T00:00:00-0500',
'2023-02-03T00:00:00-0500',
'2023-02-04T00:00:00-0500',
'2023-02-05T00:00:00-0500',
'2023-02-06T00:00:00-0500',
'2023-02-07T00:00:00-0500',
'2023-02-08T00:00:00-0500',
'2023-02-09T00:00:00-0500',
'2023-02-10T00:00:00-0500',
'2023-02-11T00:00:00-0500',
'2023-02-12T00:00:00-0500',
'2023-02-13T00:00:00-0500',
'2023-02-14T00:00:00-0500',
'2023-02-15T00:00:00-0500',
'2023-02-16T00:00:00-0500',
'2023-02-17T00:00:00-0500',
'2023-02-18T00:00:00-0500',
'2023-02-19T00:00:00-0500',
'2023-02-20T00:00:00-0500',
'2023-02-21T00:00:00-0500',
'2023-02-22T00:00:00-0500',
'2023-02-23T00:00:00-0500',
'2023-02-24T00:00:00-0500',
'2023-02-25T00:00:00-0500',
'2023-01-25T00:00:00',
'2023-01-26T00:00:00',
'2023-01-27T00:00:00',
'2023-01-28T00:00:00',
'2023-01-29T00:00:00',
'2023-01-30T00:00:00',
'2023-01-31T00:00:00',
'2023-02-01T00:00:00',
'2023-02-02T00:00:00',
'2023-02-03T00:00:00',
'2023-02-04T00:00:00',
'2023-02-05T00:00:00',
'2023-02-06T00:00:00',
'2023-02-07T00:00:00',
'2023-02-08T00:00:00',
'2023-02-09T00:00:00',
'2023-02-10T00:00:00',
'2023-02-11T00:00:00',
'2023-02-12T00:00:00',
'2023-02-13T00:00:00',
'2023-02-14T00:00:00',
'2023-02-15T00:00:00',
'2023-02-16T00:00:00',
'2023-02-17T00:00:00',
'2023-02-18T00:00:00',
'2023-02-19T00:00:00',
'2023-02-20T00:00:00',
'2023-02-21T00:00:00',
'2023-02-22T00:00:00',
'2023-02-23T00:00:00',
'2023-02-24T00:00:00',
'2023-02-25T00:00:00',
],
)
self.assertEqual(
Expand All @@ -819,42 +819,42 @@ def test_statistics_tomatoes_month(self):
{
'label': 'number_of_tomato',
'data': [
{'x': '2023-01-25T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-26T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-27T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-28T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-29T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-30T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-31T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-01T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-02T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-03T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-04T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-05T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-06T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-07T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-08T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-09T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-10T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-11T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-12T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-13T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-14T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-15T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-16T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-17T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-18T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-19T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-20T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-21T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-22T00:00:00-0500', 'y': 0.0},
{'x': '2023-01-25T00:00:00', 'y': 0.0},
{'x': '2023-01-26T00:00:00', 'y': 0.0},
{'x': '2023-01-27T00:00:00', 'y': 0.0},
{'x': '2023-01-28T00:00:00', 'y': 0.0},
{'x': '2023-01-29T00:00:00', 'y': 0.0},
{'x': '2023-01-30T00:00:00', 'y': 0.0},
{'x': '2023-01-31T00:00:00', 'y': 0.0},
{'x': '2023-02-01T00:00:00', 'y': 0.0},
{'x': '2023-02-02T00:00:00', 'y': 0.0},
{'x': '2023-02-03T00:00:00', 'y': 0.0},
{'x': '2023-02-04T00:00:00', 'y': 0.0},
{'x': '2023-02-05T00:00:00', 'y': 0.0},
{'x': '2023-02-06T00:00:00', 'y': 0.0},
{'x': '2023-02-07T00:00:00', 'y': 0.0},
{'x': '2023-02-08T00:00:00', 'y': 0.0},
{'x': '2023-02-09T00:00:00', 'y': 0.0},
{'x': '2023-02-10T00:00:00', 'y': 0.0},
{'x': '2023-02-11T00:00:00', 'y': 0.0},
{'x': '2023-02-12T00:00:00', 'y': 0.0},
{'x': '2023-02-13T00:00:00', 'y': 0.0},
{'x': '2023-02-14T00:00:00', 'y': 0.0},
{'x': '2023-02-15T00:00:00', 'y': 0.0},
{'x': '2023-02-16T00:00:00', 'y': 0.0},
{'x': '2023-02-17T00:00:00', 'y': 0.0},
{'x': '2023-02-18T00:00:00', 'y': 0.0},
{'x': '2023-02-19T00:00:00', 'y': 0.0},
{'x': '2023-02-20T00:00:00', 'y': 0.0},
{'x': '2023-02-21T00:00:00', 'y': 0.0},
{'x': '2023-02-22T00:00:00', 'y': 0.0},
{
'x': '2023-02-23T00:00:00-0500',
'x': '2023-02-23T00:00:00',
'y': 45.0
},
{'x': '2023-02-24T00:00:00-0500', 'y': 0.0},
{'x': '2023-02-24T00:00:00', 'y': 0.0},
{
'x': '2023-02-25T00:00:00-0500',
'x': '2023-02-25T00:00:00',
'y': 15.0
}
]
Expand Down Expand Up @@ -924,13 +924,13 @@ def test_statistics_tomatoes_week(self):
self.assertEqual(
result['graph']['labels'],
[
'2023-02-19T00:00:00-0500',
'2023-02-20T00:00:00-0500',
'2023-02-21T00:00:00-0500',
'2023-02-22T00:00:00-0500',
'2023-02-23T00:00:00-0500',
'2023-02-24T00:00:00-0500',
'2023-02-25T00:00:00-0500',
'2023-02-19T00:00:00',
'2023-02-20T00:00:00',
'2023-02-21T00:00:00',
'2023-02-22T00:00:00',
'2023-02-23T00:00:00',
'2023-02-24T00:00:00',
'2023-02-25T00:00:00',
],
)
self.assertEqual(
Expand All @@ -940,31 +940,31 @@ def test_statistics_tomatoes_week(self):
'label': 'number_of_tomato',
'data': [
{
'x': '2023-02-19T00:00:00-0500',
'x': '2023-02-19T00:00:00',
'y': 0.0,
},
{
'x': '2023-02-20T00:00:00-0500',
'x': '2023-02-20T00:00:00',
'y': 0.0,
},
{
'x': '2023-02-21T00:00:00-0500',
'x': '2023-02-21T00:00:00',
'y': 0.0,
},
{
'x': '2023-02-22T00:00:00-0500',
'x': '2023-02-22T00:00:00',
'y': 0.0,
},
{
'x': '2023-02-23T00:00:00-0500',
'x': '2023-02-23T00:00:00',
'y': 45.0
},
{
'x': '2023-02-24T00:00:00-0500',
'x': '2023-02-24T00:00:00',
'y': 0.0
},
{
'x': '2023-02-25T00:00:00-0500',
'x': '2023-02-25T00:00:00',
'y': 15.0
}
]
Expand Down
6 changes: 3 additions & 3 deletions tomato/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ def _get_intervals(start, end, interval_param):
if interval_param == 'day':
while end >= date:
labels.add(
date.strftime("%Y-%m-%dT%H:%M:%S%z")
date.strftime("%Y-%m-%dT%H:%M:%S")
)
date += timedelta(days=1)
else:
date = date.replace(day=1)
end = end.replace(day=1, hour=0, minute=0, second=0)
while end >= date:
labels.add(
date.strftime("%Y-%m-%dT%H:%M:%S%z")
date.strftime("%Y-%m-%dT%H:%M:%S")
)
# Get first day of next month
date += timedelta(days=32)
Expand Down Expand Up @@ -439,7 +439,7 @@ def _get_data(queryset, data_set_type, labels):

non_covered_labels = labels.copy()
for data in queryset:
label = data['interval'].strftime('%Y-%m-%dT%H:%M:%S%z')
label = data['interval'].strftime('%Y-%m-%dT%H:%M:%S')
results.append(
{
'x': label,
Expand Down

0 comments on commit e1d9522

Please sign in to comment.