From 61371282b1a0e99a477bcc303d0afcaef8c52cf6 Mon Sep 17 00:00:00 2001 From: Pavel Gnedov Date: Wed, 23 Aug 2023 02:02:52 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=B0=D1=80=D1=81=D0=B5=D1=80=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D0=BD=D1=8B=D1=85=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + configs/calendar-enhancer.jsonc.dist | 17 ++ configs/interview-projects.jsonc | 6 - configs/interview-projects.jsonc.dist | 4 - .../event-emitter/src/event-emitter.module.ts | 19 ++ .../src/issue-enhancers/calendar-enhancer.ts | 164 ++++++++++++++++++ .../src/models/calendar-event.ts | 8 + .../src/utils/string-with-dates-parser.ts | 138 +++++++++++++++ package-lock.json | 24 +++ package.json | 2 + src/app.module.ts | 5 + src/configs/app.ts | 3 + src/configs/calendar-enhancer.config.ts | 23 +++ src/issue-enhancers/interview-enhancer.ts | 59 ------- src/models/app-config.model.ts | 2 +- 15 files changed, 405 insertions(+), 70 deletions(-) create mode 100644 configs/calendar-enhancer.jsonc.dist delete mode 100644 configs/interview-projects.jsonc delete mode 100644 configs/interview-projects.jsonc.dist create mode 100644 libs/event-emitter/src/issue-enhancers/calendar-enhancer.ts create mode 100644 libs/event-emitter/src/models/calendar-event.ts create mode 100644 libs/event-emitter/src/utils/string-with-dates-parser.ts create mode 100644 src/configs/calendar-enhancer.config.ts delete mode 100644 src/issue-enhancers/interview-enhancer.ts diff --git a/.gitignore b/.gitignore index 43607ab..d0f42bc 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ configs/eccm-config.jsonc configs/current-user-rules.jsonc configs/simple-kanban-board-config.jsonc configs/kanban-boards/ +configs/calendar-enhancer.jsonc diff --git a/configs/calendar-enhancer.jsonc.dist b/configs/calendar-enhancer.jsonc.dist new file mode 100644 index 0000000..72f9c8c --- /dev/null +++ b/configs/calendar-enhancer.jsonc.dist @@ -0,0 +1,17 @@ +{ + "useForProjects": [ + "*" // '*' - все, или перечислить отдельные проекты + ], + "customFields": [ + { + "dateFormat": "yyyy-MM-dd HH:mm", + "customFieldName": "Custom field name", + "alias": "" + } + ], + "descriptionCalendarParams": { + "title": "Calendar:", + "lineRegexp": "(?<=\\*\\ ).+" + }, + "calendarEventsKey": "calendar" +} diff --git a/configs/interview-projects.jsonc b/configs/interview-projects.jsonc deleted file mode 100644 index 2b2925b..0000000 --- a/configs/interview-projects.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "interviewProjects": [ - "Программисты, инженеры HW" - ], - "customFieldDateFormat": "yyyy-MM-dd HH:mm" -} \ No newline at end of file diff --git a/configs/interview-projects.jsonc.dist b/configs/interview-projects.jsonc.dist deleted file mode 100644 index 9f49eb9..0000000 --- a/configs/interview-projects.jsonc.dist +++ /dev/null @@ -1,4 +0,0 @@ -{ - "interviewProjects": [], - "customFieldDateFormat": "yyyy-MM-dd HH:mm" -} \ No newline at end of file diff --git a/libs/event-emitter/src/event-emitter.module.ts b/libs/event-emitter/src/event-emitter.module.ts index 679e6a3..d24ab6a 100644 --- a/libs/event-emitter/src/event-emitter.module.ts +++ b/libs/event-emitter/src/event-emitter.module.ts @@ -28,6 +28,7 @@ import { ListIssuesByUsersLikeJiraWidgetService } from './project-dashboard/widg import { TimePassedHighlightEnhancer } from './issue-enhancers/time-passed-highlight-enhancer'; import { ListIssuesByFieldsWidgetService } from './project-dashboard/widgets/list-issues-by-fields.widget.service'; import { IssuesUpdaterService } from './issues-updater/issues-updater.service'; +import { CalendarEnhancer } from './issue-enhancers/calendar-enhancer'; @Module({}) export class EventEmitterModule implements OnModuleInit { @@ -68,6 +69,20 @@ export class EventEmitterModule implements OnModuleInit { }, inject: [ConfigService], }, + { + provide: 'CALENDAR_ENHANCER', + useFactory: (configService: ConfigService) => { + const calendarEnhancerConfig = + configService.get>('calendarEnhancer'); + return new CalendarEnhancer( + calendarEnhancerConfig.useForProjects, + calendarEnhancerConfig.customFields, + calendarEnhancerConfig.descriptionCalendarParams, + calendarEnhancerConfig.calendarEventsKey, + ); + }, + inject: [ConfigService], + }, ], exports: [ EventEmitterService, @@ -95,6 +110,10 @@ export class EventEmitterModule implements OnModuleInit { provide: 'ISSUES_UPDATER_SERVICE', useExisting: 'ISSUES_UPDATER_SERVICE', }, + { + provide: 'CALENDAR_ENHANCER', + useExisting: 'CALENDAR_ENHANCER', + }, ], controllers: [MainController, UsersController, IssuesController], }; diff --git a/libs/event-emitter/src/issue-enhancers/calendar-enhancer.ts b/libs/event-emitter/src/issue-enhancers/calendar-enhancer.ts new file mode 100644 index 0000000..5bc8c55 --- /dev/null +++ b/libs/event-emitter/src/issue-enhancers/calendar-enhancer.ts @@ -0,0 +1,164 @@ +import { IssueEnhancerInterface } from '@app/event-emitter/issue-enhancers/issue-enhancer-interface'; +import { RedmineTypes } from '@app/event-emitter/models/redmine-types'; +import { Injectable } from '@nestjs/common'; +import * as Luxon from 'luxon'; +import { CalendarEvent } from '../models/calendar-event'; +import * as DatesParser from '../utils/string-with-dates-parser'; + +export type DescriptionParserParams = { + title: string; + lineRegexp: string; +}; + +export type CustomFieldParserParams = { + dateFormat: string; + customFieldName: string; + /** Время в минутах */ + interval?: number; + fullDay?: boolean; + alias?: string; +}; + +export const UNKNOWN_CALENDAR_EVENT = 'Unknown calendar event'; + +@Injectable() +export class CalendarEnhancer implements IssueEnhancerInterface { + name = 'calendar'; + + constructor( + public useForProjects: string[], + public customFields: CustomFieldParserParams[], + public descriptionCalendarParams: DescriptionParserParams, + public calendarEventsKey: string, + ) {} + + async enhance( + issue: RedmineTypes.ExtendedIssue, + ): Promise { + const res: RedmineTypes.ExtendedIssue = { ...issue }; + + if (!this.checkProject(issue)) return res; + + issue[this.calendarEventsKey] = this.getCalendarEvents(issue); + + return res; + } + + private checkProject(issue: RedmineTypes.ExtendedIssue): boolean { + if (this.useForProjects.indexOf('*') >= 0) { + return true; + } + if ( + this.useForProjects.length > 0 && + this.useForProjects.indexOf(issue.project.name) >= 0 + ) { + return true; + } + return false; + } + + private getCalendarEvents( + issue: RedmineTypes.ExtendedIssue, + ): CalendarEvent[] { + return [ + ...this.getCalendarEventsFromCustomFields(issue), + ...this.getCalendarEventsFromSubject(issue), + ...this.getCalendarEventsFromDescription(issue), + ]; + } + + private getCalendarEventsFromCustomFields( + issue: RedmineTypes.ExtendedIssue, + ): CalendarEvent[] { + const res: CalendarEvent[] = []; + for (let i = 0; i < this.customFields.length; i++) { + const cfParam = this.customFields[i]; + const event = this.getCalendarEventFromCustomField(issue, cfParam); + if (event) res.push(event); + } + return res; + } + + private getCalendarEventFromCustomField( + issue: RedmineTypes.ExtendedIssue, + params: CustomFieldParserParams, + ): CalendarEvent | null { + if (typeof params.interval !== 'number' && params.fullDay !== true) + return null; + + const cf = issue.custom_fields.find((issueCf) => { + return issueCf.name === params.customFieldName; + }); + if (!cf) return null; + + const from = Luxon.DateTime.fromFormat(cf.value, params.dateFormat); + if (!from.isValid) return null; + + let to: Luxon.DateTime; + if (typeof params.interval === 'number') { + const interval = Luxon.Duration.fromObject({ minutes: params.interval }); + to = from.plus(interval); + } else if (params.fullDay) { + from.set({ hour: 0, minute: 0, second: 0, millisecond: 0 }); + to = from.plus(Luxon.Duration.fromObject({ day: 1 })); + } else { + return null; + } + if (!to.isValid) return null; + + return { + from: from.toISO(), + fromTimestamp: from.toSeconds(), + to: to.toISO(), + toTimestamp: to.toSeconds(), + fullDay: Boolean(params.fullDay), + description: params.alias || cf.name || UNKNOWN_CALENDAR_EVENT, + }; + } + + private getCalendarEventsFromSubject( + issue: RedmineTypes.ExtendedIssue, + ): CalendarEvent[] { + const matches = issue.subject.matchAll(/(?<=\()[^()]*(?=\))/g); + const items = [...matches].map((i) => i[0]).filter((i) => !!i); + + return items + .map((item) => DatesParser.parseToCalendarEvent(item)) + .filter((i) => !!i); + } + + private getCalendarEventsFromDescription( + issue: RedmineTypes.ExtendedIssue, + ): CalendarEvent[] { + const text = issue.description; + + const lines = text.split('\n').map((line) => line.trim()); + + const calendarStartIndex = lines.indexOf('Календарь:'); + if (calendarStartIndex < 0) return []; + + let index = calendarStartIndex + 1; + let line = this.extractFromList(lines[index]); + if (!line) { + index++; + line = this.extractFromList(lines[index]); + } + if (!line) return []; + + const res: string[] = []; + + do { + res.push(line); + index++; + line = this.extractFromList(lines[index]); + } while (line); + + return res.map((line) => DatesParser.parseToCalendarEvent(line)); + } + + private extractFromList(line: string): string | null { + const regexp = new RegExp(this.descriptionCalendarParams.lineRegexp); + const match = line.match(regexp); + return match && match[0] ? match[0] : null; + } +} diff --git a/libs/event-emitter/src/models/calendar-event.ts b/libs/event-emitter/src/models/calendar-event.ts new file mode 100644 index 0000000..3b5e180 --- /dev/null +++ b/libs/event-emitter/src/models/calendar-event.ts @@ -0,0 +1,8 @@ +export type CalendarEvent = { + from: string; + fromTimestamp: number; + to: string; + toTimestamp: number; + fullDay: boolean; + description: string; +}; diff --git a/libs/event-emitter/src/utils/string-with-dates-parser.ts b/libs/event-emitter/src/utils/string-with-dates-parser.ts new file mode 100644 index 0000000..cbfe4c8 --- /dev/null +++ b/libs/event-emitter/src/utils/string-with-dates-parser.ts @@ -0,0 +1,138 @@ +import Moo from 'moo'; +import { CalendarEvent } from '../models/calendar-event'; +import Luxon from 'luxon'; + +export const DEFAULT_PARAMS: Moo.Rules = { + WS: /[ \t]+/, + delimiter: /(?: - |: )/, + delimiter2: /(?:^\* |^- |(?!\d)T(?!>\d))/, + date: /(?:(?:\d{2}\.\d{2}\.(?:\d{2}|\d{4}))|(?:\d{4}-\d{2}-\d{2}))/, + time: /(?:\d{2}\b:\d{2}:\d{2}|\d{2}:\d{2})/, + word: /[\wА-Яа-я]+/, + other: { match: /./, lineBreaks: true }, + NL: { match: /\n/, lineBreaks: true }, +}; + +export const DEFAULT_DATE_FORMATS = ['dd.MM.yy', 'dd.MM.yyyy', 'yyyy-MM-dd']; + +export const DEFAULT_TIME_FORMATS = ['HH:mm', 'HH:mm:ss']; + +export const DEFAULT_EVENT_DURATION = 60 * 60 * 1000; // 1 hour in millis + +export function parse(str: string, params?: Moo.Rules): Moo.Token[] { + if (!params) params = DEFAULT_PARAMS; + try { + const lexer = Moo.compile(params); + lexer.reset(str); + const res: Moo.Token[] = []; + let token = lexer.next(); + while (token) { + res.push(token); + token = lexer.next(); + } + return res; + } catch (ex) { + return []; + } +} + +export type ParserOpts = { + rules?: Moo.Rules; + dateFormats?: string[]; + timeFormats?: string[]; +}; + +export function parseDate( + str: string, + formats?: string[], +): Luxon.DateTime | null { + if (!formats) formats = DEFAULT_DATE_FORMATS; + let res: Luxon.DateTime; + for (let i = 0; i < formats.length; i++) { + const format = formats[i]; + res = Luxon.DateTime.fromFormat(str, format); + if (res.isValid) return res; + } + return null; +} + +export function parseTime( + str: string, + formats?: string[], +): Luxon.Duration | null { + if (!formats) formats = DEFAULT_TIME_FORMATS; + let res: Luxon.DateTime; + for (let i = 0; i < formats.length; i++) { + const format = formats[i]; + res = Luxon.DateTime.fromFormat(str, format); + if (res.isValid) { + const startOfDay = res.set({ + hour: 0, + minute: 0, + second: 0, + millisecond: 0, + }); + return res.diff(startOfDay).shiftToAll(); + } + } + return null; +} + +export function parseToCalendarEvent( + str: string, + opts?: ParserOpts, +): CalendarEvent | null { + const tokens = parse(str, opts?.rules); + + const words = tokens.filter((i) => i.type === 'word'); + + const dates = tokens.filter((i) => i.type === 'date'); + if (dates.length < 0) return null; + const date1 = parseDate(dates[0]?.value, opts?.dateFormats); + const date2 = parseDate(dates[1]?.value, opts?.dateFormats); + + const times = tokens.filter((i) => i.type === 'time'); + const time1 = parseTime(times[0]?.value, opts?.timeFormats); + const time2 = parseTime(times[1]?.value, opts?.timeFormats); + + let from: Luxon.DateTime; + let to: Luxon.DateTime; + let fullDay: boolean; + + if (date1 && time1) { + from = date1.set({ + hour: time1.hours, + minute: time1.minutes, + second: time1.seconds, + }); + fullDay = false; + } else if (date1) { + from = date1; + fullDay = true; + } else { + return null; + } + + if (date2 && time2) { + to = date2.set({ + hour: time2.hours, + minute: time2.minutes, + second: time2.seconds, + }); + } else if (date2) { + to = date2.plus({ day: 1 }); + } else if (fullDay) { + to = from.plus({ day: 1 }); + } else { + to = from.plus(Luxon.Duration.fromMillis(DEFAULT_EVENT_DURATION)); + } + + return { + from: from.toISO(), + fromTimestamp: from.toMillis(), + to: to.toISO(), + toTimestamp: to.toMillis(), + description: words.join(' '), + fullDay: fullDay, + }; +} diff --git a/package-lock.json b/package-lock.json index 1c17d5d..4e33da7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "imap-simple": "^5.1.0", "jsonc-parser": "^3.2.0", "luxon": "^3.1.0", + "moo": "^0.5.2", "nano": "^10.0.0", "node-telegram-bot-api": "^0.59.0", "reflect-metadata": "^0.1.13", @@ -41,6 +42,7 @@ "@types/express": "^4.17.13", "@types/jest": "27.4.0", "@types/luxon": "^3.1.0", + "@types/moo": "^0.5.6", "@types/node": "^16.0.0", "@types/node-telegram-bot-api": "^0.57.1", "@types/supertest": "^2.0.11", @@ -2141,6 +2143,12 @@ "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==", "dev": true }, + "node_modules/@types/moo": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@types/moo/-/moo-0.5.6.tgz", + "integrity": "sha512-Q60hZhulhl2Ox4LjbJvhH+HzsKrwzLPjEB8dZw0fK1MH2HyOLe6LDou68yTfsWasxGv7DPZe5VNM5vgpzOa2nw==", + "dev": true + }, "node_modules/@types/node": { "version": "16.11.49", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.49.tgz", @@ -7452,6 +7460,11 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moo": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", + "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==" + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -12014,6 +12027,12 @@ "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==", "dev": true }, + "@types/moo": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@types/moo/-/moo-0.5.6.tgz", + "integrity": "sha512-Q60hZhulhl2Ox4LjbJvhH+HzsKrwzLPjEB8dZw0fK1MH2HyOLe6LDou68yTfsWasxGv7DPZe5VNM5vgpzOa2nw==", + "dev": true + }, "@types/node": { "version": "16.11.49", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.49.tgz", @@ -16024,6 +16043,11 @@ "minimist": "^1.2.6" } }, + "moo": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", + "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==" + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index a871bf2..ad4a2a9 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "imap-simple": "^5.1.0", "jsonc-parser": "^3.2.0", "luxon": "^3.1.0", + "moo": "^0.5.2", "nano": "^10.0.0", "node-telegram-bot-api": "^0.59.0", "reflect-metadata": "^0.1.13", @@ -53,6 +54,7 @@ "@types/express": "^4.17.13", "@types/jest": "27.4.0", "@types/luxon": "^3.1.0", + "@types/moo": "^0.5.6", "@types/node": "^16.0.0", "@types/node-telegram-bot-api": "^0.57.1", "@types/supertest": "^2.0.11", diff --git a/src/app.module.ts b/src/app.module.ts index 686bb56..2afa718 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -50,6 +50,7 @@ import { join } from 'path'; import { SimpleIssuesListController } from './dashboards/simple-issues-list.controller'; import { TagsManagerController } from './tags-manager/tags-manager.controller'; import { CreateTagManagerServiceProvider } from './tags-manager/tags-manager.service'; +import { CalendarEnhancer } from '@app/event-emitter/issue-enhancers/calendar-enhancer'; @Module({ imports: [ @@ -132,6 +133,9 @@ export class AppModule implements OnModuleInit { @Inject('CATEGORY_MERGE_TO_TAGS_ENHANCER') private categoryMergeToTagsEnhancer: CategoryMergeToTagsEnhancer, + + @Inject('CALENDAR_ENHANCER') + private calendarEnhancer: CalendarEnhancer, ) {} onModuleInit() { @@ -148,6 +152,7 @@ export class AppModule implements OnModuleInit { this.currentUserEnhancer, this.issueUrlEnhancer, this.categoryMergeToTagsEnhancer, + this.calendarEnhancer, ]); this.personalNotificationsService.$messages.subscribe((resp) => { diff --git a/src/configs/app.ts b/src/configs/app.ts index 89c3e6c..92146ba 100644 --- a/src/configs/app.ts +++ b/src/configs/app.ts @@ -8,6 +8,7 @@ import RedmineStatusChangesConfigLoader from './status-changes.config'; import RedmineEccmConfig from './eccm.config'; import RedmineCurrentUserRulesConfig from './current-user-rules.config'; import SimpleKanbanBoardConfig from './simple-kanban-board.config'; +import CalendarEnhancer from './calendar-enhancer.config'; const redmineIssueEventEmitterConfig = RedmineIssueEventEmitterConfigLoader(); const redmineStatusesConfig = RedmineStatusesConfigLoader(); @@ -15,6 +16,7 @@ const redmineStatusChanges = RedmineStatusChangesConfigLoader(); const redmineEccm = RedmineEccmConfig(); const redmineCurrentUserRules = RedmineCurrentUserRulesConfig(); const simpleKanbanBoard = SimpleKanbanBoardConfig(); +const calendarEnhancer = CalendarEnhancer(); let appConfig: AppConfig; @@ -39,6 +41,7 @@ export default (): AppConfig => { redmineEccm: redmineEccm, redmineCurrentUserRules: redmineCurrentUserRules, simpleKanbanBoard: simpleKanbanBoard, + calendarEnhancer: calendarEnhancer, }; return appConfig; diff --git a/src/configs/calendar-enhancer.config.ts b/src/configs/calendar-enhancer.config.ts new file mode 100644 index 0000000..1b19e6f --- /dev/null +++ b/src/configs/calendar-enhancer.config.ts @@ -0,0 +1,23 @@ +import { readFileSync } from 'fs'; +import { join } from 'path'; +import { parse } from 'jsonc-parser'; + +let config: Record; + +export default (): Record => { + if (config) { + return config; + } + + const userDefinedConfigPath = + process.env['ELTEX_REDMINE_HELPER_CALENDAR_ENHANCER_CONFIG_PATH']; + const defaultConfigPath = join('configs', 'calendar-enhancer.jsonc'); + + const configPath = userDefinedConfigPath || defaultConfigPath; + + const rawData = readFileSync(configPath, { encoding: 'utf-8' }); + + config = parse(rawData); + + return config; +}; diff --git a/src/issue-enhancers/interview-enhancer.ts b/src/issue-enhancers/interview-enhancer.ts deleted file mode 100644 index 06e11c1..0000000 --- a/src/issue-enhancers/interview-enhancer.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { IssueEnhancerInterface } from '@app/event-emitter/issue-enhancers/issue-enhancer-interface'; -import { RedmineTypes } from '@app/event-emitter/models/redmine-types'; -import { Injectable } from '@nestjs/common'; -import * as Luxon from 'luxon'; - -export type SubjectParserParam = { - regexp: string; - format: string; - type: string; -}; - -export type DescriptionParserParam = {}; - -@Injectable() -export class InterviewEnhancer implements IssueEnhancerInterface { - name = 'interview'; - - constructor( - public interviewProjects: string[] = [], - public customFieldDateFormat: string = 'yyyy-MM-dd HH:mm', - public subjectParserParams: SubjectParserParam[] - ) {} - - async enhance( - issue: RedmineTypes.Issue, - ): Promise> { - const res: RedmineTypes.ExtendedIssue = { ...issue }; - - if (this.interviewProjects.indexOf(res.project.name) < 0) { - return res; - } - - const subject = res.subject; - const nextEventDateField = res.custom_fields.find((cf) => { - return cf.name === 'Дата следующего обновления'; - }); - - if () - - const nextEventDate = Luxon.DateTime.fromFormat(nextEventDateField.value, this.customFieldDateFormat); - - return res; - } - - private getNextEventDate(issue: RedmineTypes.ExtendedIssue): Luxon.DateTime|null { - const nextEventDateField = issue.custom_fields.find((cf) => { - return cf.name === 'Дата следующего обновления'; - }); - if (!nextEventDateField) return null; - const nextEventDate = Luxon.DateTime.fromFormat(nextEventDateField.value, this.customFieldDateFormat); - if (!nextEventDate.isValid) return null; - return nextEventDate; - } - - private getDateFromSubject(issue: RedmineTypes.ExtendedIssue): Luxon.DateTime|null { - const subject = issue.subject; - return null; - } -} diff --git a/src/models/app-config.model.ts b/src/models/app-config.model.ts index 38f3873..a60af45 100644 --- a/src/models/app-config.model.ts +++ b/src/models/app-config.model.ts @@ -26,4 +26,4 @@ export type AppConfig = { updateItemsLimit: number; tagsCustomFieldName: string; }; -}; +} & Record;