mirror of https://gitee.com/answerdev/answer.git
fix(search): Fixed #307, Closes #307. when connection mysql(MariaDB) with option of 'parseTime=true', the time of search result is parse error.
This commit is contained in:
parent
c55cecc6ad
commit
8a2522cb3b
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
||||||
"github.com/answerdev/answer/plugin"
|
"github.com/answerdev/answer/plugin"
|
||||||
|
"github.com/segmentfault/pacman/log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -469,7 +470,13 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
|
||||||
for _, r := range res {
|
for _, r := range res {
|
||||||
questionIDs = append(questionIDs, string(r["question_id"]))
|
questionIDs = append(questionIDs, string(r["question_id"]))
|
||||||
userIDs = append(userIDs, string(r["user_id"]))
|
userIDs = append(userIDs, string(r["user_id"]))
|
||||||
tp, _ := time.ParseInLocation("2006-01-02 15:04:05", string(r["created_at"]), time.Local)
|
tp, pe := time.ParseInLocation("2006-01-02 15:04:05", string(r["created_at"]), time.Local)
|
||||||
|
if pe != nil {
|
||||||
|
tp, pe = time.ParseInLocation("2006-01-02T15:04:05Z", string(r["created_at"]), time.Local)
|
||||||
|
if pe != nil {
|
||||||
|
log.Error("parse time error: ", pe)
|
||||||
|
}
|
||||||
|
}
|
||||||
object := &schema.SearchObject{
|
object := &schema.SearchObject{
|
||||||
ID: string(r["id"]),
|
ID: string(r["id"]),
|
||||||
QuestionID: string(r["question_id"]),
|
QuestionID: string(r["question_id"]),
|
||||||
|
|
Loading…
Reference in New Issue