用户调查
This commit is contained in:
@@ -4,7 +4,7 @@ from ..views.oj import (
|
||||
ApplyResetPasswordAPI,
|
||||
ResetPasswordAPI,
|
||||
UserChangePasswordAPI,
|
||||
UserProfileAnalyse,
|
||||
Metrics,
|
||||
UserRegisterAPI,
|
||||
UserChangeEmailAPI,
|
||||
UserLoginAPI,
|
||||
@@ -35,8 +35,8 @@ urlpatterns = [
|
||||
path("captcha", CaptchaAPIView.as_view()),
|
||||
path("check_username_or_email", UsernameOrEmailCheck.as_view()),
|
||||
path("profile", UserProfileAPI.as_view(), name="user_profile_api"),
|
||||
path("profile/analyse", UserProfileAnalyse.as_view()),
|
||||
path("profile/fresh_display_id", ProfileProblemDisplayIDRefreshAPI.as_view()),
|
||||
path("metrics", Metrics.as_view()),
|
||||
path("upload_avatar", AvatarUploadAPI.as_view()),
|
||||
path("tfa_required", CheckTFARequiredAPI.as_view()),
|
||||
path(
|
||||
|
||||
@@ -80,14 +80,22 @@ class UserProfileAPI(APIView):
|
||||
)
|
||||
|
||||
|
||||
class UserProfileAnalyse(APIView):
|
||||
class Metrics(APIView):
|
||||
def get(self, request):
|
||||
userid = request.GET.get("userid")
|
||||
submission = Submission.objects.filter(user_id=userid).latest("create_time")
|
||||
if not submission:
|
||||
submissions = Submission.objects.filter(user_id=userid)
|
||||
if len(submissions) == 0:
|
||||
return self.error("暂无提交")
|
||||
else:
|
||||
return self.success({"now": timezone.now(), "last": submission.create_time})
|
||||
latest_submission = submissions.first()
|
||||
last_submission = submissions.last()
|
||||
return self.success(
|
||||
{
|
||||
"now": timezone.now(),
|
||||
"latest": latest_submission.create_time,
|
||||
"first": last_submission.create_time,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class AvatarUploadAPI(APIView):
|
||||
|
||||
Reference in New Issue
Block a user