Fix operator precedence for plannedAt calculation

This commit is contained in:
Simran Gill 2025-01-06 19:38:42 -08:00 committed by Johannes Millan
parent d71bc0988f
commit 3fc4cfbcdd
4 changed files with 24 additions and 16 deletions

View file

@ -85,32 +85,32 @@ export type IssueData =
| RedmineIssue;
export type IssueDataReduced =
| GithubIssueReduced
| JiraIssueReduced
| GitlabIssue
| OpenProjectWorkPackageReduced
| CaldavIssueReduced
| ICalIssueReduced
| GiteaIssue
| RedmineIssue;
| (GithubIssueReduced & { plannedAt?: string | null })
| (JiraIssueReduced & { plannedAt?: string | null })
| (GitlabIssue & { plannedAt?: string | null })
| (OpenProjectWorkPackageReduced & { plannedAt?: string | null })
| (CaldavIssueReduced & { plannedAt?: string | null })
| (ICalIssueReduced & { plannedAt?: string | null })
| (GiteaIssue & { plannedAt?: string | null })
| (RedmineIssue & { plannedAt?: string | null });
export type IssueDataReducedMap = {
[K in IssueProviderKey]: K extends 'JIRA'
? JiraIssueReduced
? JiraIssueReduced & { plannedAt?: string | null }
: K extends 'GITHUB'
? GithubIssueReduced
? GithubIssueReduced & { plannedAt?: string | null }
: K extends 'GITLAB'
? GitlabIssue
? GitlabIssue & { plannedAt?: string | null }
: K extends 'CALDAV'
? CaldavIssueReduced
? CaldavIssueReduced & { plannedAt?: string | null }
: K extends 'ICAL'
? ICalIssueReduced
? ICalIssueReduced & { plannedAt?: string | null }
: K extends 'OPEN_PROJECT'
? OpenProjectWorkPackageReduced
? OpenProjectWorkPackageReduced & { plannedAt?: string | null }
: K extends 'GITEA'
? GiteaIssue
? GiteaIssue & { plannedAt?: string | null }
: K extends 'REDMINE'
? RedmineIssue
? RedmineIssue & { plannedAt?: string | null }
: never;
};

View file

@ -454,12 +454,18 @@ export class IssueService {
}
};
const oneDayInMilliseconds = 24 * 60 * 60 * 1000;
const taskData = {
issueType: issueProviderKey,
issueProviderId: issueProviderId,
issueId: issueDataReduced.id.toString(),
issueWasUpdated: false,
issueLastUpdated: Date.now(),
plannedAt: issueDataReduced.plannedAt
? new Date(new Date(issueDataReduced.plannedAt).setHours(6, 0, 0, 0)).getTime() +
oneDayInMilliseconds
: null, // Adjust plannedAt to 6 AM or set it to null if not present
...additionalFromProviderIssueService,
// NOTE: if we were to add tags, this could be overwritten here
...(await getProjectOrTagId()),

View file

@ -16,6 +16,7 @@ export const mapOpenProjectIssueReduced = (
): OpenProjectWorkPackageReduced => {
return {
...issue,
plannedAt: issue.startDate,
url: `${cfg.host}/projects/${cfg.projectId}/work_packages/${issue.id}`,
};
};

View file

@ -7,6 +7,7 @@ export type OpenProjectWorkPackageReduced = OpenProjectOriginalWorkPackageReduce
Readonly<{
// added
// transformed
plannedAt: string | null;
url: string;
// removed
}>;