-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: unactivated check, etc #262
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Sales Daily CI | ||
|
||
on: | ||
# 毎週金曜の 17:00 に実行 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✍️ アーカイヴは毎週金曜の 17:00 を想定 |
||
# schedule: | ||
# - cron: 0 17 * * 5 # https://crontab.guru/#0_17_*_*_5 | ||
# push: | ||
# branches: | ||
# - main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
sales-daily: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.19.0] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install packages | ||
uses: ./.github/actions/install-packages | ||
|
||
- name: Build sales daily | ||
run: bun build-sales-daily | ||
working-directory: apps/peatix-adapter | ||
env: | ||
PEATIX_EVENT_ID: ${{ secrets.PEATIX_EVENT_ID }} | ||
PEATIX_BASIC_EMAIL: ${{ secrets.PEATIX_BASIC_EMAIL }} | ||
PEATIX_BASIC_PASSWORD: ${{ secrets.PEATIX_BASIC_PASSWORD }} | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} |
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,36 @@ | ||
name: Unactivated Check CI | ||
|
||
on: | ||
# 毎日 23:00 に実行 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✍️ 紐付けされていないかチェックするのは毎日の 23:00 を想定 |
||
# schedule: | ||
# - cron: 0 23 * * * # https://crontab.guru/#0_23_*_*_* | ||
# push: | ||
# branches: | ||
# - main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
unactivated-check: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.19.0] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install packages | ||
uses: ./.github/actions/install-packages | ||
|
||
- name: Build unactivated check | ||
run: bun build-unactivated-check | ||
working-directory: apps/peatix-adapter | ||
env: | ||
PEATIX_EVENT_ID: ${{ secrets.PEATIX_EVENT_ID }} | ||
PEATIX_BASIC_EMAIL: ${{ secrets.PEATIX_BASIC_EMAIL }} | ||
PEATIX_BASIC_PASSWORD: ${{ secrets.PEATIX_BASIC_PASSWORD }} | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} |
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
21 changes: 21 additions & 0 deletions
21
apps/peatix-adapter/src/sales-daily/sales-daily.command.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Logger } from '@nestjs/common' | ||
import { CommandRunner, Command } from 'nest-commander' | ||
import { SalesDailyService } from './sales-daily.service' | ||
|
||
type CommandOptions = { | ||
id?: number; | ||
}; | ||
|
||
@Command({ name: 'sales-daily', description: 'A sales daily command.' }) | ||
export class SalesDailyCommand extends CommandRunner { | ||
private readonly logger = new Logger(SalesDailyCommand.name) | ||
|
||
constructor(readonly salesDailyService: SalesDailyService) { | ||
super() | ||
} | ||
|
||
async run(params: string[], options?: CommandOptions): Promise<void> { | ||
this.salesDailyService.apply() | ||
return Promise.resolve() | ||
} | ||
} |
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,47 @@ | ||
import { Module } from '@nestjs/common' | ||
import { ConfigModule, ConfigService } from '@nestjs/config' | ||
import { SalesDailyService } from './sales-daily.service' | ||
import { EnvService } from '../env/env.service' | ||
import { | ||
symbol as IPuppeteerService, | ||
PuppeteerService, | ||
} from '../puppeteer/puppeteer.service' | ||
import { SalesDailyCommand } from './sales-daily.command' | ||
import { configuration } from '../env/utils' | ||
import { EnvModule } from '../env/env.module' | ||
import { HttpModule } from '@nestjs/axios' | ||
import { SupabaseModule } from 'src/supabase/supabase.module' | ||
import { SupabaseService } from 'src/supabase/supabase.service' | ||
import { DiscordModule } from 'src/discord/discord.module' | ||
import { DiscordService } from 'src/discord/discord.service' | ||
import { PeatixOrderService } from 'src/peatix-order/peatix-order.service' | ||
import { PeatixOrderModule } from 'src/peatix-order/peatix-order.module' | ||
|
||
@Module({ | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
envFilePath: '.env', | ||
expandVariables: true, | ||
load: [configuration], | ||
}), | ||
EnvModule, | ||
HttpModule, | ||
SupabaseModule, | ||
PeatixOrderModule, | ||
DiscordModule, | ||
], | ||
providers: [ | ||
ConfigService, | ||
EnvService, | ||
{ | ||
provide: IPuppeteerService, | ||
useClass: PuppeteerService, | ||
}, | ||
SalesDailyCommand, | ||
SalesDailyService, | ||
SupabaseService, | ||
PeatixOrderService, | ||
DiscordService, | ||
], | ||
}) | ||
export class SalesDailyModule {} |
56 changes: 56 additions & 0 deletions
56
apps/peatix-adapter/src/sales-daily/sales-daily.service.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Injectable, Logger } from '@nestjs/common' | ||
import { SupabaseService } from 'src/supabase/supabase.service' | ||
import { DiscordService } from 'src/discord/discord.service' | ||
import { PeatixOrderService } from 'src/peatix-order/peatix-order.service' | ||
import { AttendeeReceipt } from 'src/types/supabase' | ||
import { Constants } from 'src/constnats' | ||
|
||
@Injectable() | ||
export class SalesDailyService { | ||
private readonly logger = new Logger(SalesDailyService.name) | ||
|
||
constructor( | ||
private readonly peatixOrderService: PeatixOrderService, | ||
private readonly supabaseService: SupabaseService, | ||
private readonly discordService: DiscordService, | ||
) { | ||
// | ||
} | ||
|
||
async apply() { | ||
const orders = await this.peatixOrderService.getOrders() | ||
|
||
const receipts: AttendeeReceipt[] = orders | ||
.map((attendee) => { | ||
const appliedAt = attendee[Object.keys(attendee)[Constants.PEATIX_APPLIED_AT_ROW_INDEX]] | ||
const receiptId = attendee[Object.keys(attendee)[Constants.PEATIX_RECEIPT_ID_ROW_INDEX]] | ||
const ticketName = attendee[Object.keys(attendee)[Constants.PEATIX_RECEIPTS_TICKET_NAME_ROW_INDEX]] | ||
|
||
const d = new Date(appliedAt) | ||
const appliedDate = `${d.getFullYear()}/${d.getMonth() + 1}/${d.getDate()}` | ||
|
||
// チケット名から参加者の種別を特定する | ||
if (ticketName.includes(Constants.PEATIX_GENERAL_TICKET)) { | ||
return { date: appliedDate, role: Constants.PEATIX_GENERAL_ROLE, receipt_id: receiptId } | ||
} | ||
if (ticketName.includes(Constants.PEATIX_WITH_PARTY_TICKET)) { | ||
return { date: appliedDate, role: Constants.PEATIX_WITH_PARTY_ROLE, receipt_id: receiptId } | ||
} | ||
|
||
// return { role: 'attendee', receipt_id: receiptId } | ||
}) | ||
.filter(v => v) // null は除外 | ||
|
||
const startedDate = new Date(2024, 7 - 1, 29) | ||
let archives = [[], [], []] | ||
for (let date = startedDate; date <= new Date(); date.setDate(date.getDate() + 1)) { | ||
archives[0].push(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`) | ||
archives[1].push(`${receipts.filter(v => v.role === Constants.PEATIX_GENERAL_ROLE).filter(v => v.date.includes(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`)).length}`) | ||
archives[2].push(`${receipts.filter(v => v.role === Constants.PEATIX_WITH_PARTY_ROLE).filter(v => v.date.includes(`${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`)).length}`) | ||
} | ||
for (const archive of archives) { | ||
this.logger.log(`${archive.join(', ')} `) | ||
this.discordService.send('After Purchase Bot', `${archive.join(', ')} `) | ||
} | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
apps/peatix-adapter/src/unactivated-check/unactivated-check.command.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Logger } from '@nestjs/common' | ||
import { CommandRunner, Command } from 'nest-commander' | ||
import { UnactivatedCheckService } from './unactivated-check.service' | ||
|
||
type CommandOptions = { | ||
id?: number; | ||
}; | ||
|
||
@Command({ name: 'unactivated-check', description: 'An unactivated check command.' }) | ||
export class UnactivatedCheckCommand extends CommandRunner { | ||
private readonly logger = new Logger(UnactivatedCheckCommand.name) | ||
|
||
constructor(readonly unactivatedCheckService: UnactivatedCheckService) { | ||
super() | ||
} | ||
|
||
async run(params: string[], options?: CommandOptions): Promise<void> { | ||
this.unactivatedCheckService.apply() | ||
return Promise.resolve() | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
apps/peatix-adapter/src/unactivated-check/unactivated-check.module.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Module } from '@nestjs/common' | ||
import { ConfigModule, ConfigService } from '@nestjs/config' | ||
import { UnactivatedCheckService } from './unactivated-check.service' | ||
import { EnvService } from '../env/env.service' | ||
import { | ||
symbol as IPuppeteerService, | ||
PuppeteerService, | ||
} from '../puppeteer/puppeteer.service' | ||
import { UnactivatedCheckCommand } from './unactivated-check.command' | ||
import { configuration } from '../env/utils' | ||
import { EnvModule } from '../env/env.module' | ||
import { HttpModule } from '@nestjs/axios' | ||
import { SupabaseModule } from 'src/supabase/supabase.module' | ||
import { SupabaseService } from 'src/supabase/supabase.service' | ||
import { DiscordModule } from 'src/discord/discord.module' | ||
import { DiscordService } from 'src/discord/discord.service' | ||
|
||
@Module({ | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
envFilePath: '.env', | ||
expandVariables: true, | ||
load: [configuration], | ||
}), | ||
EnvModule, | ||
HttpModule, | ||
SupabaseModule, | ||
DiscordModule, | ||
], | ||
providers: [ | ||
ConfigService, | ||
EnvService, | ||
{ | ||
provide: IPuppeteerService, | ||
useClass: PuppeteerService, | ||
}, | ||
UnactivatedCheckCommand, | ||
UnactivatedCheckService, | ||
SupabaseService, | ||
DiscordService, | ||
], | ||
}) | ||
export class UnactivatedCheckModule {} |
21 changes: 21 additions & 0 deletions
21
apps/peatix-adapter/src/unactivated-check/unactivated-check.service.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable, Logger } from '@nestjs/common' | ||
import { SupabaseService } from 'src/supabase/supabase.service' | ||
import { DiscordService } from 'src/discord/discord.service' | ||
|
||
@Injectable() | ||
export class UnactivatedCheckService { | ||
private readonly logger = new Logger(UnactivatedCheckService.name) | ||
|
||
constructor( | ||
private readonly supabaseService: SupabaseService, | ||
private readonly discordService: DiscordService, | ||
) { | ||
// | ||
} | ||
|
||
async apply() { | ||
this.supabaseService.updateUnactivatedAttendees() | ||
|
||
this.discordService.send('After Purchase Bot', '未反映者 反映済') | ||
} | ||
} |
Binary file not shown.
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✍️
紐付けは 2 時間おきを想定