File tree Expand file tree Collapse file tree 1 file changed +30
-21
lines changed
Expand file tree Collapse file tree 1 file changed +30
-21
lines changed Original file line number Diff line number Diff line change @@ -38,29 +38,38 @@ async def start_migration():
3838
3939 from bob .qna .json import json_to_questions
4040
41- logger .info ("migrating qna data (this will take a while)..." )
41+ logger .info ("migrating qna data (this might take a while)..." )
4242 questions = json_to_questions (data )
4343
44- for question in tqdm (questions , unit = "questions" ):
45- dbQuestion = await db .Question .create (
46- text = question .text ,
47- guild = question .guild ,
48- channel = question .channel ,
49- message = question .message ,
50- author = question .author ,
51- )
52- await db .Response .bulk_create (
53- [
54- db .Response (
55- text = resp .text ,
56- count = resp .count ,
57- message = resp .message ,
58- author = resp .author ,
59- question = dbQuestion ,
60- )
61- for resp in question .responses
62- ]
63- )
44+ logger .info ("migrating questions..." )
45+ await db .Question .bulk_create (
46+ [
47+ db .Question (
48+ id = idx + 1 ,
49+ text = q .text ,
50+ guild = q .guild ,
51+ channel = q .channel ,
52+ message = q .message ,
53+ author = q .author ,
54+ )
55+ for idx , q in enumerate (questions )
56+ ]
57+ )
58+
59+ logger .info ("...and responses..." )
60+ await db .Response .bulk_create (
61+ [
62+ db .Response (
63+ question_id = q_idx + 1 ,
64+ text = r .text ,
65+ count = r .count ,
66+ message = r .message ,
67+ author = r .author ,
68+ )
69+ for q_idx , q in enumerate (questions )
70+ for r in q .responses
71+ ]
72+ )
6473
6574 logger .info ("cleaning up, we're done" )
6675 os .remove ("config.json" )
You can’t perform that action at this time.
0 commit comments