Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make manage workflow 'to setup' links intelligent (#2549)
https://eaflood.atlassian.net/browse/WATER-4437 For context, we found out legacy background jobs scheduled in BullMQ only run intermittently. One we found hadn't run for the last 2 years so agreed to bin. Two we need to deal with at some point but intermittent is fine for now. The critical job, which is putting updated licences into workflow, we solved by migrating to [water-abstraction-system](DEFRA/water-abstraction-system#903). As part of solving it we took the opportunity to add data to the workflow record to allow us to identify that the record was added because of an updated licence. We also spotted that our time-limited job was broken 😱 so [fixed that](DEFRA/water-abstraction-system#908) and updated it to _also_ add some info to the workflow record. With these handy bits of info now in the workflow record, it seems a shame we don't make the reason why the record was added visible to the user. So, this change amends the link in the 'To setup' based on that extra info. In the pre-handler that fetches the to-setup workflow records we now iterate through the results and add the link details to use in the view. If it spots the `timeLimitedChargeVersionId` property we add to the data field it will generate a link that will take the user directly to the charge version with the time-limited element. Else if the `chargeVersionExists` property is present we know the record was added by the licence updates job. If the property is true we direct the user to the charge information tab for the licence rather than drop them into a new one. That way they can see the existing ones and determine if a new one is needed. Else if `chargeVersionExists` property is missing or false we leave the link as it was and direct the user to create a new charge version.
- Loading branch information