Skip to content

Commit f12b6b9

Browse files
Merge pull request #78 from pitangainnovare/impl/content_type
Adiciona content_type e click_timestamps em ItemAccess
2 parents 80debe1 + 4c63fe2 commit f12b6b9

28 files changed

Lines changed: 1042 additions & 161 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# VSCode
2+
.vscode/
3+
14
# Solr
25
index/data/usage
36
index/data/log_manager/data

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.5.0

compose/local/django/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ COPY ./compose/local/django/celery/beat/start /start-celerybeat
7474
RUN sed -i 's/\r$//g' /start-celerybeat
7575
RUN chmod +x /start-celerybeat
7676

77-
COPY ./compose/local/django/celery/flower/start /start-flower
78-
RUN sed -i 's/\r$//g' /start-flower
79-
RUN chmod +x /start-flower
80-
8177

8278
# copy application code to WORKDIR
8379
COPY . ${APP_HOME}

compose/local/django/celery/flower/start

Lines changed: 0 additions & 11 deletions
This file was deleted.

compose/local/django/celery/worker/start

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -o errexit
44
set -o nounset
55

66

7-
watchgod celery.__main__.main --args -A config.celery_app worker -l INFO
7+
watchgod celery.__main__.main --args -A config.celery_app worker -l INFO --concurrency=4

compose/production/django/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ RUN sed -i 's/\r$//g' /start-celerybeat
8080
RUN chmod +x /start-celerybeat
8181

8282

83-
COPY ./compose/production/django/celery/flower/start /start-flower
84-
RUN sed -i 's/\r$//g' /start-flower
85-
RUN chmod +x /start-flower
86-
87-
8883
# copy application code to WORKDIR
8984
COPY --chown=django:django . ${APP_HOME}
9085

compose/production/django/celery/flower/start

Lines changed: 0 additions & 11 deletions
This file was deleted.

compose/production/django/celery/worker/start

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -o pipefail
55
set -o nounset
66

77

8-
exec celery -A config.celery_app worker -l INFO
8+
exec celery -A config.celery_app worker -l INFO --concurrency=4

core/tests_date_utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
from django.test import TestCase
44

5-
from core.utils.date_utils import get_date_range_str
5+
from core.utils.date_utils import (
6+
extract_minute_second_key,
7+
get_date_range_str,
8+
truncate_datetime_to_hour,
9+
)
610

711

812
class DateUtilsTests(TestCase):
@@ -76,3 +80,13 @@ def test_get_date_range_with_only_until_date(self):
7680
'2025-02-08',
7781
)
7882
self.assertEqual(result, expected)
83+
84+
def test_extract_minute_second_key(self):
85+
dt = datetime(2023, 3, 15, 14, 30, 45)
86+
key = extract_minute_second_key(dt)
87+
self.assertEqual(key, '30:45')
88+
89+
def test_truncate_datetime_to_hour(self):
90+
dt = datetime(2023, 3, 15, 14, 30, 45)
91+
truncated = truncate_datetime_to_hour(dt)
92+
self.assertEqual(truncated, datetime(2023, 3, 15, 14, 0, 0))

core/utils/date_utils.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,43 @@ def get_date_objs_from_date_range(from_date, until_date, format='%Y-%m-%d'):
8282
visible_dates.append(current)
8383
current += timedelta(days=1)
8484

85-
return visible_dates
85+
return visible_dates
86+
87+
88+
def truncate_datetime_to_hour(dt):
89+
"""
90+
Truncates a datetime object to the hour.
91+
Parameters:
92+
dt (datetime or str): The datetime object or string to be truncated.
93+
94+
Returns:
95+
datetime: The truncated datetime object.
96+
"""
97+
if isinstance(dt, str):
98+
try:
99+
dt = datetime.strptime(dt, "%Y-%m-%d %H:%M:%S")
100+
except ValueError:
101+
logging.error("Invalid datetime string format. Expected '%Y-%m-%d %H:%M:%S'.")
102+
return None
103+
104+
return dt.replace(minute=0, second=0, microsecond=0)
105+
106+
107+
def extract_minute_second_key(dt):
108+
"""
109+
Extracts a tuple based on the minute and second of a datetime object.
110+
111+
Parameters:
112+
dt (datetime or str): The datetime object or string.
113+
114+
Returns:
115+
str: A string in the format "MM:SS" representing the minute and second.
116+
"""
117+
if isinstance(dt, str):
118+
try:
119+
dt = datetime.strptime(dt, "%Y-%m-%d %H:%M:%S")
120+
except ValueError:
121+
logging.error("Invalid datetime string format. Expected '%Y-%m-%d %H:%M:%S'.")
122+
return None
123+
124+
return f"{dt.minute:02}:{dt.second:02}"

0 commit comments

Comments
 (0)