Skip to content

Conversation

Sae126V
Copy link
Member

@Sae126V Sae126V commented Sep 3, 2025

Resolves GT-1092, GT-1057

@Sae126V Sae126V force-pushed the stale-summary-clean-up-script branch 4 times, most recently from af5a3fa to bc8f49c Compare September 3, 2025 13:06
@Sae126V Sae126V force-pushed the stale-summary-clean-up-script branch from bc8f49c to f2e0a02 Compare September 3, 2025 13:15
@Sae126V
Copy link
Member Author

Sae126V commented Sep 3, 2025

This PR is ready for the review.

If the script requires passing multiple table names at once to delete the data [With the same threshold and timeframe]. I have the solution ready in my local. Please let me know if we want that feature. The feature would be like , separated values. table_name = VNormalisedSummaries, someOtherTableNam

@tofu-rocketry tofu-rocketry self-assigned this Sep 3, 2025
@tofu-rocketry tofu-rocketry added the enhancement New feature or request label Sep 3, 2025
@tofu-rocketry
Copy link
Member

tofu-rocketry commented Sep 3, 2025

If the script requires passing multiple table names at once to delete the data [With the same threshold and timeframe]. I have the solution ready in my local. Please let me know if we want that feature. The feature would be like , separated values. table_name = VNormalisedSummaries, someOtherTableNam

No, I can't see a use-case for that at the moment. We're only interested it getting one table cleaned up.

Comment on lines 2 to 3
# type of database
backend = mysql
Copy link
Member

Choose a reason for hiding this comment

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

This isn't actually used, and we know the type of database we're targetting. Remove.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

result = cursor.fetchone()

if not result or not result[0]:
no_records_found_error = "No UpdateTime values found. Nothing to purge."
Copy link
Member

Choose a reason for hiding this comment

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

Constants should be ALL_CAPS.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed this as we are no longer using. But, changed the code in other places for ALL_CAPS

)

if args.dry_run:
print(column_not_found_error)
Copy link
Member

Choose a reason for hiding this comment

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

Rather than doing all these ifs for print or log, just configure the logging at the start to output to stdout if it's a dry-run.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh!. I didn't thought of it. Make sense to me.

Comment on lines 221 to 222
default_config_path = '/etc/apel/delete_stale_records.cfg'
default_logfile_path = '/var/log/apel/delete_stale_records.log'
Copy link
Member

Choose a reason for hiding this comment

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

Const = CAPS

Copy link
Member Author

Choose a reason for hiding this comment

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

DOne

from datetime import timedelta
from argparse import ArgumentParser
from configparser import ConfigParser, NoSectionError, NoOptionError
import MySQLdb
Copy link
Member

Choose a reason for hiding this comment

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

Add a space between built in and 3rd-party imports.

hostname =
# port to connect to
port = 3306
# database name
Copy link
Member

Choose a reason for hiding this comment

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

I know the DB config for APEL is quite verbose in its comments, but we don't need to repeat that. name should be schema_name to make it more descriptive, and you could keep the comment for table_name but otherwise, the other config options are quite straightforward.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. name is the one we are using in other places as well which is why I thought to keep it consistent. As this is standalone file it make sense to be more descriptive.

@Sae126V Sae126V force-pushed the stale-summary-clean-up-script branch from ca2ea6e to 3da7c6a Compare September 4, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants