Skip to content

Commit

Permalink
ライブコメントとリアクションの初期データ追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tukeJonny committed Oct 31, 2023
1 parent b48b3d9 commit 9c8b21f
Show file tree
Hide file tree
Showing 10 changed files with 201,885 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bench-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
env:
TZ: Asia/Tokyo
run: |
go clean -testcache
go test -p=1 -v ./...
- name: "[bench] Benchmark"
Expand Down
2 changes: 2 additions & 0 deletions development/docker-compose-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
- ../webapp/initial_tags.sql:/home/isucon/webapp/go/initial_tags.sql
- ../webapp/initial_livestreams.sql:/home/isucon/webapp/go/initial_livestreams.sql
- ../webapp/initial_reservation_slots.sql:/home/isucon/webapp/go/initial_reservation_slots.sql
- ../webapp/initial_reactions.sql:/home/isucon/webapp/go/initial_reactions.sql
- ../webapp/initial_livecomments.sql:/home/isucon/webapp/go/initial_livecomments.sql
- ../webapp/powerdns/pdnsutil:/usr/local/bin/pdnsutil
environment:
ISUCON13_MYSQL_DIALCONFIG_ADDRESS: mysql
Expand Down
20 changes: 20 additions & 0 deletions scripts/generate_initial_livecomment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import random

N = 100000

SQL_FORMAT = "\t(1, 1, '{comment}'),\n"



with open('./initial-data/positive_sentence.txt', 'r') as f:
livecomments = list(line.rstrip() for line in f.readlines())

with open('/tmp/livecomments.sql', 'w') as f:
f.write("INSERT INTO livecomments (user_id, livestream_id, comment)\n")
f.write("VALUES\n")
for _ in range(N):
comment = random.choice(livecomments)
sql = SQL_FORMAT.format(comment=comment)
f.write(sql)
f.write("\t(1, 1, 'こんにちは');\n")

19 changes: 19 additions & 0 deletions scripts/generate_initial_reaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import random

N = 100000


SQL_FORMAT = "\t('{emoji_name}', 1, 1),\n"

with open('./initial-data/emoji.txt', 'r') as f:
emoji_list = list(line.rstrip() for line in f.readlines())


with open('/tmp/reactions.sql', 'w') as f:
f.write('INSERT INTO reactions (emoji_name, user_id, livestream_id)\n')
f.write('VALUES\n')
for _ in range(N):
emoji_name = random.choice(emoji_list)
sql = SQL_FORMAT.format(emoji_name=emoji_name)
f.write(sql)
f.write("\t('+1', 1, 1);\n")
Loading

0 comments on commit 9c8b21f

Please sign in to comment.