v0.0.30.3 Добавлено логирование в получение клипов и авторов
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6a21e9411c
commit
fbcb323145
@ -31,37 +31,47 @@ 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) {
|
func (r *clipResolver) Author(ctx context.Context, obj *domain.Clip) (*domain.User, error) {
|
||||||
|
log.Printf("Resolving author for clip %d, authorID: %d", obj.ID, obj.AuthorID)
|
||||||
|
|
||||||
if obj.AuthorID == 0 {
|
if obj.AuthorID == 0 {
|
||||||
log.Printf("ERROR: Clip %d has no author ID", obj.ID)
|
log.Printf("WARNING: Clip %d has no authorID, returning stub", obj.ID)
|
||||||
return &domain.User{
|
return &domain.User{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
Username: "Unknown",
|
Username: "Unknown User",
|
||||||
Avatar: "/img/logo.png",
|
Avatar: "/img/logo.png",
|
||||||
|
Email: "unknown@example.com",
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
}, nil
|
}, nil
|
||||||
// Не возвращаем ошибку, чтобы не ломать весь запрос
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Получаем пользователя из сервиса
|
||||||
author, err := r.Services.User.GetByID(ctx, obj.AuthorID)
|
author, err := r.Services.User.GetByID(ctx, obj.AuthorID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("ERROR: Failed to get author %d for clip %d: %v", obj.AuthorID, obj.ID, err)
|
log.Printf("ERROR: Failed to get author %d for clip %d: %v", obj.AuthorID, obj.ID, err)
|
||||||
// Возвращаем заглушку вместо ошибки
|
|
||||||
return &domain.User{
|
return &domain.User{
|
||||||
ID: obj.AuthorID,
|
ID: obj.AuthorID,
|
||||||
Username: "Unknown",
|
Username: "Error Loading User",
|
||||||
Avatar: "/img/logo.png",
|
Avatar: "/img/logo.png",
|
||||||
|
Email: "error@example.com",
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if author == nil {
|
if author == nil {
|
||||||
log.Printf("ERROR: Author %d not found for clip %d", obj.AuthorID, obj.ID)
|
log.Printf("WARNING: Author %d not found for clip %d", obj.AuthorID, obj.ID)
|
||||||
return &domain.User{
|
return &domain.User{
|
||||||
ID: obj.AuthorID,
|
ID: obj.AuthorID,
|
||||||
Username: "Deleted User",
|
Username: "Deleted User",
|
||||||
Avatar: "/img/logo.png",
|
Avatar: "/img/logo.png",
|
||||||
|
Email: "deleted@example.com",
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Successfully resolved author %d for clip %d", obj.AuthorID, obj.ID)
|
log.Printf("Successfully resolved author %d for clip %d", obj.AuthorID, obj.ID)
|
||||||
log.Printf("Successfully resolved author %d for clip %d", author.Avatar, author.ID, author.Username)
|
|
||||||
return author, nil
|
return author, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,11 +258,15 @@ func (r *queryResolver) Clips(ctx context.Context, limit *int, offset *int) ([]*
|
|||||||
|
|
||||||
clips := r.protoClipsToDomain(resp.Clips)
|
clips := r.protoClipsToDomain(resp.Clips)
|
||||||
|
|
||||||
// Добавьте логирование для дебага
|
// Детальное логирование
|
||||||
log.Printf("Retrieved %d clips from gRPC service", len(clips))
|
log.Printf("Retrieved %d clips from gRPC service", len(clips))
|
||||||
for i, clip := range clips {
|
for i, clip := range clips {
|
||||||
log.Printf("Clip %d: ID=%d, Title=%s, VideoURL=%s, AuthorID=%d",
|
log.Printf("Clip %d: ID=%d, Title=%s, AuthorID=%d", i, clip.ID, clip.Title, clip.AuthorID)
|
||||||
i, clip.ID, clip.Title, clip.VideoURL, clip.AuthorID)
|
|
||||||
|
// Проверяем, что AuthorID заполнен
|
||||||
|
if clip.AuthorID == 0 {
|
||||||
|
log.Printf("ERROR: Clip %d has AuthorID=0!", clip.ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clips, nil
|
return clips, nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user