mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-22 18:30:09 +00:00
Refactored plannedAt implementation as per feedback
This commit is contained in:
parent
3fc4cfbcdd
commit
f56b5c584a
4 changed files with 22 additions and 22 deletions
BIN
.swp
Normal file
BIN
.swp
Normal file
Binary file not shown.
|
|
@ -85,32 +85,32 @@ export type IssueData =
|
|||
| RedmineIssue;
|
||||
|
||||
export type IssueDataReduced =
|
||||
| (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 });
|
||||
| GithubIssueReduced
|
||||
| JiraIssueReduced
|
||||
| GitlabIssue
|
||||
| OpenProjectWorkPackageReduced
|
||||
| CaldavIssueReduced
|
||||
| ICalIssueReduced
|
||||
| GiteaIssue
|
||||
| RedmineIssue;
|
||||
|
||||
export type IssueDataReducedMap = {
|
||||
[K in IssueProviderKey]: K extends 'JIRA'
|
||||
? JiraIssueReduced & { plannedAt?: string | null }
|
||||
? JiraIssueReduced
|
||||
: K extends 'GITHUB'
|
||||
? GithubIssueReduced & { plannedAt?: string | null }
|
||||
? GithubIssueReduced
|
||||
: K extends 'GITLAB'
|
||||
? GitlabIssue & { plannedAt?: string | null }
|
||||
? GitlabIssue
|
||||
: K extends 'CALDAV'
|
||||
? CaldavIssueReduced & { plannedAt?: string | null }
|
||||
? CaldavIssueReduced
|
||||
: K extends 'ICAL'
|
||||
? ICalIssueReduced & { plannedAt?: string | null }
|
||||
? ICalIssueReduced
|
||||
: K extends 'OPEN_PROJECT'
|
||||
? OpenProjectWorkPackageReduced & { plannedAt?: string | null }
|
||||
? OpenProjectWorkPackageReduced
|
||||
: K extends 'GITEA'
|
||||
? GiteaIssue & { plannedAt?: string | null }
|
||||
? GiteaIssue
|
||||
: K extends 'REDMINE'
|
||||
? RedmineIssue & { plannedAt?: string | null }
|
||||
? RedmineIssue
|
||||
: never;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -454,18 +454,12 @@ 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()),
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ export class OpenProjectCommonInterfacesService implements IssueServiceInterface
|
|||
});
|
||||
}
|
||||
|
||||
readonly oneDayInMilliseconds = 24 * 60 * 60 * 1000;
|
||||
|
||||
getAddTaskData(
|
||||
issue: OpenProjectWorkPackageReduced,
|
||||
): Partial<Task> & { title: string } {
|
||||
|
|
@ -144,6 +146,10 @@ export class OpenProjectCommonInterfacesService implements IssueServiceInterface
|
|||
issuePoints: issue.storyPoints,
|
||||
issueWasUpdated: false,
|
||||
// NOTE: we use Date.now() instead to because updated does not account for comments
|
||||
plannedAt: issue.plannedAt
|
||||
? new Date(new Date(issue.plannedAt).setHours(7, 30, 0, 0)).getTime() +
|
||||
this.oneDayInMilliseconds
|
||||
: null, // Adjust plannedAt to 7 AM or set it to null if not present
|
||||
issueLastUpdated: new Date(issue.updatedAt).getTime(),
|
||||
...(parsedEstimate > 0 ? { timeEstimate: parsedEstimate } : {}),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue