-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add a command to reset user's Jobma interview state #1427
Conversation
07bf12d
to
7a80de0
Compare
10052cc
to
cf90ab7
Compare
It looks like the management command is actually named |
Will the command only work if the learner is in the Awaiting payment state? |
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.
Didn't work for me, here are the commands I ran:
Creating bootcamp-ecommerce_web_run ... done
Application:
user='mrbertrand@gmail.com', run='Seed Single Variable Calculus Run 2', state=AWAITING_PAYMENT
State change: AWAITING_USER_SUBMISSIONS -> AWAITING_PAYMENT
Application now shown as "In progress", with "Video Interview" completed, "Application Review" approved, "Payment" as final step.
Then ran:
mattbert@Matts-MacBook-Pro bootcamp-ecommerce % docker-compose run web python manage.py reset_application_interview_state --user 2 --run 2
Creating bootcamp-ecommerce_web_run ... done
Jobma interview state has been reset for User=matt-b Run=Seed Single Variable Calculus, Sep 9 - Dec 8, 2023.
In django admin, the application state is AWAITING_USER_SUBMISSIONS
. But nothing changed on the front end, video submission still exists in django admin. Tried again:
mattbert@Matts-MacBook-Pro bootcamp-ecommerce % docker-compose run web python manage.py reset_application_interview_state --user 2 --run 2
Creating bootcamp-ecommerce_web_run ... done
CommandError: User's application is already in approved state. User=matt-b, Run=Seed Single Variable Calculus, Sep 9 - Dec 8, 2023, State=AWAITING_USER_SUBMISSIONS.
Repeated the above with a slight variation, same basic result:
mattbert@Matts-MacBook-Pro bootcamp-ecommerce % docker-compose run web python manage.py set_application_state --app-id=3 --state=AWAITING_SUBMISSION_REVIEW
Creating bootcamp-ecommerce_web_run ... done
Application:
user='mrbertrand@gmail.com', run='Seed Multivariable Calculus Run 2', state=AWAITING_SUBMISSION_REVIEW
Video interview completed, awaiting application review
mattbert@Matts-MacBook-Pro bootcamp-ecommerce % docker-compose run web python manage.py reset_application_interview_state --user 2 --run 4
Creating bootcamp-ecommerce_web_run ... done
Jobma interview state has been reset for User=matt-b Run=Seed Multivariable Calculus, Sep 9 - Dec 8, 2023.
Status has been reset to AWAITING_USER_SUBMISSIONS
but video submission still exists, no change on front end: "Video Interview" shown as completed, review pending.
mattbert@Matts-MacBook-Pro bootcamp-ecommerce % docker-compose run web python manage.py reset_application_interview_state --user 2 --run 4
Creating bootcamp-ecommerce_web_run ... done
CommandError: User's application is already in approved state. User=matt-b, Run=Seed Multivariable Calculus, Sep 9 - Dec 8, 2023, State=AWAITING_USER_SUBMISSIONS.
ERROR: 1
PS I started with a clean database, ran the following first:
Then registered a user and applied. |
@pdpinch Thanks, I fixed that in the PR description.
@cachob The command should work for all the pre-decided/declared possible reviewable app states. These are mentioned in https://github.com/mitodl/bootcamp-ecommerce/blob/master/applications/constants.py#L42-L45. Currently, they are
@mbertrand Thanks for trying all those possible combinations, While I was testing it locally, It worked for me and even when I tested it right now it works and I think I have the answer to why they might not be working for you.
I tested it on a data set that was created locally some time ago. Now, I guess, In the case of the command, We should just bypass the creation duration of the steps and the statuses. What do you think @mbertrand ? |
@arslanashraf7 thanks, it was the fault of cutoff date for jobma interviews:
Maybe the function could be modified to pass in an optional @app.task
def refresh_pending_interview_links(cutoff_days=settings.JOBMA_LINK_EXPIRATION_DAYS):
"""Recreate old pending interviews"""
now = now_in_utc()
cutoff_date = now - timedelta(days=cutoff_days)
...
...
.filter(
Q(submission_status=SUBMISSION_STATUS_PENDING)
& Q(videointerviews__created_on__lte=cutoff_date)
) and then the mgmt command could call it like this: refresh_pending_interview_links(cutoff_days=0) |
@mbertrand Good suggestion but here are a few more things to that, I gave a quick try to your suggestion as well but I think we might have to go with a bypass approach. Why?
Based on the above, I think only tweaking the cutoff time would not work completely. For the filters bypass approach, I'm making the refresh functionality independent of the filters and dependent upon the provided list of submissions itself so that we can just pass a list of submissions from anywhere and their video interview state could be refreshed. |
21e6bdc
to
bf9270a
Compare
bf9270a
to
0e743c9
Compare
@mbertrand this is ready for review again. |
I am getting this error when running the mgmt command, which results in the transaction being aborted and no changes made. I have set all my
|
@mbertrand oh yeah. Wasn't working for me either, So as a workaround, I returned some dummy values from the function so that the command could succeed without Jomba API error. The Jobma API functionality isn't integral part of this PR or it's scope so I think placeholder values should be fine. I changed the
@mbertrand Do you think we should test it otherwise? |
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.
Modified code to bypass the 500 error from jobma, on first run of the following everything went according to plan:
mitodl@fe24a0c0088d:/src$ python manage.py set_application_state --app-id=1 --state=AWAITING_PAYMENT
Application:
user='mrbertrand@gmail.com', run='Seed Single Variable Calculus Run 2', state=AWAITING_PAYMENT
State change: AWAITING_RESUME -> AWAITING_PAYMENT
mitodl@fe24a0c0088d:/src$ python manage.py reset_application_interview_state --user=2 --run=2
Jobma interview state has been reset for User=matthew-r-bertrand Run=Seed Single Variable Calculus, Sep 11 - Dec 10, 2023.
mitodl@fe24a0c0088d:/src$ python manage.py reset_application_interview_state --user=2 --run=2
CommandError: User's application is not in a reviewable state. User=matthew-r-bertrand, Run=Seed Single Variable Calculus, Sep 11 - Dec 10, 2023, State=AWAITING_USER_SUBMISSIONS.
But then I ran the following again:
mitodl@fe24a0c0088d:/src$ python manage.py set_application_state --app-id=1 --state=AWAITING_PAYMENT
Application:
user='mrbertrand@gmail.com', run='Seed Single Variable Calculus Run 2', state=AWAITING_PAYMENT
State change: AWAITING_USER_SUBMISSIONS -> AWAITING_PAYMENT
and the frontend indicated that the application was awaiting payment but the interview step was still awaiting completion:
@arslanashraf7 I followed your approach to test locally. However it appears interviews are still broken on RC, which will make it difficult to test there. I tried to fix it awhile back but didn't have much luck and moved on to other things. @pdpinch should I try to fix this again now? |
@mbertrand That might probably be because your application step submission's |
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.
Working with JOBMA_BASE_URL=https://dev.jobma.com
(though interview link redirects to an "Interview deleted" page), so I think that should be good enough for RC testing.
What are the relevant tickets?
#1362
What's this PR do?
How should this be manually tested?
./manage.py set_application_state --app-id=5 --state=AWAITING_PAYMENT
VideoInterviewSubmission
andInterview
records - Check in the Django AdminNow check the following:
Awaiting payment
state./manage.py reset_application_interview_state --user=<username or email or id> --run=2
for the user and it should now delete theInterview
and its related submission records, and the user on the frontend should be back to theVideo Interview
stage.applications/constants/REVIEWABLE_APP_STATES
. The command should show an errorAlso, note, Application should only reset if its state is in
REVIEWABLE_APP_STATES
, Otherwise thereset_application_interview_state
should print an error message.Where should the reviewer start?
Set up user, bootcamp enrollment, and a state where the user has passed the Video interview step.