Skip to content

Commit

Permalink
fix user pfp display
Browse files Browse the repository at this point in the history
  • Loading branch information
ddusichka committed Dec 4, 2024
1 parent 6940518 commit 4dbc35b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
18 changes: 8 additions & 10 deletions backend/internal/models/profile.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package models

import "database/sql"

type Profile struct {
UserID string `json:"user_id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
ProfilePicture sql.NullString `json:"profile_picture"`
Bio sql.NullString `json:"bio"`
Score int `json:"score"`
Followers int `json:"followers"`
Followed int `json:"followed"`
UserID string `json:"user_id"`
Username string `json:"username"`
DisplayName string `json:"display_name"`
ProfilePicture *string `json:"profile_picture"`
Bio *string `json:"bio"`
Score int `json:"score"`
Followers int `json:"followers"`
Followed int `json:"followed"`
}
13 changes: 11 additions & 2 deletions backend/internal/storage/postgres/schema/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,27 @@ func (r *UserRepository) GetProfileByName(ctx context.Context, name string) ([]*

for profileRows.Next() {
var profile models.Profile
var profilePicture, bio sql.NullString
if err := profileRows.Scan(
&profile.UserID,
&profile.Username,
&profile.DisplayName,
&profile.ProfilePicture,
&profile.Bio,
&profilePicture,
&bio,
&profile.Followers,
&profile.Followed,
); err != nil {
return nil, err
}

if profilePicture.Valid {
profile.ProfilePicture = &profilePicture.String
}

if bio.Valid {
profile.Bio = &bio.String
}

userUUID, err := uuid.Parse(profile.UserID)
if err != nil {
return nil, err
Expand Down

0 comments on commit 4dbc35b

Please sign in to comment.