feat: update to new meeting date

This commit is contained in:
Karl-Philipp Wulfert
2019-11-13 15:02:12 +01:00
parent b1c019bece
commit 98c73b5758
4 changed files with 39 additions and 36 deletions

View File

@@ -21,7 +21,7 @@ import {render} from 'mustache';
import {join, resolve} from 'path';
import {cwd} from 'process';
import {flatten2dArray, getProjects, readFilePromisified, writeFilePromisified} from '../common';
import {BOLD_LABELS, CONCURRENCY, GROUPS, LABEL_WEIGHTS} from '../configuration';
import {BOLD_LABELS, CONCURRENCY, GROUPS, LABEL_WEIGHTS, NEXT_MEETING} from '../configuration';
/**
* A structure for template compilation
@@ -358,23 +358,7 @@ export async function getIssuesGroupedByAssignees(api: Api, label: string): Prom
* Get next meeting day
*/
export function getNextMeetingDay() {
// get "now"
const now = moment();
// get first wednesday of month
const meetingDayMoment = moment()
.startOf('month')
// tslint:disable-next-line:no-magic-numbers
.hour(10)
// tslint:disable-next-line:no-magic-numbers
.isoWeekday(3);
while (meetingDayMoment.isBefore(now)) {
// add one week until meeting day is after now
meetingDayMoment.add(1, 'weeks');
}
const meetingDay = meetingDayMoment.format('YYYY-MM-DD');
const meetingDay = NEXT_MEETING.format('YYYY-MM-DD');
// log found meeting day
Logger.info(`Generating report for '${meetingDay}' of '${GROUPS.length}' group(s)...`);

View File

@@ -18,7 +18,7 @@ import {IssueState, Scope} from '@openstapps/gitlab-api/lib/types';
import {Logger} from '@openstapps/logger';
import * as moment from 'moment';
import {flatten2dArray} from '../common';
import {CONCURRENCY, GROUPS, NOTE_PREFIX} from '../configuration';
import {CONCURRENCY, GROUPS, LAST_MEETING, NOTE_PREFIX} from '../configuration';
/**
* Remove label `meeting` from closed issues
@@ -37,21 +37,11 @@ export async function unlabel(api: Api) {
Logger.log(`Fetched ${issues.length} closed issue(s).`);
const thisWeeksWednesday = moment()
.startOf('week')
// tslint:disable-next-line:no-magic-numbers
.hour(10)
// tslint:disable-next-line:no-magic-numbers
.day(3);
const lastWeeksWednesday = moment(thisWeeksWednesday)
.subtract(1, 'week');
await asyncPool(CONCURRENCY, issues, async (issue) => {
if (issue.labels.indexOf('meeting') >= 0 && issue.closed_at !== null) {
if (moment(issue.closed_at)
.isBefore(lastWeeksWednesday)) {
.isBefore(LAST_MEETING)) {
Logger.info(`Issue ${issue.title} is closed before last meeting and has label "meeting". Removing it.`);
await api.createNote(