PyJaipur / PyJudge

Simple Programming Contest hosting software
MIT License
17 stars 29 forks source link

User Submission History and User Stats #131

Closed rsvarma95 closed 5 years ago

rsvarma95 commented 5 years ago

User Submission History and User Stats

image

image

rishabhKalakoti commented 5 years ago

We have moved to peewee and mysqli with #126 , you should switch to database accordingly

rishabhKalakoti commented 5 years ago

I was thinking to have stats for individual users (similar to profiles in online judges), I think here we have stats for all the users. @theSage21 what do you think about this? How should we progress?

We can have this these type of stats for the contest/question though

rsvarma95 commented 5 years ago

Added User Specific Data and updated to incorporate sqlite changes

image image

rsvarma95 commented 5 years ago

I have updated the code as per the review comments.

theSage21 commented 5 years ago

Oh right. You're deleting sessions instead of deactivation. Forgot

I've lost touch with this codebase. I'll schedule some time tomorrow to work on this

On Fri 24 May, 2019, 19:27 Rishabh Kalakoti, notifications@github.com wrote:

@rishabhKalakoti commented on this pull request.

In server.py https://github.com/PyJaipur/PyJudge/pull/131#discussion_r287371122:

@@ -146,6 +143,20 @@ def dashboard(): contests = Contest.select().order_by(Contest.start_time) return bottle.template("dashboard.html", contests=contests)

+@app.get("/stats") +@login_required +def statistics():

  • sub_history_temp = Submission.select(Contest.code, ContestProblems.question, Submission.time, Submission.is_correct)\
  • .where(Session.token == bottle.request.get_cookie("s_id"))\
  • .join(ContestProblems, on=(Submission.contestProblem == ContestProblems.id)) \
  • .join(Session, on=(Submission.user == Session.user))\

Adding a session as foreign key to submission doesn't look right to me. Eg. User logged in. Made a submission with session Id = 12345. Logged out. (That session entry would be deleted from the database on logging out). So, when we search for that session while calculating stats, it won't be available anymore.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PyJaipur/PyJudge/pull/131?email_source=notifications&email_token=AB2WHULWPCTVB6WZZ632R6DPW7X35A5CNFSM4HPGGX2KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOBZUOMDQ#discussion_r287371122, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2WHUKNQICI5WZM2DKZFVTPW7X35ANCNFSM4HPGGX2A .

rsvarma95 commented 5 years ago

Ok so I should be getting the user ID from bottle and using that to reference the records right? I don't know exactly how. I'll figure it out tomorrow.

rishabhKalakoti commented 5 years ago

Maybe use something like:

sub_history_temp = Submission.select(
    ...
)
.where(
    Submission.user == Session.get(Session.token == bottle.request.get_cookie("s_id")).user
)
...
rsvarma95 commented 5 years ago

I have deployed the code with the changes that Rishabh suggested.

rsvarma95 commented 5 years ago

Updated the code as per the comments given above, @rishabhKalakoti and @theSage21

rsvarma95 commented 5 years ago

I have formatted the code using Black