-
Notifications
You must be signed in to change notification settings - Fork 0
FEAT: 문제 풀이 상태 관리 API #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dlwlehd
wants to merge
11
commits into
dev
Choose a base branch
from
feat/problem-solving-status-api
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
58d9313
Feat: cursor 폴더 .gitignore 추가
dlwlehd 67a1524
Feat: Problem Solving Status 모델 추가
dlwlehd 11ead2b
Feat: ProblemSolvingStatusService 생성
dlwlehd 901ff71
Feat: 문제 상태 업데이트 관련 method 구현
dlwlehd 14d3918
Feat: 통계 관련 method 구현
dlwlehd a4894cf
Feat: Problem Solving Status Serializer 구현
dlwlehd 1237517
Feat: Problem Solving Status View 구현
dlwlehd 1739668
Feat: Problem Solving Status URL 추가
dlwlehd b47c037
Fix: 쿨다운 로직 멤버 전체 공유 되는 방식으로 변경
dlwlehd 6094e95
Feat: 풀이 상태 조회 리스폰스 수정
alsdn1360 424f945
Feat: 내 스터디 조회 리스폰스를 id 기준 정렬로 변경
alsdn1360 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,4 +52,6 @@ poetry.lock | |
| # Environment variables | ||
| .env | ||
| .env.local | ||
| /.env.development | ||
| /.env.development | ||
|
|
||
| .cursor | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/migrations/0009_alter_study_template_content_problemsolvingstatus.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Generated by Django 5.2.8 on 2026-01-12 03:49 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('core', '0008_add_assigned_date_to_solution_note'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='study', | ||
| name='template_content', | ||
| field=models.TextField(default='## 접근 방법\n - \n - \n\n## 코드\n```\n여기에 코드를 입력하세요\n```\n\n## 회고\n - \n - \n', verbose_name='템플릿 내용'), | ||
| ), | ||
| migrations.CreateModel( | ||
| name='ProblemSolvingStatus', | ||
| fields=[ | ||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('status', models.CharField(choices=[('not_attempted', '미시도'), ('in_progress', '진행중'), ('completed', '완료')], default='not_attempted', max_length=20, verbose_name='풀이 상태')), | ||
| ('last_updated_at', models.DateTimeField(auto_now=True, verbose_name='마지막 업데이트 시간')), | ||
| ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='생성일시')), | ||
| ('assignment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solving_statuses', to='core.dailyassignment', verbose_name='일일 과제')), | ||
| ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solving_statuses', to=settings.AUTH_USER_MODEL, verbose_name='사용자')), | ||
| ], | ||
| options={ | ||
| 'verbose_name': '문제 풀이 상태', | ||
| 'verbose_name_plural': '문제 풀이 상태들', | ||
| 'db_table': 'problem_solving_statuses', | ||
| 'indexes': [models.Index(fields=['assignment', 'user'], name='problem_sol_assignm_8f74bd_idx'), models.Index(fields=['assignment'], name='problem_sol_assignm_14e0dc_idx'), models.Index(fields=['user'], name='problem_sol_user_id_525393_idx')], | ||
| 'unique_together': {('assignment', 'user')}, | ||
| }, | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,221 @@ | ||
| from rest_framework import serializers | ||
|
|
||
|
|
||
| class AssignmentStatusQuerySerializer(serializers.Serializer): | ||
| """문제 풀이 상태 조회 Query Serializer""" | ||
|
|
||
| date = serializers.DateField( | ||
| required=False, allow_null=True, help_text="날짜 (YYYY-MM-DD, 기본값: 오늘)" | ||
| ) | ||
| view = serializers.ChoiceField( | ||
| choices=["me", "group"], | ||
| default="me", | ||
| required=False, | ||
| help_text="조회 방식 (me: 현재 사용자, group: 모든 멤버)", | ||
| ) | ||
|
|
||
|
|
||
| class StatisticsQuerySerializer(serializers.Serializer): | ||
| """통계 조회 Query Serializer""" | ||
|
|
||
| view = serializers.ChoiceField( | ||
| choices=["me", "group", "member"], | ||
| default="me", | ||
| required=False, | ||
| help_text="조회 방식 (me: 현재 사용자, group: 모든 멤버, member: 특정 멤버)", | ||
| ) | ||
| member_id = serializers.IntegerField( | ||
| required=False, | ||
| allow_null=True, | ||
| help_text="멤버 ID (view=member일 때 필수)", | ||
| ) | ||
| start_date = serializers.DateField( | ||
| required=False, allow_null=True, help_text="시작 날짜 (YYYY-MM-DD)" | ||
| ) | ||
| end_date = serializers.DateField( | ||
| required=False, allow_null=True, help_text="종료 날짜 (YYYY-MM-DD)" | ||
| ) | ||
|
|
||
| def validate(self, data): | ||
| """view=member일 때 member_id 필수 검증""" | ||
| if data.get("view") == "member" and not data.get("member_id"): | ||
| raise serializers.ValidationError( | ||
| {"member_id": "view='member'일 때 member_id가 필요합니다."} | ||
| ) | ||
| return data | ||
|
|
||
|
|
||
| class ProblemStatusSerializer(serializers.Serializer): | ||
| """문제 풀이 상태 Serializer""" | ||
|
|
||
| problem_id = serializers.IntegerField() | ||
| boj_number = serializers.IntegerField() | ||
| title = serializers.CharField() | ||
| problem_status = serializers.CharField() | ||
| note_status = serializers.CharField() | ||
| last_updated_at = serializers.DateTimeField(allow_null=True) | ||
|
|
||
|
|
||
| class MemberStatusSerializer(serializers.Serializer): | ||
| """멤버 상태 Serializer""" | ||
|
|
||
| member_id = serializers.IntegerField() | ||
| member_email = serializers.EmailField() | ||
| username = serializers.CharField(allow_null=True) | ||
| boj_username = serializers.CharField(allow_null=True) | ||
| problem_status = serializers.CharField() | ||
| note_status = serializers.CharField() | ||
| last_updated_at = serializers.DateTimeField(allow_null=True) | ||
|
|
||
|
|
||
| class StatusSummarySerializer(serializers.Serializer): | ||
| """상태 요약 Serializer""" | ||
|
|
||
| not_attempted_count = serializers.IntegerField() | ||
| in_progress_count = serializers.IntegerField() | ||
| completed_count = serializers.IntegerField() | ||
|
|
||
|
|
||
| class NoteStatusSummarySerializer(serializers.Serializer): | ||
| """노트 상태 요약 Serializer""" | ||
|
|
||
| not_completed_count = serializers.IntegerField() | ||
| completed_count = serializers.IntegerField() | ||
|
|
||
|
|
||
| class AssignmentStatusResponseSerializer(serializers.Serializer): | ||
| """문제 풀이 상태 조회 응답 Serializer (view=me)""" | ||
|
|
||
| date = serializers.DateField() | ||
| view = serializers.CharField() | ||
| assignments = ProblemStatusSerializer(many=True) | ||
| total_count = serializers.IntegerField() | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
| can_update = serializers.BooleanField() | ||
| next_available_at = serializers.DateTimeField(allow_null=True) | ||
| last_updated_at = serializers.DateTimeField(allow_null=True) | ||
|
|
||
|
|
||
| class MemberWithAssignmentsSerializer(serializers.Serializer): | ||
| """멤버와 과제 목록 Serializer""" | ||
|
|
||
| member_id = serializers.IntegerField() | ||
| member_email = serializers.EmailField() | ||
| username = serializers.CharField(allow_null=True) | ||
| boj_username = serializers.CharField(allow_null=True) | ||
| assignments = ProblemStatusSerializer(many=True) | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
| total_count = serializers.IntegerField() | ||
|
|
||
|
|
||
| class OverallSummarySerializer(serializers.Serializer): | ||
| """전체 요약 Serializer""" | ||
|
|
||
| problem_status_summary = serializers.DictField() | ||
| note_status_summary = serializers.DictField() | ||
|
|
||
|
|
||
| class GroupAssignmentStatusResponseSerializer(serializers.Serializer): | ||
| """문제 풀이 상태 조회 응답 Serializer (view=group)""" | ||
|
|
||
| date = serializers.DateField() | ||
| view = serializers.CharField() | ||
| members = MemberWithAssignmentsSerializer(many=True) | ||
| total_members = serializers.IntegerField() | ||
| overall_summary = OverallSummarySerializer() | ||
| can_update = serializers.BooleanField() | ||
| next_available_at = serializers.DateTimeField(allow_null=True) | ||
| last_updated_at = serializers.DateTimeField(allow_null=True) | ||
|
|
||
|
|
||
| class ProblemMembersStatusResponseSerializer(serializers.Serializer): | ||
| """특정 문제의 모든 멤버 풀이 상태 응답 Serializer""" | ||
|
|
||
| problem_id = serializers.IntegerField() | ||
| boj_number = serializers.IntegerField() | ||
| title = serializers.CharField() | ||
| members_status = MemberStatusSerializer(many=True) | ||
| problem_status_summary = serializers.DictField() | ||
| note_status_summary = serializers.DictField() | ||
|
|
||
|
|
||
| class DailyStatisticsSerializer(serializers.Serializer): | ||
| """일별 통계 Serializer""" | ||
|
|
||
| date = serializers.DateField() | ||
| assigned_count = serializers.IntegerField() | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
|
|
||
|
|
||
| class MyStatisticsResponseSerializer(serializers.Serializer): | ||
| """통계 조회 응답 Serializer (view=me)""" | ||
|
|
||
| view = serializers.CharField() | ||
| member_id = serializers.IntegerField() | ||
| member_email = serializers.EmailField() | ||
| username = serializers.CharField(allow_null=True) | ||
| boj_username = serializers.CharField(allow_null=True) | ||
| total_assigned = serializers.IntegerField() | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
| problem_completion_rate = serializers.FloatField() | ||
| note_completion_rate = serializers.FloatField() | ||
| date_range = serializers.DictField() | ||
| daily_statistics = DailyStatisticsSerializer(many=True) | ||
|
|
||
|
|
||
| class MemberStatisticsItemSerializer(serializers.Serializer): | ||
| """멤버 통계 항목 Serializer""" | ||
|
|
||
| member_id = serializers.IntegerField() | ||
| member_email = serializers.EmailField() | ||
| username = serializers.CharField(allow_null=True) | ||
| boj_username = serializers.CharField(allow_null=True) | ||
| total_assigned = serializers.IntegerField() | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
| problem_completion_rate = serializers.FloatField() | ||
| note_completion_rate = serializers.FloatField() | ||
|
|
||
|
|
||
| class GroupStatisticsResponseSerializer(serializers.Serializer): | ||
| """통계 조회 응답 Serializer (view=group)""" | ||
|
|
||
| view = serializers.CharField() | ||
| total_members = serializers.IntegerField() | ||
| total_assigned = serializers.IntegerField() | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
| average_problem_completion_rate = serializers.FloatField() | ||
| average_note_completion_rate = serializers.FloatField() | ||
| date_range = serializers.DictField() | ||
| members_statistics = MemberStatisticsItemSerializer(many=True) | ||
| daily_statistics = DailyStatisticsSerializer(many=True) | ||
|
|
||
|
|
||
| class MemberStatisticsResponseSerializer(serializers.Serializer): | ||
| """통계 조회 응답 Serializer (view=member)""" | ||
|
|
||
| view = serializers.CharField() | ||
| member_id = serializers.IntegerField() | ||
| member_email = serializers.EmailField() | ||
| username = serializers.CharField(allow_null=True) | ||
| boj_username = serializers.CharField(allow_null=True) | ||
| total_assigned = serializers.IntegerField() | ||
| problem_status_summary = StatusSummarySerializer() | ||
| note_status_summary = NoteStatusSummarySerializer() | ||
| problem_completion_rate = serializers.FloatField() | ||
| note_completion_rate = serializers.FloatField() | ||
| date_range = serializers.DictField() | ||
| daily_statistics = DailyStatisticsSerializer(many=True) | ||
|
|
||
|
|
||
| class UpdateCooldownErrorSerializer(serializers.Serializer): | ||
| """상태 업데이트 쿨다운 에러 Serializer""" | ||
|
|
||
| error_code = serializers.CharField() | ||
| message = serializers.CharField() | ||
| next_available_at = serializers.DateTimeField() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User모델에 대한ForeignKey를 정의할 때 Django의 권장사항에 따라settings.AUTH_USER_MODEL을 사용하는 것이 좋습니다. 이렇게 하면 User 모델이 변경되거나 교체될 경우에 더 유연하게 대처할 수 있습니다. 현재 코드도 동작하지만, 일관성과 유지보수성을 위해 변경을 제안합니다.변경을 위해서는 파일 상단에
from django.conf import settings를 추가해야 합니다.