-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
121 lines (105 loc) · 3.12 KB
/
Copy pathapp.js
File metadata and controls
121 lines (105 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const utilCsv = require("./utils/utilCsv");
const serParticipant = require("./services/serParticipant");
const serTeam = require("./services/serTeam");
const serMatching = require("./services/serMatching");
const serMail = require("./services/serMail");
const serSms = require("./services/serSms");
const serInfo = require("./services/serInfo");
class App {
constructor() {
if (App.instance) return App.instance;
App.instance = this;
return App.instance;
}
async smsLimited(offset) {
await serSms.messageLimited();
}
async rematch() {
const [male, female] = await serMatching.getRematchableTeam();
await serMatching.setCandidate(male, female);
await serMatching.setCandidate(female, male);
const maleList = await serMatching.makeListForRematching();
await serMatching.match(maleList);
}
async checkManInfo() {
const list = await serInfo.getMatchedMale();
const ulist = await serInfo.getUnmatchedMale();
console.log(
`
전체 팀: ${list.length + ulist.length}
매칭 된 남성 팀: ${list.length}
매칭 안 된 남성 팀: ${ulist.length}
`
);
}
async checkWomanInfo() {
const list = await serInfo.getMatchedFemale();
const ulist = await serInfo.getUnmatchedFemale();
console.log(
`
전체 팀: ${list.length + ulist.length}
매칭 된 여성 팀: ${list.length}
매칭 안 된 여성 팀: ${ulist.length}
`
);
}
async injectStart() {
console.log("앱 만들어지는 중...");
const { whPath, otPath } = utilCsv.formPathMaker();
const whParsedCsv = await utilCsv.csvParser(whPath);
const otParsedCsv = await utilCsv.csvParser(otPath);
let whDuplicatedNum = 0;
let otDuplicatedNum = 0;
let whTeamsNum = 0;
let otTeamsNum = 0;
const inject = async () => {
await Promise.all(
whParsedCsv.map(async whRawTeamForm => {
const { result, ret } = await serParticipant.injectWeehanMembers(
whRawTeamForm
);
if (!result) {
console.log("위한 중복 참여 팀:", ++whDuplicatedNum);
return;
}
await serTeam.injectTeam(ret, whRawTeamForm);
console.log(`위한 팀 추가: ${++whTeamsNum}`);
return;
})
);
await Promise.all(
otParsedCsv.map(async otRawTeamForm => {
const { result, ret } = await serParticipant.injectOthersMembers(
otRawTeamForm
);
if (!result) {
console.log("타대생 중복 참여 팀:", ++otDuplicatedNum);
return;
}
await serTeam.injectTeam(ret, otRawTeamForm);
console.log(`타대생 팀 추가: ${++otTeamsNum}`);
return;
})
);
};
await inject();
console.log("완료");
}
async matching() {
const [male, female] = await serMatching.makeListForCandidates();
await serMatching.setCandidate(male, female);
await serMatching.setCandidate(female, male);
const maleList = await serMatching.makeListForMatching();
await serMatching.match(maleList);
}
async mailingStart() {
await serMail.sendMailToMatchedTeam();
await serMail.sendMailToUnmatchedTeam();
}
async messageStart() {
await serSms.sendMessageToMatchedTeam();
await serSms.sendMessageToUnmatchedTeam();
}
}
const app = new App();
module.exports = app;