Skip to content

Commit

Permalink
fix image of product
Browse files Browse the repository at this point in the history
  • Loading branch information
KranjQ committed Dec 17, 2024
1 parent 6905ebd commit 4c71ab7
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sparkit-down:
.PHONY: sparkit-test
sparkit-test:
go test -json ./... -coverprofile coverprofile_.tmp -coverpkg=./... ; \
grep -v -e '/mocks' -e 'mock_repository.go' -e 'mock.go' -e 'docs.go' -e '_easyjson.go' -e '.pb.go' -e 'gen.go' coverprofile_.tmp > coverprofile.tmp ; \
grep -v -e '/mocks' -e 'mock_repository.go' -e 'mock.go' -e 'docs.go' -e '_easyjson.go' -e '.pb.go' -e 'gen.go' -e 'main.go' coverprofile_.tmp > coverprofile.tmp ; \
rm coverprofile_.tmp ; \
go tool cover -html coverprofile.tmp -o ../heatmap.html; \
go tool cover -func coverprofile.tmp
Expand Down
8 changes: 4 additions & 4 deletions docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ DB_USER=app_user
DB_PASSWORD=test
DB_NAME=sparkitDB
DB_SSLMODE=disable
SERVER_CERT_PATH=/etc/letsencrypt/live/spark-it.site/fullchain.pem
SERVER_KEY_PATH=/etc/letsencrypt/live/spark-it.site/privkey.pem
# SERVER_CERT_PATH=/etc/letsencrypt/live/spark-it.site/fullchain.pem
# SERVER_KEY_PATH=/etc/letsencrypt/live/spark-it.site/privkey.pem
SHOP_ID=999343
SECRET_SHOP_KEY=test_tg4qykklfcjLeOx-oMnv0jBUTKu6Cr7-FVqkG1-O1IY
# SERVER_CERT_PATH=../server.crt
# SERVER_KEY_PATH=../server.key
SERVER_CERT_PATH=../server.crt
SERVER_KEY_PATH=../server.key

1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- SparkIt-network
volumes:
- ~/imagedata:/home/${OS_USER}/imagedata
- ./resources/:/home/${OS_USER}/imageproduct
- ${SERVER_CERT_PATH}:/etc/ssl/certs/server.crt
- ${SERVER_KEY_PATH}:/etc/ssl/private/server.key

Expand Down
Binary file added docker/resources/likes100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docker/resources/likes150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docker/resources/likes50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion internal/pkg/payments/usecase/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (u *UseCase) CreateProduct(ctx context.Context, product models.Product) (in
u.logger.Error("usecase create product bad price", zap.Int("price", product.Price))
return -1, fmt.Errorf("invalid price")
}
product.ImageLink = ""
product.ImageLink = product.Title + ".png"
id, err := u.repo.CreateProduct(ctx, product)
if err != nil {
u.logger.Error("usecase create product error", zap.Error(err))
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/payments/usecase/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestUseCase(t *testing.T) {
args: args{ctx: ctx, product: models.Product{Title: "prod", Price: 100}},
mockSetup: func(repo *mocks.MockRepository) {
repo.EXPECT().CreateProduct(ctx, gomock.Any()).DoAndReturn(func(ctx context.Context, p models.Product) (int, error) {
if p.Title != "prod" || p.Price != 100 || p.ImageLink != "" {
if p.Title != "prod" || p.Price != 100 || p.ImageLink != p.Title+".png" {
return -1, fmt.Errorf("unexpected product")
}
return 1, nil
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/personalities/delivery/grpc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ func (h *GrpcPersonalitiesHandler) DeleteProfile(ctx context.Context,
return res, nil
}

func (h *GrpcPersonalitiesHandler) ChangePassword(ctx context.Context, in *generatedPersonalities.ChangePasswordRequest) (*generatedPersonalities.ChangePasswordResponse, error) {
func (h *GrpcPersonalitiesHandler) ChangePassword(ctx context.Context,
in *generatedPersonalities.ChangePasswordRequest) (*generatedPersonalities.ChangePasswordResponse, error) {
err := h.userUC.ChangePassword(ctx, int(in.UserID), in.Password)
if err != nil {
return nil, fmt.Errorf("Grpc change password error : %w", err)
Expand Down
9 changes: 8 additions & 1 deletion internal/pkg/personalities/repo/user/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,14 @@ func (repo *Storage) GetUsernameByUserId(ctx context.Context, userId int) (strin
}

func (repo *Storage) GetFeedList(ctx context.Context, userId int, receivers []int) ([]models.User, error) {
rows, err := repo.DB.Query("SELECT id, username FROM users WHERE id != $1 AND id NOT IN (SELECT receiver FROM reaction WHERE author = $2)", userId, userId)

query := `SELECT u.id, u.username
FROM users u
JOIN profile p ON p.id = u.profile
WHERE u.id != $1 AND
u.id NOT IN (SELECT receiver FROM reaction WHERE author = $1) AND
p.gender != (SELECT gender FROM profile WHERE id = (SELECT profile FROM users WHERE id = $1))`
rows, err := repo.DB.Query(query, userId)
if err != nil {
return []models.User{}, fmt.Errorf("GetFeedList err: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/personalities/repo/user/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@ func TestGetFeedList(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.queryError == nil {
mock.ExpectQuery("SELECT id, username FROM users").
WithArgs(tt.userID, tt.userID).
mock.ExpectQuery(`SELECT`).
WithArgs(tt.userID).
WillReturnRows(tt.queryRows)
} else {
mock.ExpectQuery("SELECT id, username FROM users").
WithArgs(tt.userID, tt.userID).
mock.ExpectQuery(`SELECT`).
WithArgs(tt.userID).
WillReturnError(tt.queryError)
}
list, err := repo.GetFeedList(ctx, tt.userID, tt.receivers)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/personalities/usecase/profile/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func checkAge(age int) error {
if age < 18 {
return sparkiterrors.ErrSmallAge
}
if age > 100 {
if age > 120 {
return sparkiterrors.ErrBigAge
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/personalities/usecase/profile/usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func TestCheckAge(t *testing.T) {
},
{
name: "big age",
age: 101,
age: 121,
wantErr: sparkiterrors.ErrBigAge,
},
}
Expand Down

0 comments on commit 4c71ab7

Please sign in to comment.