feat(views): save position in Typesense
This commit is contained in:
parent
14353b24d7
commit
5641da27f7
@ -244,7 +244,13 @@ func ReindexAllTasks() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTypesenseTaskForTask(s *xorm.Session, task *Task, projectsCache map[int64]*Project) (ttask *typesenseTask, err error) {
|
func getTypesenseTaskForTask(s *xorm.Session, task *Task, projectsCache map[int64]*Project) (ttask *typesenseTask, err error) {
|
||||||
ttask = convertTaskToTypesenseTask(task)
|
positions := []*TaskPosition{}
|
||||||
|
err = s.Where("task_id = ?", task.ID).Find(&positions)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ttask = convertTaskToTypesenseTask(task, positions)
|
||||||
|
|
||||||
var p *Project
|
var p *Project
|
||||||
if projectsCache == nil {
|
if projectsCache == nil {
|
||||||
@ -411,8 +417,6 @@ type typesenseTask struct {
|
|||||||
CoverImageAttachmentID int64 `json:"cover_image_attachment_id"`
|
CoverImageAttachmentID int64 `json:"cover_image_attachment_id"`
|
||||||
Created int64 `json:"created"`
|
Created int64 `json:"created"`
|
||||||
Updated int64 `json:"updated"`
|
Updated int64 `json:"updated"`
|
||||||
BucketID int64 `json:"bucket_id"`
|
|
||||||
Position float64 `json:"position"`
|
|
||||||
CreatedByID int64 `json:"created_by_id"`
|
CreatedByID int64 `json:"created_by_id"`
|
||||||
Reminders interface{} `json:"reminders"`
|
Reminders interface{} `json:"reminders"`
|
||||||
Assignees interface{} `json:"assignees"`
|
Assignees interface{} `json:"assignees"`
|
||||||
@ -420,9 +424,13 @@ type typesenseTask struct {
|
|||||||
//RelatedTasks interface{} `json:"related_tasks"` // TODO
|
//RelatedTasks interface{} `json:"related_tasks"` // TODO
|
||||||
Attachments interface{} `json:"attachments"`
|
Attachments interface{} `json:"attachments"`
|
||||||
Comments interface{} `json:"comments"`
|
Comments interface{} `json:"comments"`
|
||||||
|
Positions []*struct {
|
||||||
|
Position float64 `json:"position"`
|
||||||
|
ProjectViewID int64 `json:"project_view_id"`
|
||||||
|
} `json:"positions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertTaskToTypesenseTask(task *Task) *typesenseTask {
|
func convertTaskToTypesenseTask(task *Task, positions []*TaskPosition) *typesenseTask {
|
||||||
tt := &typesenseTask{
|
tt := &typesenseTask{
|
||||||
ID: fmt.Sprintf("%d", task.ID),
|
ID: fmt.Sprintf("%d", task.ID),
|
||||||
Title: task.Title,
|
Title: task.Title,
|
||||||
@ -444,7 +452,6 @@ func convertTaskToTypesenseTask(task *Task) *typesenseTask {
|
|||||||
CoverImageAttachmentID: task.CoverImageAttachmentID,
|
CoverImageAttachmentID: task.CoverImageAttachmentID,
|
||||||
Created: task.Created.UTC().Unix(),
|
Created: task.Created.UTC().Unix(),
|
||||||
Updated: task.Updated.UTC().Unix(),
|
Updated: task.Updated.UTC().Unix(),
|
||||||
BucketID: task.BucketID,
|
|
||||||
CreatedByID: task.CreatedByID,
|
CreatedByID: task.CreatedByID,
|
||||||
Reminders: task.Reminders,
|
Reminders: task.Reminders,
|
||||||
Assignees: task.Assignees,
|
Assignees: task.Assignees,
|
||||||
@ -466,6 +473,16 @@ func convertTaskToTypesenseTask(task *Task) *typesenseTask {
|
|||||||
tt.EndDate = nil
|
tt.EndDate = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, position := range positions {
|
||||||
|
tt.Positions = append(tt.Positions, &struct {
|
||||||
|
Position float64 `json:"position"`
|
||||||
|
ProjectViewID int64 `json:"project_view_id"`
|
||||||
|
}{
|
||||||
|
Position: position.Position,
|
||||||
|
ProjectViewID: position.ProjectViewID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return tt
|
return tt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user