def since()

in membership-common/src/main/scala/com/gu/memsub/subsv2/services/SubscriptionService.scala [109:124]


  def since(onOrAfter: LocalDate)(contact: ContactId)(implicit logPrefix: LogPrefix): M[List[Subscription]] =
    for {
      subscriptionsEither <- getSubscriptionsFromContact(contact)
    } yield {
      val subscriptionsStillInTerm = for {
        subscriptions <- subscriptionsEither.withLogging("sub service - get for contact")
      } yield subscriptions.filter { sub =>
        !sub.termEndDate.isBefore(onOrAfter)
      }
      subscriptionsStillInTerm.toEither match {
        case Left(error) =>
          logger.warn(s"Error from sub service for contact $contact: $error")
          List.empty // returns an empty list if there's an error
        case Right(nel) => nel
      }
    }