Skip to content

Commit

Permalink
Merge pull request #138 from KazumaSun/feature/sato/shifts-table-to-db
Browse files Browse the repository at this point in the history
Creates shitts table DB by csv
  • Loading branch information
mashita1023 authored Sep 7, 2022
2 parents fee0a33 + 8513f5f commit 739f1ff
Show file tree
Hide file tree
Showing 9 changed files with 807 additions and 67 deletions.
38 changes: 38 additions & 0 deletions sql/20220909shift.csv

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion sql/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ INSERT INTO tasks
VALUES
('テスト1', '24', 'https://example.com', 'Admin', '', 1, 1, 1),
('テスト2', '体育館', 'https://example.com', 'Admin', '', 1, 1, 1),
('テスト3', 'D講', 'https://nutfes.net', 'Admin', '', 1, 1, 1);
('テスト3', 'D講', 'https://nutfes.net', 'Admin', '', 1, 1, 1),
('なし', '', '', 'Admin', '', 1, 1, 41);

INSERT INTO shifts
(user_id, task_id, year_id, date_id, time_id, weather_id, created_user_id, updated_user_id)
Expand Down
224 changes: 224 additions & 0 deletions sql/shift_1_sunny.csv

Large diffs are not rendered by default.

236 changes: 236 additions & 0 deletions sql/shift_2_sunny.csv

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions sql/shift_pre_sunny.csv

Large diffs are not rendered by default.

