This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from proshunsuke/v4
他のカレンダーを登録出来るように抽象化
- Loading branch information
Showing
14 changed files
with
297 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface ScheduleInterface { | ||
title: string; | ||
date: string; | ||
startTime?: string; | ||
endTime?: string; | ||
description?: string; | ||
type: string; | ||
} | ||
|
||
export interface SiteCalendarInterface { | ||
type: string; | ||
calendarId: string; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,14 @@ | ||
import dayjs from 'dayjs'; | ||
import KeyakiSchedule from './keyakizaka/keyakiSchedule'; | ||
import Trigger, { TERMINATION_MINUTES } from './lib/trigger'; | ||
import KeyakiSiteSchedule from './sites/keyakizaka/keyakiSiteSchedule'; | ||
import { SiteScheduleInterface } from './sites/siteSchedule'; | ||
|
||
export default class Schedule { | ||
static async setSchedule(): Promise<void> { | ||
const beginningOfNexYearMonth = dayjs().startOf('month').add(1, 'year'); | ||
let targetBeginningOfMonth = Schedule.getTargetBeginningOfMonth(); | ||
const startDate = dayjs(); | ||
|
||
while (targetBeginningOfMonth.isBefore(beginningOfNexYearMonth)) { | ||
// eslint-disable-next-line no-await-in-loop | ||
await KeyakiSchedule.setSchedule(targetBeginningOfMonth); | ||
targetBeginningOfMonth = targetBeginningOfMonth.add(1, 'month'); | ||
if (Trigger.hasExceededTerminationMinutes(startDate)) { | ||
Trigger.setTrigger(targetBeginningOfMonth); | ||
console.info( | ||
`${TERMINATION_MINUTES}分以上経過したので次のトリガーをセットして終了します。次実行開始する月: ${targetBeginningOfMonth.format( | ||
'YYYY-MM-DD' | ||
)}` | ||
); | ||
return; | ||
} | ||
const siteScheduleList: SiteScheduleInterface[] = [ | ||
new KeyakiSiteSchedule(), | ||
// new KeyakiSiteSchedule | ||
]; | ||
for await (const siteSchedule of siteScheduleList) { | ||
await siteSchedule.setSiteSchedule(); | ||
} | ||
Trigger.deleteTargetDateProperty(); | ||
Trigger.deleteTriggers(); | ||
} | ||
|
||
/** | ||
* | ||
* @returns {dayjs.Dayjs} | ||
*/ | ||
private static getTargetBeginningOfMonth(): dayjs.Dayjs { | ||
const targetDateStr: string | null = Trigger.getTargetDateProperty(); | ||
return targetDateStr | ||
? dayjs(targetDateStr).startOf('month') | ||
: dayjs().startOf('month'); | ||
} | ||
} |
30 changes: 10 additions & 20 deletions
30
src/keyakizaka/keyakiObjects.ts → src/sites/keyakizaka/keyakiObjects.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,41 @@ | ||
export interface ScheduleObj { | ||
title: string; | ||
start: string; | ||
description: string; | ||
className: string; | ||
} | ||
|
||
export interface KeyakiCalendarObj { | ||
kind: string; | ||
calendarId: string; | ||
} | ||
import { SiteCalendarInterface } from '../../calendarInterface'; | ||
|
||
export const getKeyakiCalendarUrl = | ||
process.env.ENV === 'production' | ||
? 'https://us-central1-augc-260709.cloudfunctions.net/getKeyakiSchedule?date=' | ||
: 'http://localhost:8080?date='; | ||
|
||
export const keyakiCalendarIds: KeyakiCalendarObj[] = [ | ||
export const keyakiCalendarIds: SiteCalendarInterface[] = [ | ||
{ | ||
kind: 'shakehands', | ||
type: 'shakehands', | ||
calendarId: 'jdnc8uf21242be7qjm5nmj7uok@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'event', | ||
type: 'event', | ||
calendarId: 'eh0boh68ai7r2v15m38k2ms1lg@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'goods', | ||
type: 'goods', | ||
calendarId: '8l4srrnd9c6vge51k6cclsdsmc@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'release', | ||
type: 'release', | ||
calendarId: '8tc88j0j9gmr95qa81r8t2210c@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'ticket', | ||
type: 'ticket', | ||
calendarId: 'f4bcp8sqv66sugk9m06gb1ioeg@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'media', | ||
type: 'media', | ||
calendarId: '9beck0tqd2096b3b5utkh0jg8g@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'birthday', | ||
type: 'birthday', | ||
calendarId: 'lihum5fsldhsspa3r8altr01ns@group.calendar.google.com', | ||
}, | ||
{ | ||
kind: 'other', | ||
type: 'other', | ||
calendarId: 'efhfvac7iii073suf8v16tlmic@group.calendar.google.com', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import SiteSchedule from '../siteSchedule'; | ||
import { getKeyakiCalendarUrl, keyakiCalendarIds } from './keyakiObjects'; | ||
import { SiteCalendarInterface } from '../../calendarInterface'; | ||
|
||
export default class KeyakiSiteSchedule extends SiteSchedule { | ||
// eslint-disable-next-line class-methods-use-this | ||
siteCalendarUrl(): string { | ||
return getKeyakiCalendarUrl; | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
siteCalendarIds(): SiteCalendarInterface[] { | ||
return keyakiCalendarIds; | ||
} | ||
} |
Oops, something went wrong.