-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(website): Optimize website expiration time setting #8061
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package migrations | |
| import ( | ||
| "fmt" | ||
| "path" | ||
| "time" | ||
|
|
||
| "github.com/1Panel-dev/1Panel/agent/app/dto/request" | ||
| "github.com/1Panel-dev/1Panel/agent/app/model" | ||
|
|
@@ -296,3 +297,17 @@ var InitDefault = &gormigrate.Migration{ | |
| return nil | ||
| }, | ||
| } | ||
|
|
||
| var UpdateWebsiteExpireDate = &gormigrate.Migration{ | ||
| ID: "20250304-update-website", | ||
| Migrate: func(tx *gorm.DB) error { | ||
| targetDate := time.Date(9999, 12, 31, 0, 0, 0, 0, time.UTC) | ||
|
|
||
| if err := tx.Model(&model.Website{}). | ||
| Where("expire_date = ?", time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)). | ||
| Update("expire_date", targetDate).Error; err != nil { | ||
| return err | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code appears to be incomplete and there is no proper documentation for what each variable represents. It can't be analyzed unless I am provided with additional context about its purpose. However, here's a very basic suggestion that doesn't involve changing existing features:
To optimize, review performance of It seems like the author was trying to introduce an update function within another migration (the initial init_migration), but didn't implement the logic properly because they were missing information needed for completion. The commented-out ID should point towards either importing relevant Gormigrate package types or defining the migrations manually from scratch if the original intention isn’t clear from these snippets alone. As mentioned before, more detailed information would help analyze this fully, including how the other parts of the code interact. Please let me know if you need assistance with anything else! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,7 @@ const shortcuts = [ | |
| { | ||
| text: useI18n().t('website.ever'), | ||
| value: () => { | ||
| return new Date('1970-01-01'); | ||
| return new Date('9999-12-31'); | ||
| }, | ||
| }, | ||
| { | ||
|
|
@@ -379,7 +379,7 @@ const openConfig = (id: number) => { | |
|
|
||
| const isEver = (time: string) => { | ||
| const expireDate = new Date(time); | ||
| return expireDate < new Date('1970-01-02'); | ||
| return expireDate > new Date('9999-12-30'); | ||
| }; | ||
|
|
||
| const isBeforeNow = (time: string) => { | ||
|
|
@@ -415,10 +415,14 @@ const setdateRefs = (ref: any) => { | |
| }; | ||
|
|
||
| const initDatePicker = (row: any) => { | ||
| if (dataRef.value == undefined && row.oldExpireDate == undefined && isBeforeNow(row.expireDate)) { | ||
| if ( | ||
| (dataRef.value == undefined && row.oldExpireDate == undefined && isBeforeNow(row.expireDate)) || | ||
| isEver(row.expireDate) | ||
| ) { | ||
| row.oldExpireDate = row.expireDate; | ||
| const date = new Date().toLocaleDateString(); | ||
| row.expireDate = date; | ||
| return; | ||
| } | ||
| }; | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided changes suggest no significant differences from the previous code block, and there do not seem to be any bugs or optimizations that can be suggested based on these shortcodes. If you have more specific concerns about the current code structure, please share them so I could provide further assistance. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues have been identified with this code. It appears to be written efficiently within the parameters of current knowledge cutoff and can further optimizations if needed.