Remove all Unix suffixes in field names
This commit is contained in:
parent
ff152e4d0d
commit
01c2b57950
|
@ -205,12 +205,12 @@ func makeCalDavTimeFromTimeStamp(ts timeutil.TimeStamp) (caldavtime string) {
|
|||
return ts.ToTime().In(tz).Format(DateFormat)
|
||||
}
|
||||
|
||||
func calcAlarmDateFromReminder(eventStartUnix, reminderUnix timeutil.TimeStamp) (alarmTime string) {
|
||||
if eventStartUnix > reminderUnix {
|
||||
func calcAlarmDateFromReminder(eventStart, reminder timeutil.TimeStamp) (alarmTime string) {
|
||||
if eventStart > reminder {
|
||||
alarmTime += `-`
|
||||
}
|
||||
alarmTime += `PT`
|
||||
diff := eventStartUnix - reminderUnix
|
||||
diff := eventStart - reminder
|
||||
if diff < 0 { // Make it positive
|
||||
diff = diff * -1
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ type File struct {
|
|||
|
||||
Created time.Time `xorm:"-" json:"created"`
|
||||
|
||||
CreatedUnix timeutil.TimeStamp `xorm:"created" json:"-"`
|
||||
Created timeutil.TimeStamp `xorm:"created" json:"-"`
|
||||
CreatedByID int64 `xorm:"int(11) not null" json:"-"`
|
||||
|
||||
File afero.File `xorm:"-" json:"-"`
|
||||
|
@ -66,7 +66,7 @@ func (f *File) LoadFileMetaByID() (err error) {
|
|||
if !exists {
|
||||
return ErrFileDoesNotExist{FileID: f.ID}
|
||||
}
|
||||
f.Created = f.CreatedUnix.ToTime()
|
||||
f.Created = f.Created.ToTime()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ func (ta *TaskAttachment) ReadAll(a web.Auth, search string, page int, perPage i
|
|||
continue
|
||||
}
|
||||
r.File = fs[r.FileID]
|
||||
r.File.Created = r.File.CreatedUnix.ToTime()
|
||||
r.File.Created = r.File.Created.ToTime()
|
||||
r.CreatedBy = us[r.CreatedByID]
|
||||
}
|
||||
|
||||
|
|
|
@ -57,14 +57,14 @@ func validateTaskField(fieldName string) error {
|
|||
taskPropertyTitle,
|
||||
taskPropertyDescription,
|
||||
taskPropertyDone,
|
||||
taskPropertyDoneAtUnix,
|
||||
taskPropertyDueDateUnix,
|
||||
taskPropertyDoneAt,
|
||||
taskPropertyDueDate,
|
||||
taskPropertyCreatedByID,
|
||||
taskPropertyListID,
|
||||
taskPropertyRepeatAfter,
|
||||
taskPropertyPriority,
|
||||
taskPropertyStartDateUnix,
|
||||
taskPropertyEndDateUnix,
|
||||
taskPropertyStartDate,
|
||||
taskPropertyEndDate,
|
||||
taskPropertyHexColor,
|
||||
taskPropertyPercentDone,
|
||||
taskPropertyUID,
|
||||
|
@ -123,13 +123,13 @@ func (tf *TaskCollection) ReadAll(a web.Auth, search string, page int, perPage i
|
|||
// FIXME: This is really dirty, to fix this properly the db fields should be renamed
|
||||
switch param.sortBy {
|
||||
case "done_at":
|
||||
param.sortBy = taskPropertyDoneAtUnix
|
||||
param.sortBy = taskPropertyDoneAt
|
||||
case "due_date":
|
||||
param.sortBy = taskPropertyDueDateUnix
|
||||
param.sortBy = taskPropertyDueDate
|
||||
case "start_date":
|
||||
param.sortBy = taskPropertyStartDateUnix
|
||||
param.sortBy = taskPropertyStartDate
|
||||
case "end_date":
|
||||
param.sortBy = taskPropertyEndDateUnix
|
||||
param.sortBy = taskPropertyEndDate
|
||||
}
|
||||
|
||||
// Param validation
|
||||
|
|
|
@ -91,10 +91,10 @@ func getTaskFiltersByCollections(c *TaskCollection) (filters []*taskFilter, err
|
|||
|
||||
// Special case for pseudo date fields
|
||||
// FIXME: This is really dirty, to fix this properly the db fields should be renamed
|
||||
if filter.field+"_unix" == taskPropertyDoneAtUnix ||
|
||||
filter.field+"_unix" == taskPropertyDueDateUnix ||
|
||||
filter.field+"_unix" == taskPropertyStartDateUnix ||
|
||||
filter.field+"_unix" == taskPropertyEndDateUnix {
|
||||
if filter.field+"_unix" == taskPropertyDoneAt ||
|
||||
filter.field+"_unix" == taskPropertyDueDate ||
|
||||
filter.field+"_unix" == taskPropertyStartDate ||
|
||||
filter.field+"_unix" == taskPropertyEndDate {
|
||||
filter.field += "_unix"
|
||||
}
|
||||
|
||||
|
|
|
@ -26,24 +26,24 @@ type (
|
|||
)
|
||||
|
||||
const (
|
||||
taskPropertyID string = "id"
|
||||
taskPropertyTitle string = "title"
|
||||
taskPropertyDescription string = "description"
|
||||
taskPropertyDone string = "done"
|
||||
taskPropertyDoneAtUnix string = "done_at_unix"
|
||||
taskPropertyDueDateUnix string = "due_date_unix"
|
||||
taskPropertyCreatedByID string = "created_by_id"
|
||||
taskPropertyListID string = "list_id"
|
||||
taskPropertyRepeatAfter string = "repeat_after"
|
||||
taskPropertyPriority string = "priority"
|
||||
taskPropertyStartDateUnix string = "start_date_unix"
|
||||
taskPropertyEndDateUnix string = "end_date_unix"
|
||||
taskPropertyHexColor string = "hex_color"
|
||||
taskPropertyPercentDone string = "percent_done"
|
||||
taskPropertyUID string = "uid"
|
||||
taskPropertyCreated string = "created"
|
||||
taskPropertyUpdated string = "updated"
|
||||
taskPropertyPosition string = "position"
|
||||
taskPropertyID string = "id"
|
||||
taskPropertyTitle string = "title"
|
||||
taskPropertyDescription string = "description"
|
||||
taskPropertyDone string = "done"
|
||||
taskPropertyDoneAt string = "done_at_unix"
|
||||
taskPropertyDueDate string = "due_date_unix"
|
||||
taskPropertyCreatedByID string = "created_by_id"
|
||||
taskPropertyListID string = "list_id"
|
||||
taskPropertyRepeatAfter string = "repeat_after"
|
||||
taskPropertyPriority string = "priority"
|
||||
taskPropertyStartDate string = "start_date_unix"
|
||||
taskPropertyEndDate string = "end_date_unix"
|
||||
taskPropertyHexColor string = "hex_color"
|
||||
taskPropertyPercentDone string = "percent_done"
|
||||
taskPropertyUID string = "uid"
|
||||
taskPropertyCreated string = "created"
|
||||
taskPropertyUpdated string = "updated"
|
||||
taskPropertyPosition string = "position"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -46,14 +46,14 @@ func TestSortParamValidation(t *testing.T) {
|
|||
taskPropertyTitle,
|
||||
taskPropertyDescription,
|
||||
taskPropertyDone,
|
||||
taskPropertyDoneAtUnix,
|
||||
taskPropertyDueDateUnix,
|
||||
taskPropertyDoneAt,
|
||||
taskPropertyDueDate,
|
||||
taskPropertyCreatedByID,
|
||||
taskPropertyListID,
|
||||
taskPropertyRepeatAfter,
|
||||
taskPropertyPriority,
|
||||
taskPropertyStartDateUnix,
|
||||
taskPropertyEndDateUnix,
|
||||
taskPropertyStartDate,
|
||||
taskPropertyEndDate,
|
||||
taskPropertyHexColor,
|
||||
taskPropertyPercentDone,
|
||||
taskPropertyUID,
|
||||
|
|
|
@ -92,7 +92,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
ID: 1,
|
||||
Name: "test",
|
||||
Size: 100,
|
||||
CreatedUnix: 1570998791,
|
||||
Created: 1570998791,
|
||||
CreatedByID: 1,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -471,9 +471,9 @@ func addMoreInfoToTasks(taskMap map[int64]*Task) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
taskRemindersUnix := make(map[int64][]timeutil.TimeStamp)
|
||||
taskReminders := make(map[int64][]timeutil.TimeStamp)
|
||||
for _, r := range reminders {
|
||||
taskRemindersUnix[r.TaskID] = append(taskRemindersUnix[r.TaskID], r.Reminder)
|
||||
taskReminders[r.TaskID] = append(taskReminders[r.TaskID], r.Reminder)
|
||||
}
|
||||
|
||||
// Get all identifiers
|
||||
|
@ -490,7 +490,7 @@ func addMoreInfoToTasks(taskMap map[int64]*Task) (err error) {
|
|||
task.CreatedBy = users[task.CreatedByID]
|
||||
|
||||
// Add the reminders
|
||||
task.Reminders = taskRemindersUnix[task.ID]
|
||||
task.Reminders = taskReminders[task.ID]
|
||||
|
||||
// Prepare the subtasks
|
||||
task.RelatedTasks = make(RelatedTaskMap)
|
||||
|
@ -796,7 +796,7 @@ func (t *Task) Update() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// This helper function updates the reminders, doneAtUnix, start and end dates of the *old* task
|
||||
// This helper function updates the reminders, doneAt, start and end dates of the *old* task
|
||||
// and saves the new values in the newTask object.
|
||||
// We make a few assumtions here:
|
||||
// 1. Everything in oldTask is the truth - we figure out if we update anything at all if oldTask.RepeatAfter has a value > 0
|
||||
|
|
|
@ -153,7 +153,7 @@ func TestUpdateDone(t *testing.T) {
|
|||
updateDone(oldTask, newTask)
|
||||
|
||||
var expected int64 = 1550008600
|
||||
for expected < time.Now().Unix() {
|
||||
for expected < time.Now().() {
|
||||
expected += oldTask.RepeatAfter
|
||||
}
|
||||
|
||||
|
@ -188,10 +188,10 @@ func TestUpdateDone(t *testing.T) {
|
|||
|
||||
var expected1 int64 = 1550008600
|
||||
var expected2 int64 = 1555008600
|
||||
for expected1 < time.Now().Unix() {
|
||||
for expected1 < time.Now().() {
|
||||
expected1 += oldTask.RepeatAfter
|
||||
}
|
||||
for expected2 < time.Now().Unix() {
|
||||
for expected2 < time.Now().() {
|
||||
expected2 += oldTask.RepeatAfter
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ func TestUpdateDone(t *testing.T) {
|
|||
updateDone(oldTask, newTask)
|
||||
|
||||
var expected int64 = 1550008600
|
||||
for expected < time.Now().Unix() {
|
||||
for expected < time.Now().() {
|
||||
expected += oldTask.RepeatAfter
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ func TestUpdateDone(t *testing.T) {
|
|||
updateDone(oldTask, newTask)
|
||||
|
||||
var expected int64 = 1550008600
|
||||
for expected < time.Now().Unix() {
|
||||
for expected < time.Now().() {
|
||||
expected += oldTask.RepeatAfter
|
||||
}
|
||||
|
||||
|
|
|
@ -341,11 +341,11 @@ func convertTodoistToVikunja(sync *sync) (fullVikunjaHierachie []*models.Namespa
|
|||
|
||||
tasks[n.ItemID].Attachments = append(tasks[n.ItemID].Attachments, &models.TaskAttachment{
|
||||
File: &files.File{
|
||||
Name: n.FileAttachment.FileName,
|
||||
Mime: n.FileAttachment.FileType,
|
||||
Size: uint64(n.FileAttachment.FileSize),
|
||||
Created: n.Posted,
|
||||
CreatedUnix: timeutil.FromTime(n.Posted),
|
||||
Name: n.FileAttachment.FileName,
|
||||
Mime: n.FileAttachment.FileType,
|
||||
Size: uint64(n.FileAttachment.FileSize),
|
||||
Created: n.Posted,
|
||||
Created: timeutil.FromTime(n.Posted),
|
||||
// We directly pass the file contents here to have a way to link the attachment to the file later.
|
||||
// Because we don't have an ID for our task at this point of the migration, we cannot just throw all
|
||||
// attachments in a slice and do the work of downloading and properly storing them later.
|
||||
|
|
|
@ -489,7 +489,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
|
|||
Mime: "text/plain",
|
||||
Size: 12345,
|
||||
Created: time1,
|
||||
CreatedUnix: timeutil.FromTime(time1),
|
||||
Created: timeutil.FromTime(time1),
|
||||
FileContent: exampleFile,
|
||||
},
|
||||
Created: timeutil.FromTime(time1),
|
||||
|
|
|
@ -195,11 +195,11 @@ func convertListForFolder(listID int, list *list, content *wunderlistContents) (
|
|||
|
||||
newTask.Attachments = append(newTask.Attachments, &models.TaskAttachment{
|
||||
File: &files.File{
|
||||
Name: f.FileName,
|
||||
Mime: f.ContentType,
|
||||
Size: uint64(f.FileSize),
|
||||
Created: f.CreatedAt,
|
||||
CreatedUnix: timeutil.FromTime(f.CreatedAt),
|
||||
Name: f.FileName,
|
||||
Mime: f.ContentType,
|
||||
Size: uint64(f.FileSize),
|
||||
Created: f.CreatedAt,
|
||||
Created: timeutil.FromTime(f.CreatedAt),
|
||||
// We directly pass the file contents here to have a way to link the attachment to the file later.
|
||||
// Because we don't have an ID for our task at this point of the migration, we cannot just throw all
|
||||
// attachments in a slice and do the work of downloading and properly storing them later.
|
||||
|
|
|
@ -213,7 +213,7 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Mime: "text/plain",
|
||||
Size: 12345,
|
||||
Created: time2,
|
||||
CreatedUnix: timeutil.FromTime(time2),
|
||||
Created: timeutil.FromTime(time2),
|
||||
FileContent: exampleFile,
|
||||
},
|
||||
Created: timeutil.FromTime(time2),
|
||||
|
@ -257,7 +257,7 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Mime: "text/plain",
|
||||
Size: 12345,
|
||||
Created: time3,
|
||||
CreatedUnix: timeutil.FromTime(time3),
|
||||
Created: timeutil.FromTime(time3),
|
||||
FileContent: exampleFile,
|
||||
},
|
||||
Created: timeutil.FromTime(time3),
|
||||
|
|
|
@ -44,7 +44,7 @@ func NewUserJWTAuthtoken(user *user.User) (token string, err error) {
|
|||
claims["id"] = user.ID
|
||||
claims["username"] = user.Username
|
||||
claims["email"] = user.Email
|
||||
claims["exp"] = time.Now().Add(time.Hour * 72).Unix()
|
||||
claims["exp"] = time.Now().Add(time.Hour * 72).()
|
||||
|
||||
// Generate encoded token and send it as response.
|
||||
return t.SignedString([]byte(config.ServiceJWTSecret.GetString()))
|
||||
|
@ -62,7 +62,7 @@ func NewLinkShareJWTAuthtoken(share *models.LinkSharing) (token string, err erro
|
|||
claims["list_id"] = share.ListID
|
||||
claims["right"] = share.Right
|
||||
claims["sharedByID"] = share.SharedByID
|
||||
claims["exp"] = time.Now().Add(time.Hour * 72).Unix()
|
||||
claims["exp"] = time.Now().Add(time.Hour * 72).()
|
||||
|
||||
// Generate encoded token and send it as response.
|
||||
return t.SignedString([]byte(config.ServiceJWTSecret.GetString()))
|
||||
|
|
|
@ -342,12 +342,12 @@ func (vlra *VikunjaListResourceAdapter) CalculateEtag() string {
|
|||
|
||||
// Return the etag of a task if we have one
|
||||
if vlra.task != nil {
|
||||
return `"` + strconv.FormatInt(vlra.task.ID, 10) + `-` + strconv.FormatInt(vlra.task.Updated.ToTime().Unix(), 10) + `"`
|
||||
return `"` + strconv.FormatInt(vlra.task.ID, 10) + `-` + strconv.FormatInt(vlra.task.Updated.ToTime().(), 10) + `"`
|
||||
}
|
||||
// This also returns the etag of the list, and not of the task,
|
||||
// which becomes problematic because the client uses this etag (= the one from the list) to make
|
||||
// Requests to update a task. These do not match and thus updating a task fails.
|
||||
return `"` + strconv.FormatInt(vlra.list.ID, 10) + `-` + strconv.FormatInt(vlra.list.Updated.ToTime().Unix(), 10) + `"`
|
||||
return `"` + strconv.FormatInt(vlra.list.ID, 10) + `-` + strconv.FormatInt(vlra.list.Updated.ToTime().(), 10) + `"`
|
||||
}
|
||||
|
||||
// GetContent returns the content string of a resource (a task in our case)
|
||||
|
@ -372,11 +372,11 @@ func (vlra *VikunjaListResourceAdapter) GetContentSize() int64 {
|
|||
// GetModTime returns when the resource was last modified
|
||||
func (vlra *VikunjaListResourceAdapter) GetModTime() time.Time {
|
||||
if vlra.task != nil {
|
||||
return time.Unix(vlra.task.Updated.ToTime().Unix(), 0)
|
||||
return time.(vlra.task.Updated.ToTime().(), 0)
|
||||
}
|
||||
|
||||
if vlra.list != nil {
|
||||
return time.Unix(vlra.list.Updated.ToTime().Unix(), 0)
|
||||
return time.(vlra.list.Updated.ToTime().(), 0)
|
||||
}
|
||||
|
||||
return time.Time{}
|
||||
|
|
|
@ -30,12 +30,12 @@ type TimeStamp int64
|
|||
|
||||
// ToTime returns a time.Time from a TimeStamp
|
||||
func (ts *TimeStamp) ToTime() time.Time {
|
||||
return time.Unix(int64(*ts), 0)
|
||||
return time.(int64(*ts), 0)
|
||||
}
|
||||
|
||||
// FromTime converts a time.Time to a TimeStamp
|
||||
func FromTime(t time.Time) TimeStamp {
|
||||
return TimeStamp(t.Unix())
|
||||
return TimeStamp(t.())
|
||||
}
|
||||
|
||||
// MarshalJSON converts a TimeStamp to a json string
|
||||
|
@ -61,7 +61,7 @@ func (ts *TimeStamp) UnmarshalJSON(data []byte) error {
|
|||
return err
|
||||
}
|
||||
if s == "" {
|
||||
*ts = FromTime(time.Unix(0, 0))
|
||||
*ts = FromTime(time.(0, 0))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,6 @@ func (ts *TimeStamp) UnmarshalJSON(data []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
*ts = TimeStamp(t.In(loc).Unix())
|
||||
*ts = TimeStamp(t.In(loc).())
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.Seed(time.Now().Nano())
|
||||
}
|
||||
|
||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
|
Loading…
Reference in New Issue