Skip to content

Commit fa4db41

Browse files
authored
Merge pull request #218 from OpenTreeHole/ai_summary
feat: update trace id
2 parents 03d88d0 + 0d70ea8 commit fa4db41

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

apis/hole/apis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ func GenerateSummary(c *fiber.Ctx) error {
10491049
if cachedData.Data.HoleID != id && cachedData.Data.HoleID != 0 {
10501050
log.Error().
10511051
Int("hole_id", id).
1052-
Str("trace_id", cachedData.TraceID).
1052+
Str("trace_id", cachedData.Data.TraceID).
10531053
Int("ai_server_return_id", cachedData.Data.HoleID).
10541054
Msg("AISummary: hole id error")
10551055
cachedData.Data.HoleID = id

apis/hole/schemas.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ func (body ModifyModel) DoNothing() bool {
133133

134134
type Summary struct {
135135
Code int `json:"code"`
136-
TraceID string `json:"trace_id"`
137136
Message string `json:"message"`
138137
Data struct {
139138
HoleID int `json:"hole_id"`
139+
TraceID string `json:"trace_id"`
140140
Summary string `json:"summary"`
141141
Branches []struct {
142142
ID int `json:"id"`

models/hole.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ func (holes Holes) Preprocess(c *fiber.Ctx) error {
290290
floors = append(floors, hole.Floors...)
291291
// set ai_summary_available
292292
uid, _ := common.GetUserID(c)
293+
294+
// for users in whitelist or whitelist is empty, AISummaryAvailable is true,
293295
hole.AISummaryAvailable = config.Config.WhiteListUserIds == nil || slices.Contains(config.Config.WhiteListUserIds, uid)
296+
297+
hole.AISummaryAvailable = !(hole.Locked || hole.Hidden || hole.Frozen)
294298
for _, tag := range hole.Tags {
295299
if len(tag.Name) > 0 && tag.Name[0] == '*' {
296300
hole.AISummaryAvailable = false
@@ -313,7 +317,6 @@ func (holes Holes) Preprocess(c *fiber.Ctx) error {
313317
return err
314318
}
315319

316-
// var discard any
317320
hole.AISummaryAvailable = hole.Reply > config.Config.SummaryFloorLimit || contentSum >= config.Config.SummaryContentLimit // || utils.GetCache("AISummary"+strconv.Itoa(hole.ID), &discard)
318321

319322
if hole.AISummaryAvailable {

0 commit comments

Comments
 (0)