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

Clean up previously generated CSV files #10279

Conversation

Jaspreet-singh-1032
Copy link
Contributor

Summary

remove session and summary log exports CSV files that does not have related record in GenerateCSVLogRequest.

References

#10123

Reviewer guidance


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Mar 20, 2023
Copy link
Member

@LianaHarris360 LianaHarris360 left a comment

Choose a reason for hiding this comment

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

This new task looks great and accurately removes the correct session and summary files. One thing I noticed is that the folder that contains the exported session and summary CSV files, also contains the exported users CSV files. So when log_exports_cleanup runs, it is also removing any previously generated/exported users CSV file. However, this file should remain untouched. The exported users CSV file is stored in the log_exports folder with the naming convention:

  • {facility_name}_{last 4 digits of facility ID}_users.csv

@Jaspreet-singh-1032
Copy link
Contributor Author

Sure, will exclude that from the deletion.

@github-actions github-actions bot added the APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) label Mar 23, 2023
@Jaspreet-singh-1032
Copy link
Contributor Author

Finally, that test case is fixed 🙌 Hello @LianaHarris360 please have a look and let me know if any other changes are needed.

Copy link
Member

@LianaHarris360 LianaHarris360 left a comment

Choose a reason for hiding this comment

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

Hi @Jaspreet-singh-1032 I manually tested everything and the CSV file for users is no longer being deleted, nice work 🎉 I left a couple of comments and once this is updated, it should be good to go!

Also, if you add the GitHub keyword "closes" or "fixes" before the issue referenced, it will automatically close the issue once this PR is merged.

@@ -116,3 +169,18 @@ def exportsummarylogcsv(facility_id, **kwargs):
kwargs.get("end_date"),
kwargs.get("locale"),
)


@register_task()
Copy link
Member

Choose a reason for hiding this comment

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

It would be useful to add in a job ID to this task. The register_task decorator takes the job_id as an argument, which will always be used when the task is registered. Using this predictable id deduplicates it and will ensure that there is only one cleanup task running at once.

valid_users_filenames = get_valid_users_csv_filenames()
valid_filenames = valid_filenames.union(valid_logs_filenames)
valid_filenames = valid_filenames.union(valid_users_filenames)
return valid_filenames
Copy link
Member

Choose a reason for hiding this comment

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

This is nothing major, but I think valid_filenames could be set with one line using: valid_logs_filenames.union(valid_users_filenames)

@Jaspreet-singh-1032
Copy link
Contributor Author

It seems the task failed because GitHub has updated its host keys.
https://github.com/orgs/community/discussions/50878
https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/

@LianaHarris360
Copy link
Member

Everything looks good to me, thanks @Jaspreet-singh-1032! Before approving the changes, our QA team will take a look at it for testing @radinamatic

@radinamatic radinamatic requested a review from pcenov March 28, 2023 16:26
Copy link
Member

@pcenov pcenov left a comment

Choose a reason for hiding this comment

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

Thanks @Jaspreet-singh-1032 - manually tested this with the .deb and .exe assets and it's functioning correctly as described. The existing .csv files get replaced if they are in the database and if not they are removed from the log_export folder upon generating a new file.

@LianaHarris360 LianaHarris360 linked an issue Mar 29, 2023 that may be closed by this pull request
3 tasks
@LianaHarris360 LianaHarris360 merged commit d771bcc into learningequality:develop Mar 29, 2023
@Jaspreet-singh-1032
Copy link
Contributor Author

Thank you, everyone ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) DEV: backend Python, databases, networking, filesystem... SIZE: medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up previously generated CSV files
3 participants