103 changes: 101 additions & 2 deletions sql/sql.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ void main(List<String> args) async {
var taskCommand = parser.addCommand('task');
taskCommand.addOption('csv', defaultsTo: 'task.csv');

var shiftCommand = parser.addCommand('shift');
shiftCommand.addOption('csv', defaultsTo: 'shift.csv');
shiftCommand.addOption('year', abbr: 'y', defaultsTo: '40');
shiftCommand.addOption('date', abbr: 'd', allowed: ['pre', '1', '2']);
shiftCommand.addOption('weather', abbr: 'w', allowed: ['sunny', 'rainy']);

parser.addCommand('migrate');
var results = parser.parse(args);

Expand All @@ -44,7 +50,8 @@ Available commands:
seed Database seeding `seed.sql`.
migrate Migrate SQL.
new Create migrated sql file.
task Create tasks table
task Create tasks sql file.
shift Create shifs sql file.
New command options:
-m, --model <NAME> Table name.
Expand All @@ -61,6 +68,13 @@ New command options:
user(results.command?['csv']);
} else if (results.command?.name == 'task') {
task(results.command?['csv']);
} else if (results.command?.name == 'shift') {
shift(
csvFile: results.command?['csv'],
year: results.command?['year'],
date: results.command?['date'],
weather: results.command?['weather'],
);
} else {
print("Not Found Option.");
exit(0);
Expand Down Expand Up @@ -157,7 +171,92 @@ VALUES ('${l[0]}', 'ffffff' , '1', '${l[1]}', '', '', 1, 1, 1);
''';
await conn.query(sql);
}
print('task set.');
print('tasks set.');
exit(0);
}

shift({csvFile, year, date, weather}) async {
final year_id = int.parse(year);

// ToDo: 書き方直す
var date_id;
switch (date) {
case 'pre':
date_id = 1;
break;
case '1':
date_id = 2;
break;
case '2':
date_id = 3;
break;
default:
date_id = 4;
break;
}

var weather_id;
switch (weather) {
case 'sunny':
weather_id = 1;
break;
case 'rainy':
weather_id = 2;
break;
default:
weather_id = 0;
break;
}

Map<String, String> env = Platform.environment;
final host = env['DATABASE_HOST'] ?? '';
final user = env['DATABASE_USER'] ?? '';
final password = env['DATABASE_PASSWORD'] ?? '';
final name = env['DATABASE_NAME'] ?? '';

final ConnectionSettings settings = ConnectionSettings(host: host, user: user, password: password, db: name);
var conn = await MySqlConnection.connect(settings);

// var tasks = await conn.query('SELECT * FROM tasks');
// var users = await conn.query('SELECT * FROM users');
// var grades = await conn.query('SELECT * FROM grades');
// var times = await conn.query('SELECT * FROM times');

final List list = [];
for (String line in await File(csvFile).readAsLines()) {
List l = line.split(',').toList();
list.add(l);
}

// timesはnearly equal x-4
final times = await conn.query('SELECT id, time FROM times;');

for (var y = 3; y < list[0].length; y++) {
print('${list[3][y]}');
for (var x = 4; x < list.length; x++) {
if (list[x][0] == '22:00') break;
final u = await conn.query('SELECT id FROM users WHERE name = "${list[3][y]}"');
if (u.isEmpty) {
continue;
}
final user_id = u.first.fields['id'];
final t = await conn.query('SELECT id FROM tasks WHERE task = "${list[x][y]}"');
var task_id;
if (t.isEmpty) {
task_id = 4;
} else {
task_id = t.first.fields['id'];
}
await conn.query('''
INSERT INTO shifts
(user_id, task_id, year_id, date_id, time_id, weather_id, created_user_id, updated_user_id)
VALUES
($user_id, $task_id, $year_id, $date_id, ${x - 3}, $weather_id, 1, 1);
''');
}
}

print('shifts set.');
exit(0);
}

Expand Down
25 changes: 25 additions & 0 deletions sql/task_kikaku.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
タスク名(シフト名),リンク
麻雀準備,https://docs.google.com/document/d/1L53mQ6EHQzISrOldRuNdt8xA0sKecP3oYaV52ep_p-8/edit?usp=sharing
麻雀受付(104),https://docs.google.com/document/d/1L53mQ6EHQzISrOldRuNdt8xA0sKecP3oYaV52ep_p-8/edit?usp=sharing
麻雀受付(105),https://docs.google.com/document/d/1L53mQ6EHQzISrOldRuNdt8xA0sKecP3oYaV52ep_p-8/edit?usp=sharing
麻雀大会 準備受付1,https://docs.google.com/document/d/1L53mQ6EHQzISrOldRuNdt8xA0sKecP3oYaV52ep_p-8/edit?usp=sharing
麻雀大会 受付2,https://docs.google.com/document/d/1L53mQ6EHQzISrOldRuNdt8xA0sKecP3oYaV52ep_p-8/edit?usp=sharing
麻雀大会 2日目受付1,https://docs.google.com/document/d/1L53mQ6EHQzISrOldRuNdt8xA0sKecP3oYaV52ep_p-8/edit?usp=sharing
ポーカーディーラー,https://docs.google.com/document/d/1fMjiqXP8uTouGSjF5lxOmDrIz-PRbU1WHKaSuU6xzRw/edit?usp=sharing
ポーカー受付,https://docs.google.com/document/d/1fMjiqXP8uTouGSjF5lxOmDrIz-PRbU1WHKaSuU6xzRw/edit?usp=sharing
ポーカー準備,https://docs.google.com/document/d/1fMjiqXP8uTouGSjF5lxOmDrIz-PRbU1WHKaSuU6xzRw/edit?usp=sharing
ポーカー大会,https://docs.google.com/document/d/1fMjiqXP8uTouGSjF5lxOmDrIz-PRbU1WHKaSuU6xzRw/edit?usp=sharing
ポーカー大会,https://docs.google.com/document/d/1fMjiqXP8uTouGSjF5lxOmDrIz-PRbU1WHKaSuU6xzRw/edit?usp=sharing
ポーカーAL1準備,https://docs.google.com/document/d/1fMjiqXP8uTouGSjF5lxOmDrIz-PRbU1WHKaSuU6xzRw/edit?usp=sharing
ゲーム マルチメディア準備,https://docs.google.com/document/d/1NibPgowh6lGWb_jWZlNV4NpR8op9crBl/edit?usp=sharing&ouid=103449946645111508813&rtpof=true&sd=true
ゲーム運営,https://docs.google.com/document/d/1NibPgowh6lGWb_jWZlNV4NpR8op9crBl/edit?usp=sharing&ouid=103449946645111508813&rtpof=true&sd=true
ドキュメンタリー撮影,https://docs.google.com/document/d/1xT9m0VPOzYo-UQR57fRzPHJ1sarpqd2tsTm2Y0hSoxE/edit?usp=sharing
ヒーローショー,https://docs.google.com/document/d/1uHeIsMm-7niWlZmnrp_LtVvy1zU8DAV5KuSIUob3DcA/edit?usp=sharing
カラオケ受付,https://docs.google.com/document/d/1ug0Nowtia47s19PHZYebb6AQKmzytWkP8MHzU5TYfxw/edit?usp=sharing
カラオケ大会準備+運営,https://docs.google.com/document/d/1cV6lGC4eS-G7T1vHtcAaCOg7q6tLsN6R_ETgW7za8KQ/edit?usp=sharing
学籍番号抽選会設営,https://docs.google.com/document/d/1KsHt6YJxGEURMjoJaqOX-uBFI682zrfTOi8tYYCptbo/edit?usp=sharing
抽選会システム操作,https://docs.google.com/document/d/1KsHt6YJxGEURMjoJaqOX-uBFI682zrfTOi8tYYCptbo/edit?usp=sharing
抽選会受付,https://docs.google.com/document/d/1KsHt6YJxGEURMjoJaqOX-uBFI682zrfTOi8tYYCptbo/edit?usp=sharing
抽選会呼びかけ,https://docs.google.com/document/d/1KsHt6YJxGEURMjoJaqOX-uBFI682zrfTOi8tYYCptbo/edit?usp=sharing
抽選会整列管理,https://docs.google.com/document/d/1KsHt6YJxGEURMjoJaqOX-uBFI682zrfTOi8tYYCptbo/edit?usp=sharing
学籍番号抽選会,https://docs.google.com/document/d/1KsHt6YJxGEURMjoJaqOX-uBFI682zrfTOi8tYYCptbo/edit?usp=sharing
79 changes: 79 additions & 0 deletions sql/tsak_all.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
シフト名(マニュアル名),リンク,備考欄
D講義室待機,https://docs.google.com/document/d/1ShSEyXWE_9LVS2u2DnnpyQ6osUYw5lpSGNa40ugQVx0/edit#heading=h.20mg9gqlo3mo,
F講待機,https://docs.google.com/document/d/1gD51KOdaApmRuu3YM83O9FtFwj1jONw28LD7JCzrTyU/edit#,
ソファ移動,https://docs.google.com/document/d/12y3rpxCHaK_5BAucqJbwKx_UFlzllBp_yUXh7eYcZ2c/edit,
体育館で使用するパイプ椅子のアルコール除菌マニュアル,https://docs.google.com/document/d/1AwiesU_mSClT9w5shxpO6aOj0azAHHrL9oEWjzxaZ3o/edit,
屋内巡回マニュアル,https://docs.google.com/document/d/16L8RReG-UyCswo9hKLFFZpfTpy6yd1RZ00Eat7eDgo8/edit,
巡回チェックシート,https://docs.google.com/spreadsheets/d/1tNTq4-Sa6fREEdXMjDHPu3XhHm3-5BUZU6BPH-p52mQ/edit#gid=1643837506,
カメラマニュアル,https://docs.google.com/document/d/1R51hSHAV8FkWbWgc5MV0giWv79H_B3KLlVMpXjHXKtM/edit#heading=h.20mg9gqlo3mo,
カメラ撮影チェックリスト,https://docs.google.com/spreadsheets/d/1zg6E5fJ5IW8iA54IKMrPJWPwRfHzUirqSFp45XJt2CY/edit#gid=2026707919,
ゴミ集積場管理(講義棟),https://docs.google.com/document/d/1-qUK03H6j6Ga80Tnugjs8SX2XawoTbH4ik3k2FA-mnQ/edit#heading=h.jivx9l1wg6qr,
売店のチェック,https://docs.google.com/document/d/1F0_wI6nz20keAdwSPgZA6TGVMw-BAtMSZcCN86UIbV0/edit,
施錠,https://docs.google.com/spreadsheets/d/1EOrHHbxpeIg2eeGLkM2jSG0UmMts9ZXspIgRVLonimA/edit?usp=sharing,
配線,https://docs.google.com/document/d/1dZcmCUg6NM3ziLFdqeaE2ZKOMiWZH4yJ-Xe6c8Xxwnk/edit?usp=sharing,
配線確認,https://docs.google.com/document/d/1dZcmCUg6NM3ziLFdqeaE2ZKOMiWZH4yJ-Xe6c8Xxwnk/edit?usp=sharing,
ラミ貼り,https://docs.google.com/document/d/1LBVlkS9Z9AsjV0tUAExrk0KuM0mOIgAQYJF41mSW59U/edit?usp=sharing,
ラミネート回収,https://docs.google.com/document/d/1LBVlkS9Z9AsjV0tUAExrk0KuM0mOIgAQYJF41mSW59U/edit?usp=sharing,
A講義室放送準備,https://docs.google.com/document/d/1bRPnitE1xlY7wdiD2PuWWU-jkCkBh3Dqg9qWyBLO3TA/edit#heading=h.p5xjj8g7c8s,
D講義室放送準備,https://docs.google.com/document/d/1bRPnitE1xlY7wdiD2PuWWU-jkCkBh3Dqg9qWyBLO3TA/edit#heading=h.p5xjj8g7c8s,
D講義室配信対応,https://docs.google.com/document/d/1bRPnitE1xlY7wdiD2PuWWU-jkCkBh3Dqg9qWyBLO3TA/edit#heading=h.p5xjj8g7c8s,
トラサポ設営,https://docs.google.com/document/d/1mZq-PYdtCq-HjRrPmTRx7Dr5PmFbkMwz/edit?usp=sharing&ouid=103449946645111508813&rtpof=true&sd=true,
開店チェック,https://docs.google.com/document/d/1Ku-2nlnvTK-8JZxI5eUD3LLtLLLSejA7nXIWHyw9TLk/edit?usp=sharing,
閉店チェック,https://docs.google.com/document/d/1Ku-2nlnvTK-8JZxI5eUD3LLtLLLSejA7nXIWHyw9TLk/edit?usp=sharing,
開店チェック(国際),https://docs.google.com/document/d/1Ku-2nlnvTK-8JZxI5eUD3LLtLLLSejA7nXIWHyw9TLk/edit?usp=sharing,
閉店チェック(国際),https://docs.google.com/document/d/1Ku-2nlnvTK-8JZxI5eUD3LLtLLLSejA7nXIWHyw9TLk/edit?usp=sharing,
カメラ,https://docs.google.com/document/d/1R51hSHAV8FkWbWgc5MV0giWv79H_B3KLlVMpXjHXKtM/edit?usp=sharing,
巡回1,https://docs.google.com/document/d/16L8RReG-UyCswo9hKLFFZpfTpy6yd1RZ00Eat7eDgo8/edit?usp=sharing,
巡回2,https://docs.google.com/document/d/16L8RReG-UyCswo9hKLFFZpfTpy6yd1RZ00Eat7eDgo8/edit?usp=sharing,
会場装飾見回り,https://docs.google.com/document/d/1UwxSFPA5JdbSYeKpemQOYtSlPOes6vkaD2nxyqNZ_cc/edit?usp=sharing,
入試課看板配置,https://docs.google.com/document/d/1UwxSFPA5JdbSYeKpemQOYtSlPOes6vkaD2nxyqNZ_cc/edit?usp=sharing,
大看板・ウェルカムボード・小看板設置,https://docs.google.com/document/d/1UwxSFPA5JdbSYeKpemQOYtSlPOes6vkaD2nxyqNZ_cc/edit?usp=sharing,
実行委員待機場所管理,https://docs.google.com/document/d/1gD51KOdaApmRuu3YM83O9FtFwj1jONw28LD7JCzrTyU/edit?usp=sharing,
会場アナウンス,https://docs.google.com/document/d/1AJ7ZPrwK9g-UP73r34povzIjXNrqGGnXE9EwmvjaEnw/edit?usp=sharing,
検温所設営 講義棟,https://docs.google.com/document/d/1mweaDqUxonN5O5Y0dsEbaFMq5fhnjDtzpNRQUzjk-CQ/edit?usp=sharing,
検温所設営 体育館,https://docs.google.com/document/d/1jrHxpbeN0MTvSR9cJQMUAuiVAD_0agIfZHSVQ5SksoA/edit?usp=sharing,
検温所対応 体育館,https://docs.google.com/document/d/1tXyMkPbCwbOfACrOfdnqtKYBkGRQe1Fcg5tR4jYsEeI/edit?usp=sharing,
"検温所対応
講義棟1F",https://docs.google.com/document/d/1x9lfwEZJpbHS3AdYxgVtfL2oZPP3oXkZCkXdtWHTTl8/edit?usp=sharing,
"検温所対応
新講義棟1F",https://docs.google.com/document/d/12DrsC37BoP2K2OJYHie77c7qS6dmJjWc2H1UgNLsrKM/edit?usp=sharing,
"検温所対応
講義棟2F",https://docs.google.com/document/d/1Yqaoig5e5bUz0ZtlS0t_lrX724we2Ck76yRazPs6seM/edit?usp=sharing,
"検温所対応
マルチメディア",https://docs.google.com/document/d/151E9EIX2ZnzLfZLFWFrbBceWmRThdMjiQ3A4REhotzk/edit?usp=sharing,
メインステージ設営,,
D講義室設営,,
検温所テント立ち上げ,,
体育館パイプ椅子設置,,
国際リハ,,
校内最終確認,,
ゴミ収集,,
体育館ステージバックボード設営,,
音響機材の片付け手伝い,,
ご飯準備・管理・片付け 朝ごはん,,
ご飯準備・管理・片付け 昼ごはん,,
ご飯準備・管理・片付け 夜ごはん,,
弁当受け取り,,
ケータリング受け渡し,,
参加団体窓口,,
本部指揮,,
本部設営,,
企画指揮,,
朝食,,
昼食,,
夕食,,
本部指揮補佐,,
音響業者・外部来場者の臨時対応,,
バルーンアーチ作成,,
音響機材の設置手伝い,,
参加団体窓口対応,,
講義棟準備,,
衛生対応,,
国際対応,,
参加団体緊急対応,,
総務緊急対応,,
物品窓口,,
物品最終確認,,
物品窓口補佐,,
検温所設営確認,,
屋内巡回,,
Loading

0 comments on commit 739f1ff

Please sign in to comment.