Skip to content
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: 国勢調査に人間の数の項目名を追加、改善 #104

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/service/kokusei-chousa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createMockMessage } from './command-message';
test('use case of kokusei-chousa', async () => {
const responder = new KokuseiChousa({
allMemberCount(): Promise<number> {
return Promise.resolve(100);
return Promise.resolve(150);
},
botMemberCount(): Promise<number> {
return Promise.resolve(50);
Expand All @@ -22,11 +22,16 @@ test('use case of kokusei-chousa', async () => {
fields: [
{
name: '人類の数',
value: `100人`,
value: `150人`,
inline: true
},
{
name: '人間の数',
value: '100人',
inline: true
},
{ name: 'Bot数', value: `50人`, inline: true },
{ name: 'Bot率', value: '50.000%', inline: true }
{ name: 'Botの数', value: `50人`, inline: true },
{ name: 'Bot率', value: '33.333%' }
]
});
return Promise.resolve();
Expand Down
10 changes: 8 additions & 2 deletions src/service/kokusei-chousa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class KokuseiChousa implements CommandResponder {

const botMemberCount = await this.stats.botMemberCount();
const allMemberCount = await this.stats.allMemberCount();
const peopleCount = allMemberCount - botMemberCount;
const botRate = (botMemberCount / allMemberCount) * 100;

await message.reply({
Expand All @@ -47,8 +48,13 @@ export class KokuseiChousa implements CommandResponder {
value: `${allMemberCount}人`,
inline: true
},
{ name: 'Bot数', value: `${botMemberCount}人`, inline: true },
{ name: 'Bot率', value: botRate.toFixed(3) + '%', inline: true }
{
name: '人間の数',
MikuroXina marked this conversation as resolved.
Show resolved Hide resolved
value: `${peopleCount}人`,
inline: true
},
{ name: 'Botの数', value: `${botMemberCount}人`, inline: true },
{ name: 'Bot率', value: botRate.toFixed(3) + '%' }
]
});
}
Expand Down