Skip to content
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

Add an option to process only last rows #159

Merged
merged 9 commits into from
Jul 1, 2024
Merged

Conversation

annagav
Copy link
Contributor

@annagav annagav commented Jun 20, 2024

What are the relevant tickets?

Related to https://github.com/mitodl/hq/issues/4550 and https://github.com/mitodl/hq/issues/4503

Description (What does it do?)

This PR attempts to reduce the time the task is running and to prevent unnecessary reprocessing of the whole sheet, since it is only getting longer.
Add a log info message to state which rows got processed.

How can this be tested?

You would need to set up google sheets to run locally. Follow the instructions here.

Here is the list of vars that you need set in your .env file in your local mitxonline:

MITX_ONLINE_BASE_URL=<your_ngrok_url>
MITOL_GOOGLE_SHEETS_DRIVE_CLIENT_ID=<your_client_id>
MITOL_GOOGLE_SHEETS_DRIVE_CLIENT_SECRET=<your_secret>
MITOL_GOOGLE_SHEETS_DRIVE_API_PROJECT_ID=<your_google_project_id>
MITOL_GOOGLE_SHEETS_PROCESSOR_APP_NAME=mitxonline-refunds-local
MITOL_GOOGLE_SHEETS_ENROLLMENT_CHANGE_SHEET_ID=<sheet_id>
MITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_ID=0
MITOL_GOOGLE_SHEETS_PROCESS_ONLY_LAST_ROWS_NUM=30
GOOGLE_DOMAIN_VERIFICATION_TAG_VALUE=<unique_code>
CSRF_TRUSTED_ORIGINS=<your_ngrok_url_without_https>,

To test the changes of google sheets in your mitxonline instance you would need to :

  1. In ol-django run pants package ::
  2. Then copy the file to your mitxonline repo: cp dist/mitol-django-google-sheets-2023.12.19.1.tar.gz ../mitxonline
  3. In mitxonline in pyproject.toml
-mitol-django-google-sheets = "2023.12.19.1"
+mitol-django-google-sheets = {path = "mitol-django-google-sheets-2023.12.19.1.tar.gz", develop = true}
  1. In Dockerfile move COPY . /app before RUN poetry install
  2. Run docker-compose build

When your task is running successfully you should see logs about the rows that are being processed, "Going to process the sheet starting with row 6"
"Ignored rows in Enrollment Change Request sheet (Refunds): [6, 7, 8]"
"Processed rows with errors in Enrollment Change Request sheet (Refunds): [6, 7, 8]"

Try setting MITOL_GOOGLE_SHEETS_PROCESS_ONLY_LAST_ROWS_NUM=2 in your .env file, then clear all the errors from the sheet and wait the task to run again. It should process only the last 2 rows. By default it is set to 30 rows. If the number of filled out rows is less the MITOL_GOOGLE_SHEETS_PROCESS_ONLY_LAST_ROWS_NUM it will process all rows.

@annagav annagav marked this pull request as ready for review June 24, 2024 20:18
@rachellougee rachellougee self-assigned this Jun 28, 2024
Copy link

@rachellougee rachellougee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During my tests, I set MITOL_GOOGLE_SHEETS_PROCESS_ONLY_LAST_ROWS_NUM = 3 but it started to process the last 4 rows I assume it's because ID starts with 2, so the first row is row 15 (Going to process the sheet starting with row 15), which is ID 12 in my spreadsheet.

image

I don't think it is a big deal. Functionality works great.

@annagav annagav merged commit af10c0d into main Jul 1, 2024
8 checks passed
@annagav annagav deleted the ag/process_only_last_rows branch July 1, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants