Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent/app/service/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
runtime.CodeDir = req.CodeDir
runtime.Port = strings.Join(hostPorts, ",")
runtime.Status = constant.StatusReCreating
runtime.ContainerName = req.Params["CONTAINER_NAME"].(string)
_ = runtimeRepo.Save(runtime)
go reCreateRuntime(runtime)
}
Expand Down
2 changes: 1 addition & 1 deletion agent/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
primaryDomain = fmt.Sprintf("%s:%v", domains[0].Domain, domains[0].Port)
}

defaultDate, _ := time.Parse(constant.DateLayout, constant.DefaultDate)
defaultDate, _ := time.Parse(constant.DateLayout, constant.WebsiteDefaultExpireDate)
website := &model.Website{
PrimaryDomain: primaryDomain,
Type: create.Type,
Expand Down
9 changes: 5 additions & 4 deletions agent/constant/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ const (
TimeOut20s = 20
TimeOut5m = 300

DateLayout = "2006-01-02" // or use time.DateOnly while go version >= 1.20
DefaultDate = "1970-01-01"
DateTimeLayout = "2006-01-02 15:04:05" // or use time.DateTime while go version >= 1.20
DateTimeSlimLayout = "20060102150405"
DateLayout = "2006-01-02" // or use time.DateOnly while go version >= 1.20
DefaultDate = "1970-01-01"
DateTimeLayout = "2006-01-02 15:04:05" // or use time.DateTime while go version >= 1.20
DateTimeSlimLayout = "20060102150405"
WebsiteDefaultExpireDate = "9999-12-31"
)

const (
Copy link
Member

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.

Expand Down
1 change: 1 addition & 0 deletions agent/init/migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func InitAgentDB() {
migrations.AddOllamaModel,
migrations.UpdateSettingStatus,
migrations.InitDefault,
migrations.UpdateWebsiteExpireDate,
})
if err := m.Migrate(); err != nil {
global.LOG.Error(err)
Expand Down
15 changes: 15 additions & 0 deletions agent/init/migration/migrations/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
},
}
Copy link
Member

Choose a reason for hiding this comment

The 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.
Additionally, using the time package in this way (e.g., setting expire dates directly on database rows) may not align well with current best practices, as it can lead to unexpected behavior such as overwriting previous timestamps which might conflict if you have different expiry policies elsewhere in the application.

However, here's a very basic suggestion that doesn't involve changing existing features:

  • Import only necessary packages,
  • If needed use comments explaining the functions or variables (ID, path, etc.)

To optimize, review performance of UpdateWebsiteExpireDate, remove unused imports, and ensure consistent coding style across files while keeping API consistency.

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!

10 changes: 7 additions & 3 deletions frontend/src/views/website/website/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const shortcuts = [
{
text: useI18n().t('website.ever'),
value: () => {
return new Date('1970-01-01');
return new Date('9999-12-31');
},
},
{
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
}
};

Copy link
Member

Choose a reason for hiding this comment

The 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.

Expand Down
Loading