fix: favorites creation timestamps and remove duplicate imports
This commit is contained in:
parent
0224a43736
commit
4d209f2a90
@ -9,6 +9,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"slices"
|
"slices"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
@ -132,7 +133,12 @@ outer:
|
|||||||
if len(anthroveFaves) > 0 {
|
if len(anthroveFaves) > 0 {
|
||||||
span.AddEvent("Executing CreateUserFavoriteInBatch")
|
span.AddEvent("Executing CreateUserFavoriteInBatch")
|
||||||
|
|
||||||
|
for i, fav := range anthroveFaves {
|
||||||
|
fav.CreatedAt = time.Now().Add(time.Millisecond * time.Duration(i) * -1)
|
||||||
|
}
|
||||||
|
|
||||||
slices.Reverse(anthroveFaves)
|
slices.Reverse(anthroveFaves)
|
||||||
|
|
||||||
err = database.CreateUserFavoriteInBatch(ctx, anthroveFaves, BatchSize)
|
err = database.CreateUserFavoriteInBatch(ctx, anthroveFaves, BatchSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
|
@ -2,9 +2,6 @@ package plug
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"slices"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/database"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/database"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -12,6 +9,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel/codes"
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
var BatchSize = 50
|
var BatchSize = 50
|
||||||
@ -98,9 +96,6 @@ func BatchPostProcessingWithSummery(ctx context.Context, userSource models.UserS
|
|||||||
return found
|
return found
|
||||||
}) {
|
}) {
|
||||||
anthroveFaves = append(anthroveFaves, models.UserFavorite{
|
anthroveFaves = append(anthroveFaves, models.UserFavorite{
|
||||||
BaseModel: models.BaseModel[models.UserFavoriteID]{
|
|
||||||
CreatedAt: time.Now().Add(time.Millisecond * time.Duration(i) * -1),
|
|
||||||
},
|
|
||||||
UserID: userSource.UserID,
|
UserID: userSource.UserID,
|
||||||
PostID: post.ID,
|
PostID: post.ID,
|
||||||
UserSourceID: userSource.ID,
|
UserSourceID: userSource.ID,
|
||||||
|
Loading…
Reference in New Issue
Block a user