Skip to content

Commit

Permalink
fix map, update house advert, building handler
Browse files Browse the repository at this point in the history
  • Loading branch information
vovangy committed May 31, 2024
1 parent f959c9b commit 4b799f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/pkg/adverts/delivery/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ func (h *AdvertsServerHandler) UpdateAdvertById(ctx context.Context, reqAdv *gen
Cottage: reqAdv.HouseProp.Cottage, StatusHome: statusHome, Floor: int(reqAdv.HouseProp.Floor)}
}

if reqAdv.FlatProperties != nil {
flatPropert = &models.FlatProperties{CeilingHeight: reqAdv.HouseProp.CeilingHeight,
FloorGeneral: int(reqAdv.FlatProperties.FloorGeneral), RoomCount: int(reqAdv.FlatProperties.RoomCount),
SquareResidential: reqAdv.FlatProperties.SquareResidential, SquareGeneral: reqAdv.FlatProperties.SquareGeneral,
Apartment: reqAdv.FlatProperties.Apartment, Floor: int(reqAdv.HouseProp.Floor)}
}

updData := &models.AdvertUpdateData{
ID: reqAdv.Id,
TypeAdvert: reqAdv.AdvertType,
Expand Down Expand Up @@ -409,6 +416,10 @@ func (h *AdvertsServerHandler) GetExistBuildingByAddress(ctx context.Context, re
return &genAdverts.GetExistBuildingByAddressResponse{RespCode: StatusBadRequest}, err
}

if gotBuilding == nil {
return &genAdverts.GetExistBuildingByAddressResponse{RespCode: StatusOk}, nil
}

var mater genAdverts.MaterialBuilding
switch gotBuilding.Material {
case models.MaterialBrick:
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/adverts/delivery/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ func (h *AdvertsClientHandler) GetRectangleAdvertsList(w http.ResponseWriter, r
Phone: adv.Phone,
TypeSale: adv.TypeSale,
Address: adv.Address,
AddressPoint: adv.AddressPoint,
IsLiked: adv.IsLiked,
Price: int(adv.Price),
DateCreation: tCr,
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/adverts/repo/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ func (r *AdvertRepo) UpdateFlatAdvertById(ctx context.Context, tx models.Transac
r.metricsC.AddDurationToQueryTimings("UpdateFlatAdvertById", "update advert", dur)

start = time.Now()

if _, err := tx.Exec(queryUpdateBuildingById, advertUpdateData.FlatProperties.FloorGeneral, advertUpdateData.Material, id, advertUpdateData.YearCreation, buildingId); err != nil {
dur = time.Since(start)
r.metricsC.AddDurationToQueryTimings("UpdateFlatAdvertById", "update building", dur)
Expand Down

0 comments on commit 4b799f1

Please sign in to comment.