involveMINT / iMPublic

Public involveMINT repo
https://app.involvemint.io
7 stars 20 forks source link

The Budget Rollover function takes more than 2 days #187

Open QuinnNTonic opened 4 months ago

QuinnNTonic commented 4 months ago

Repro Steps

It was discovered that it took about 3 days after the expected date for a budget rollover to display that it in fact had reset.

Also many of the budgets display an expiration date that has already passed.

QuinnNTonic commented 4 months ago

Original Work Item URL

Original Work Item Details

| Created date | Created by | Changed date | Changed By | Assigned To | State | Type | Area Path | Iteration Path| |---|---|---|---|---|---|---|---|---| | 05/12/2022 06:36:12 | Ryan McAndrew | 11/14/2022 23:59:39 | info | | New | Bug | involveMINT\involveMINT | involveMINT\72 |

Original Work Item JSON

```json { "fields": { "Microsoft.VSTS.Common.Priority": 2, "Microsoft.VSTS.Common.StackRank": 998341990, "Microsoft.VSTS.Common.StateChangeDate": "05/12/2022 06:36:12", "System.AssignedTo": { "displayName": "" }, "System.BoardColumn": "New", "System.BoardColumnDone": False, "System.ChangedBy": { "displayName": "info" }, "System.ChangedDate": "11/14/2022 23:59:39", "System.CommentCount": 1, "System.CreatedBy": { "displayName": "Ryan McAndrew" }, "System.CreatedDate": "05/12/2022 06:36:12", "System.Id": 534, "System.Reason": "New", "System.Rev": 9, "System.RevisedDate": "01/01/9999 00:00:00", "System.State": "New", "System.TeamProject": "involveMINT", "System.Title": "The Budget Rollover function takes more than 2 days", "System.WorkItemType": "Bug", "WEF_F54671B39AF54036B4485F04394D6594_Kanban.Column": "New", "WEF_F54671B39AF54036B4485F04394D6594_Kanban.Column.Done": False, "WEF_F54671B39AF54036B4485F04394D6594_System.ExtensionMarker": True }, "id": 534, "relations": [ { "attributes": { "id": , "name": "Parent", "resourceCreatedDate": "", "resourceModifiedDate": "", "resourceSize": , "revisedDate": "" }, "rel": "System.LinkTypes.Hierarchy-Reverse", "url": "https://dev.azure.com/involvemint/1853e4bf-a341-4c37-98f5-57387729b589/_apis/wit/workItems/533" }, ], "rev": 9, "url": "https://dev.azure.com/involvemint/1853e4bf-a341-4c37-98f5-57387729b589/_apis/wit/workItems/534" } ```

Work Item Comments (1)

| Created date | Created by | JSON URL | |---|---|---| | 05/12/2022 06:36:12 | Ryan McAndrew | [URL](https://dev.azure.com/involvemint/1853e4bf-a341-4c37-98f5-57387729b589/_apis/wit/workItems/534/comments/1068937) | **Comment text**:

There is a function in libs/server/core/application-services/src/lib/exchange-partner/exchange-partner.cron.ts

async void updateSpMonthlyBudgets()

It is described as a cron job and is configured to run this function everyday at midnight.

The function is a cron job that performs:
  1.  a query to get the Budgets with an End Date that is less than today() (expressed as new Date())
  2. iterates over the data returned from the query if and only if there were end dates less than today that got into the array from the query in the first place  
    1. pushes new data onto a temporary array housing updated budgetEndDates set to the following month
    2. pushing the new data onto temporary array that has updated the budgetEndDate field 
  3. uploads the data in the temporary array we manipulated to adjust the new budget end date 
From this observation, the budget will only reset the day after the budget end date which makes sense. It is possible that the server the cron job is living on is having performance issues. To look for more information in this area.

-----------