Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue_105 #121

Merged
merged 5 commits into from
Jun 17, 2024
Merged

issue_105 #121

merged 5 commits into from
Jun 17, 2024

Conversation

bakhterets
Copy link
Contributor

#105

Problem:
datetime: datetime.datetime’s utcnow() and utcfromtimestamp() are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, call now() and fromtimestamp() with the tz parameter set to datetime.UTC. (Contributed by Paul Ganssle in gh-103857.)

Solution:
To add new function to get actual datetime_now with timezone and remove timezone to save the datebase models unchanged (to use postgresql and sqlite).

Conclusion:
All timestamps converts to utc timezone and stores without timezone in the database

@bakhterets bakhterets self-assigned this May 28, 2024
@bakhterets bakhterets marked this pull request as ready for review June 5, 2024 09:30
Aloento
Aloento previously approved these changes Jun 7, 2024
app/datetime.py Outdated
return datetime.now(timezone.utc)


def utc_from_timestamp(timestamp):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method has no usage anywhere, or it's just for future use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for future use, can be deleted now

start_date: Mapped[datetime.datetime] = mapped_column(
insert_default=func.now()
start_date: Mapped[datetime] = mapped_column(
db.DateTime,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is db.DateTime corect here? Before you used only one argument and now two

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an explicit indication of the data type

@bakhterets
Copy link
Contributor Author

recheck

@bakhterets bakhterets requested a review from vladimirhasko June 14, 2024 14:34
@bakhterets bakhterets added the gate Gate PR with Zuul label Jun 17, 2024
Copy link

otc-zuul bot commented Jun 17, 2024

Build succeeded.
https://zuul.otc-service.com/t/eco/buildset/5141226fe9ed4370a527b76ea4507737

✔️ otc-tox-docs SUCCESS in 3m 07s
✔️ otc-tox-pep8 SUCCESS in 2m 06s
✔️ stackmon-status-dashboard-upload-image SUCCESS in 3m 38s

@otc-zuul otc-zuul bot merged commit 0b12d28 into main Jun 17, 2024
5 checks passed
@otc-zuul otc-zuul bot deleted the aware_datetime_v2 branch June 17, 2024 11:20
vladimirhasko added a commit to opentelekomcloud-infra/stackmon-config that referenced this pull request Jun 19, 2024
otc-zuul bot pushed a commit to opentelekomcloud-infra/stackmon-config that referenced this pull request Jul 10, 2024
Update Status Dashboard to latest version

timestamp standardization: stackmon/status-dashboard#121 API fix stackmon/status-dashboard#122

Reviewed-by: Aloento
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gate Gate PR with Zuul
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants