Skip to content

Commit

Permalink
fix: 닉네임 리스트 수정 및 스케줄러 안되는 부분 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Euizzang8001 committed Aug 19, 2024
1 parent fc4168d commit e792c2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions KUA/student/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

load_dotenv()

nickname_animal = ['고양이', '강아지', '호랑이', '토끼', '쥐', '기린', '얼룩말', '여우']
nickname_animal = ["소","금붕어","우파루파","여우","뱀","양","판다","호랑이","고양이","범고래","카멜레온","오리","거북이","비버","청둥오리","원숭이",
"쥐","표범","물소","곰","하마","강아지","게","코끼리","무당벌레","코뿔소","말","문어","벌","닭","사자","바다사자","나비","북극곰","사슴","기린","홍학","개구리","물개","앵무새"]



def update_data():
Expand All @@ -34,6 +36,10 @@ def update_data():
student_ids = cur.fetchall()
student_number = len(student_ids)

cur.execute('SELECT id FROM student_nicknamehistory;')
history_ids = cur.fetchall()
history_number = len(history_ids) + 1

if student_number == 0:
print("No students found.")
conn.close()
Expand All @@ -59,8 +65,9 @@ def update_data():
''', (nickname, nickname_change_time, student_id))
cur.execute('''
INSERT INTO student_nicknamehistory
VALUES ( %s, %s, %s);
''', (student_id, nickname, nickname_change_time))
VALUES ( %s, %s, %s, %s);
''', (history_number, nickname, nickname_change_time, student_id))
history_number += 1

conn.commit()
conn.close()
Expand All @@ -74,5 +81,5 @@ def start_scheduler():
if not scheduler.running:
# 2024년 7월 4일 오전 12시 이후 1분마다 실행되도록 설정
scheduler.add_job(update_data, 'interval',
hours=24, start_date=start_time)
minutes = 1, start_date=start_time)
scheduler.start()
4 changes: 3 additions & 1 deletion KUA/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def post(self, request):

student_number = models.Student.objects.count()

nickname_animal = ['고양이', '강아지', '호랑이', '토끼', '쥐', '기린', '얼룩말', '여우']
nickname_animal = ["소","금붕어","우파루파","여우","뱀","양","판다","호랑이","고양이","범고래","카멜레온","오리","거북이","비버","청둥오리","원숭이",
"쥐","표범","물소","곰","하마","강아지","게","코끼리","무당벌레","코뿔소","말","문어","벌","닭","사자","바다사자","나비","북극곰","사슴","기린","홍학","개구리","물개","앵무새"]


random_animal = random.choices(nickname_animal, k=1)

Expand Down

0 comments on commit e792c2a

Please sign in to comment.