diff --git a/models/custom_migrations.go b/models/custom_migrations.go index 6dbbf00f2..ec0e5f75e 100644 --- a/models/custom_migrations.go +++ b/models/custom_migrations.go @@ -22,6 +22,7 @@ var customMigrations = []CustomMigration{ } var customMigrationsStatic = []CustomMigrationStatic{ + {"Alter user static table field type ", alterUserStaticTable}, {"Delete zuzhi user history data ", deleteNotDisplayUser}, } @@ -57,6 +58,14 @@ func syncTopicStruct(x *xorm.Engine) error { return err } +func alterUserStaticTable(x *xorm.Engine, static *xorm.Engine) error { + alterSql := "alter table public.user_business_analysis alter column open_i_index type double precision" + + _, err := static.Exec(alterSql) + return err + +} + func deleteNotDisplayUser(x *xorm.Engine, static *xorm.Engine) error { querySQL := "select id,name from public.user where type=1" diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index ac51c2816..f30631ae1 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -65,7 +65,7 @@ type UserBusinessAnalysis struct { LoginCount int `xorm:"NOT NULL DEFAULT 0"` //openi index - OpenIIndex int `xorm:"NOT NULL DEFAULT 0"` + OpenIIndex float64 `xorm:"NOT NULL DEFAULT 0"` //user Email string `xorm:"NOT NULL"` @@ -366,7 +366,7 @@ func CounDataByDate(wikiCountMap map[string]int, startTime time.Time, endTime ti if _, ok := OpenIIndexMap[dateRecord.ID]; !ok { dateRecord.OpenIIndex = 0 } else { - dateRecord.OpenIIndex = int(OpenIIndexMap[dateRecord.ID] * 100) + dateRecord.OpenIIndex = OpenIIndexMap[dateRecord.ID] } dateRecord.CommitModelCount = 0