package models import ( "time" "code.gitea.io/gitea/modules/timeutil" ) const ( StorageScheduleSucceed int = iota StorageScheduleProcessing StorageScheduleFailed ) type ScheduleRecord struct { ID int64 `xorm:"pk autoincr"` CloudbrainID int64 `xorm:"INDEX NOT NULL unique"` EndPoint string `xorm:"INDEX NOT NULL"` Bucket string `xorm:"INDEX NOT NULL"` ObjectKey string `xorm:"INDEX NOT NULL"` ProxyServer string `xorm:"INDEX NOT NULL"` Status int `xorm:"INDEX NOT NULL DEFAULT 0"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` DeletedAt time.Time `xorm:"deleted"` } func updateScheduleCols(e Engine, record *ScheduleRecord, cols ...string) error { _, err := e.ID(record.ID).Cols(cols...).Update(record) return err } func UpdateScheduleCols(record *ScheduleRecord, cols ...string) error { return updateScheduleCols(x, record, cols...) } func GetSchedulingRecord() ([]*ScheduleRecord, error) { records := make([]*ScheduleRecord, 0, 10) return records, x. Where("status = ?", StorageScheduleProcessing). Limit(100). Find(&records) } func InsertScheduleRecord(record *ScheduleRecord) (_ *ScheduleRecord, err error) { if _, err := x.Insert(record); err != nil { return nil, err } return record, nil }