Skip to content

[APB-11703] Add logging for number of approved, but not subscribed applications - #131

Open
mrolfe88 wants to merge 3 commits into
mainfrom
APB-11703
Open

mrolfe88 wants to merge 3 commits into
mainfrom
APB-11703

Conversation

@mrolfe88

Copy link
Copy Markdown
Contributor

No description provided.

@platops-pr-bot

Copy link
Copy Markdown

)
).toFuture()

def findApprovedNotSubscribed(): Future[Seq[ApplicationForRisking]] = collection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be exactly what def findReadyToBeSubscribed function is already doing (the implementations seem to be exactly the same).

After closer look it also seems that we're also already logging number of applications to to approve, just with different wording.

Perhaps updating the wording of the existing log statement would be sufficient? Or explaining to the team what to look for in kibana?

Please see:

def processSubscriptions()(using RequestHeader): Future[Unit] =
    logger.info("Subscribing approved applications...")
    for
      applications: Seq[ApplicationForRisking] <- applicationForRiskingRepo.findReadyToBeSubscribed()
      applicationCount: Int = applications.size
      _ = logger.info(s"Found $applicationCount applications ready to subscribe") <<<<< HERE LOGGING
      subscriptionSuccessCount <-
        ProcessInSequence.processAllInSequence(applications)(subscribeApplication):
          case (ex, application) => logger.error(s"Failed to subscribe agent: ${application.applicationData.applicationReference.value}", ex)
      _ = logger.info(s"Subscribed $subscriptionSuccessCount/$applicationCount applications")
    yield ()
def findReadyToBeSubscribed(): Future[Seq[ApplicationForRisking]] = collection
    .find(
      Filters.and(
        Filters.eq(FieldNames.overallStatus.riskingOutcome, RiskingOutcome.Approved.toBison),
        Filters.eq(FieldNames.isSubscribed, false)
      )
    )
    .toFuture(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot! Not sure how I missed that... Yeah I think this may be covered already then, let me have a look on Kibana and see if we can get the numbers we need.

extends Logging:
def logApprovedNotSubscribedApplicationCount(): Future[Unit] = {
applicationForRiskingRepo.findApprovedNotSubscribed().map(applicationCount =>
logger.info(s"Found $applicationCount approved applications that are not subscribed")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will most likely always be 0, because subscriptions are processed immediately as part of the risking results processing flow.

By the time this code runs, any approved applications that are ready to be subscribed should already have been picked up and processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants