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

Fix the removed counts in SIS logging #1184

Merged
merged 1 commit into from
May 30, 2023

Conversation

PasiSa
Copy link
Contributor

@PasiSa PasiSa commented May 29, 2023

SIS logging incorrectly counted earlier removed students as removed on every updated. Now it counts only those participants who were not removed earlier.

Description

What?

[ANSWER HERE]

Why?

[ANSWER HERE]

How?

[ANSWER HERE]

Fixes #

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

  • Accessibility test using the WAVE extension.
  • Django unit tests.
  • Selenium tests.
  • Other test. (Add a description below)
  • Manual testing.

[ADD A DESCRIPTION ABOUT WHAT YOU TESTED MANUALLY]

Did you test the changes in

  • Chrome
  • Firefox
  • This pull request cannot be tested in the browser.

Think of what is affected by these changes and could become broken

Translation

Programming style

  • Did you follow our style guides?
  • Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)

Have you updated the README or other relevant documentation?

  • documents inside the doc directory.
  • README.md.
  • Aplus Manual.
  • Other documentation (mention below which documentation).

Is it Done?

  • Reviewer has finished the code review
  • After the review, the developer has made changes accordingly
  • Customer/Teacher has accepted the implementation of the feature

Clean up your git commit history before submitting the pull request!

SIS logging incorrectly counted earlier removed students as removed
on every updated. Now it counts only those participants who were not
removed earlier.
Copy link
Collaborator

@markkuriekkinen markkuriekkinen left a comment

Choose a reason for hiding this comment

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

Good. I just think it is best to run the operation and then clear the cache, not the other way around.

for e in qs:
invalidate_content(Enrollment, e)
delcount += 1
delcount = qs.update(status=Enrollment.ENROLLMENT_STATUS.REMOVED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it still make more sense to remove the students before invalidating the cache? qs.update() used to come before invalidate_content().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that first, but it seems that after the update operation the qs becomes empty here. Apparently the update can affect the qs contents if the same attribute that is updated is also used for filtering.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, I didn't think of that. At least, one possibility is to copy the original list before running update().

qs_before_update = list(qs)
delcount = qs.update(status=...)
for e in qs_before_update:
    invalidate_content(...)

Do you prefer to change this or merge the pull request without further changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have strong preference, so either option is fine with me, but is the order between invalidate and update that important? Compared to having a new variable for a temporary list?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not a big deal. We can keep it like you originally did.

@markkuriekkinen markkuriekkinen merged commit 1998a0e into apluslms:master May 30, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants