Skip to content

Comments

🧹 Add Django management command for cleaning up old data and orphaned files#30

Merged
DimitrovK merged 2 commits intoCVImprover:mainfrom
Pallavrai:pallav-Cleanup_command
Oct 6, 2025
Merged

🧹 Add Django management command for cleaning up old data and orphaned files#30
DimitrovK merged 2 commits intoCVImprover:mainfrom
Pallavrai:pallav-Cleanup_command

Conversation

@Pallavrai
Copy link
Contributor

Implements a Django management command to clean up old AI responses and orphaned resume files to save storage space and maintain database hygiene.

Implementation

Command location: cleanup_old_data.py
Models affected: AIResponse , CVQuestionnaire
File cleanup: Removes orphaned files in MEDIA_ROOT/resumes/

Features

Configurable retention period (default: 90 days)
Dry-run mode for safe testing
Force mode to skip confirmations
Human-readable file size reporting
Empty directory cleanup

Usage

# Preview cleanup (dry-run)
python manage.py cleanup_old_data --days=30 --dry-run --cleanup-files

# Clean AI responses older than 60 days
python manage.py cleanup_old_data --days=60

# Full cleanup with file removal
python manage.py cleanup_old_data --cleanup-files --force

# Automated cleanup (for cron)
python manage.py cleanup_old_data --days=90 --cleanup-files --force 

Command Options

--days - Retention period in days (default: 90)
--dry-run - Preview mode without changes
--force - Skip confirmation prompts
--cleanup-files - Remove orphaned resume files

Technical Details

AI Response cleanup: Deletes AIResponse objects older than cutoff date
File cleanup: Identifies and removes files not referenced by any CVQuestionnaire

Closes #21

Copy link

@skalwaghe-56 skalwaghe-56 left a comment

Choose a reason for hiding this comment

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

AI?

@Pallavrai
Copy link
Contributor Author

@skalwaghe-56 Nahh, I just generated the comments to enhance readability and the create_test_data.py script to test its functionality.

@skalwaghe-56
Copy link

@skalwaghe-56 Nahh, I just generated the comments to enhance readability and the create_test_data.py script to test its functionality.

I would strictly recommend not using AI. AI should not be used for contributions and it is should be avoided at any costs. I request you to please not use AI in the future too. Thanks! (Open source contribution is not for AI generated code)
As per me, you should do this yourself and enjoy the process and not for some swags in the HacktoberFest.

@Pallavrai
Copy link
Contributor Author

@skalwaghe-56 Bro, chill. I've been coding for several years, and I use it as a companion to make my code more readable by documenting and commenting on it. This helps reviewers and others make proper corrections.

@skalwaghe-56
Copy link

Haha, alright, Mr. “Several Years of Coding” 😎. Just don’t let your AI buddy start writing your pull requests. You shouldn't use AI at all in open-source contribution for actual world code as per me. That would ruin all the fun of open-source!

@Pallavrai
Copy link
Contributor Author

@skalwaghe-56 Relax, the AI is the GPS, not the driver. It's here to help with the comments and docs, but I'm still the one building the engine. It's a companion, not a replacement. Meanwhile, I think the good-first-issue label is calling your name.

@skalwaghe-56
Copy link

@skalwaghe-56 Relax, the AI is the GPS, not the driver. It's here to help with the comments and docs, but I'm still the one building the engine. It's a companion, not a replacement. Meanwhile, I think the good-first-issue label is calling your name.

Nicee! Use AI here as well. Understood who is what? very clearly.

Copy link
Contributor

@DimitrovK DimitrovK left a comment

Choose a reason for hiding this comment

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

I don't like the use of all these emojies (from AI) in the command, can you clear that up please

@Pallavrai
Copy link
Contributor Author

yeah sure

Copy link

@skalwaghe-56 skalwaghe-56 left a comment

Choose a reason for hiding this comment

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

LGTM

@DimitrovK DimitrovK merged commit 9a26993 into CVImprover:main Oct 6, 2025
1 check failed
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.

Create Custom Management Command for Data Cleanup

3 participants