feat: optimize log indexes
This commit is contained in:
@@ -186,8 +186,11 @@ func (s *Service) UpdateLog(
|
||||
return nil, status.Errorf(codes.Internal, "write logs: %v", err)
|
||||
}
|
||||
task.LogLength += int64(len(rows))
|
||||
if task.LogIndexes == nil {
|
||||
task.LogIndexes = &bots_model.LogIndexes{}
|
||||
}
|
||||
for _, n := range ns {
|
||||
task.LogIndexes = append(task.LogIndexes, task.LogSize)
|
||||
*task.LogIndexes = append(*task.LogIndexes, task.LogSize)
|
||||
task.LogSize += int64(n)
|
||||
}
|
||||
if err := bots_model.UpdateTask(ctx, task, "log_indexes", "log_length", "log_size"); err != nil {
|
||||
|
||||
@@ -179,7 +179,7 @@ func BuildViewPost(ctx *context.Context) {
|
||||
if cursor.Cursor < step.LogLength || step.LogLength < 0 {
|
||||
index := step.LogIndex + cursor.Cursor
|
||||
length := step.LogLength - cursor.Cursor
|
||||
offset := task.LogIndexes[index]
|
||||
offset := (*task.LogIndexes)[index]
|
||||
logRows, err = bots.ReadLogs(ctx, task.LogURL, offset, length)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user