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

Added Initial PostgreSQL support #399

Merged
merged 7 commits into from
Jan 28, 2025
Merged

Conversation

EliasMasche
Copy link
Contributor

No description provided.

@linkdotnet
Copy link
Owner

Very good start! I will try to have a look today or tomorrow.

Under docs - some readme files would need some enhancements.
Mainly: https://github.com/linkdotnet/Blog/blob/master/docs/Storage/Readme.md

@EliasMasche
Copy link
Contributor Author

There I updated the docs listing PostgreSql

@linkdotnet
Copy link
Owner

Small other things:

I guess I put it wrongly in: #207 (comment)

The initial changes so that PostgreSql works without any exception, should work. So UpdateDate and ScheduledPublishDate should be in UTC. This should be part of this PR, otherwise it will not work. At least this is my understanding, right?

But other parts like the Background-jobs, I will take over once merged.

@EliasMasche
Copy link
Contributor Author

Yes, there is a little confusion, I will include the details, and any recommendations or tips on where to apply the UTC config when using PostgreSQL or where to look still taking me time to navigate through the project

@linkdotnet
Copy link
Owner

Yes, there is a little confusion, I will include the details, and any recommendations or tips on where to apply the UTC config when using PostgreSQL or where to look still taking me time to navigate through the project

Take your time. I am no expert on Postgres.
But in the code there aren’t too many places. Mainly when a new blog post is created or updated.

@EliasMasche
Copy link
Contributor Author

EliasMasche commented Jan 8, 2025

I was able to update DateTime to UtcNow from BlogPost.cs
var blogPostUpdateDate = scheduledPublishDate ?? updatedDate ?? DateTime.UtcNow;

When you need to publish now, ' ScheduledPublishDatetriggers the exception ofKind=Unspecified` from PostgreSql when you schedule the post's release.

These three steps are handled in the fields CreateNewBlogPost.razor, CreateNewModel.cs, and BlogPost.cs where is gonna the best place or time to adapt the local time to Utc

@linkdotnet
Copy link
Owner

Good start. I get an exception when I try to set the scheduled date:
image

@linkdotnet
Copy link
Owner

That said, we might want to refactor:

<InputDate Type="InputDateType.DateTimeLocal" class="form-control" id="scheduled"
           placeholder="Scheduled Publish Date" @bind-Value="model.ScheduledPublishDate"
           @bind-Value:after="@(() => model.IsPublished &= !IsScheduled)" />

Away from the direct two-way-binding. Or transform this into UTC when creating the BlogPost object.

@linkdotnet
Copy link
Owner

Maybe also a low-hanging fruit you can implement:
Inside the CreateNewBlogPost.razor Page: Kann you add (in UTC) or similar to the Updated Date and Scheduled Publish Date in the UI?

So folks know it isn't there local time zone anymore

@EliasMasche
Copy link
Contributor Author

Thanks for the info, I will check when I get to work again and see which option I picked.

@EliasMasche
Copy link
Contributor Author

Hello there, I have been working with life stuff so now I am able to update ScheduledPublishDate for handling UTC, add a description on the GUI that all dates are saved as UTC on the DB and on CreateNewModel.cs to convert to LocalTime for displaying on the admin for the user convenience.

@linkdotnet
Copy link
Owner

Amazing - works like a charm!

@linkdotnet
Copy link
Owner

I took the liberty to fix the merge conflict. In any case - I will merge that in! Really great work!

@linkdotnet linkdotnet merged commit fca124d into linkdotnet:master Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants