From e5f4f418567268ebf5498c53def196a382aac15d Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 2 Sep 2025 23:35:28 +0300 Subject: [PATCH] =?UTF-8?q?v0.0.30.3=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B8=D0=BF?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/http/graph/clip_resolvers.go | 38 ++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/internal/http/graph/clip_resolvers.go b/internal/http/graph/clip_resolvers.go index 77172c1..281a33b 100644 --- a/internal/http/graph/clip_resolvers.go +++ b/internal/http/graph/clip_resolvers.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "io" + "log" "tailly_back_v2/internal/domain" "tailly_back_v2/proto" "time" @@ -31,12 +32,33 @@ func (r *clipResolver) IsLiked(ctx context.Context, obj *domain.Clip) (bool, err func (r *clipResolver) Author(ctx context.Context, obj *domain.Clip) (*domain.User, error) { if obj.AuthorID == 0 { - return nil, fmt.Errorf("clip has no author ID") + log.Printf("ERROR: Clip %d has no author ID", obj.ID) + return &domain.User{ + ID: 0, + Username: "Unknown", + Avatar: "/img/logo.png", + }, nil + // Не возвращаем ошибку, чтобы не ломать весь запрос } author, err := r.Services.User.GetByID(ctx, obj.AuthorID) if err != nil { - return nil, fmt.Errorf("failed to get author: %w", err) + log.Printf("ERROR: Failed to get author %d for clip %d: %v", obj.AuthorID, obj.ID, err) + // Возвращаем заглушку вместо ошибки + return &domain.User{ + ID: obj.AuthorID, + Username: "Unknown", + Avatar: "/img/logo.png", + }, nil + } + + if author == nil { + log.Printf("ERROR: Author %d not found for clip %d", obj.AuthorID, obj.ID) + return &domain.User{ + ID: obj.AuthorID, + Username: "Deleted User", + Avatar: "/img/logo.png", + }, nil } return author, nil @@ -219,10 +241,20 @@ func (r *queryResolver) Clips(ctx context.Context, limit *int, offset *int) ([]* Offset: int32(offsetVal), }) if err != nil { + log.Printf("ERROR: Failed to get clips from gRPC service: %v", err) return nil, fmt.Errorf("failed to get clips: %w", err) } - return r.protoClipsToDomain(resp.Clips), nil + clips := r.protoClipsToDomain(resp.Clips) + + // Добавьте логирование для дебага + log.Printf("Retrieved %d clips from gRPC service", len(clips)) + for i, clip := range clips { + log.Printf("Clip %d: ID=%d, Title=%s, VideoURL=%s, AuthorID=%d", + i, clip.ID, clip.Title, clip.VideoURL, clip.AuthorID) + } + + return clips, nil } // UserClips is the resolver for the userClips field.