Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvpm committed Mar 31, 2024
1 parent 175ff55 commit 9312297
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import sttp.tapir.model.UsernamePassword
import sttp.tapir.server.ServerEndpoint

class AuthHandler[F[_]: Monad](override val authService: AuthService[F], userService: UserService[F])
extends Handler[F]
extends Handler[F]
with AuthBasicSupport[F]
with ApiErrorSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import sttp.tapir.json.circe._
import sttp.tapir.server.ServerEndpoint

class OfferHandler[F[_]: Applicative](offerService: OfferService[F], override val authService: AuthService[F])
extends Handler[F]
extends Handler[F]
with AuthSessionSupport[F]
with ApiErrorSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import sttp.tapir.json.circe._
import sttp.tapir.server.ServerEndpoint

class UserHandler[F[_]: Functor](userService: UserService[F], override val authService: AuthService[F])
extends Handler[F]
extends Handler[F]
with AuthSessionSupport[F]
with ApiErrorSupport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,15 @@ class OfferDaoPostgresql[F[_]: MonadCancelThrow](implicit val tr: Transactor[F])
private def insertIntoOffers(offer: Offer): ConnectionIO[Boolean] = {
import offer._
import description._
sql"insert into offers values ($id, $name, $price, $text, $status)"
.update.run.map(_ == 1)
sql"insert into offers values ($id, $name, $price, $text, $status)".update.run.map(_ == 1)
}

private def insertIntoUserOffers(offer: Offer): ConnectionIO[Boolean] =
sql"insert into user_offers values (${offer.id}, ${offer.userId})"
.update.run.map(_ == 1)
sql"insert into user_offers values (${offer.id}, ${offer.userId})".update.run.map(_ == 1)

private def updateOffers(userId: UserID, offerId: OfferID, patch: OfferPatch): ConnectionIO[Boolean] =
(fr"update offers set" ++ sqlByPatch(patch) ++
fr"from user_offers uo where id = $offerId and uo.user_id = $userId")
.update.run.map(_ == 1)
fr"from user_offers uo where id = $offerId and uo.user_id = $userId").update.run.map(_ == 1)

// internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class UserDaoPostgresql[F[_]: MonadCancelThrow](implicit val tr: Transactor[F])
.attemptT
.leftMap {
case DuplicateKeyException(_) => UserAlreadyExistsDaoError(user.user.login)
case error => InternalUserDaoError(error.getMessage)
case error => InternalUserDaoError(error.getMessage)
}
.flatMap {
res => EitherT.cond(res, (), InternalUserDaoError(s"$res rows was inserted"))
.flatMap { res =>
EitherT.cond(res, (), InternalUserDaoError("no rows was inserted"))
}

override def updateUser(userId: UserID, patch: UserPatch): EitherT[F, UserDaoError, Unit] =
Expand Down Expand Up @@ -95,8 +95,7 @@ class UserDaoPostgresql[F[_]: MonadCancelThrow](implicit val tr: Transactor[F])
}

private def updateOffersEntryRaw(userId: UserID, patch: UserPatch): ConnectionIO[Boolean] =
(fr"update users set " ++ sqlByPatch(patch) ++ fr" where id = $userId")
.update.run.map(_ == 1)
(fr"update users set " ++ sqlByPatch(patch) ++ fr" where id = $userId").update.run.map(_ == 1)

// internal

Expand Down

0 comments on commit 9312297

Please sign in to comment.