-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import argparse | ||
import os | ||
import sys | ||
|
||
from sqlalchemy import create_engine | ||
|
||
sys.path.insert( | ||
1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "lib")) | ||
) | ||
|
||
from galaxy.model.orm.scripts import get_config | ||
from galaxy.model.scripts.history_table_pruner import HistoryTablePruner | ||
|
||
DESCRIPTION = """Remove unused histories from database. | ||
A history is considered unused if it doesn't have a user and its hid counter has not been incremented. | ||
""" | ||
|
||
|
||
def main(): | ||
args = _get_parser().parse_args() | ||
config = get_config(sys.argv, use_argparse=False, cwd=os.getcwd()) | ||
engine = create_engine(config["db_url"]) | ||
htp = HistoryTablePruner(engine=engine, batch_size=args.batch, max_create_time=args.created) | ||
htp.run() | ||
|
||
|
||
def _get_parser(): | ||
parser = argparse.ArgumentParser(description=DESCRIPTION) | ||
parser.add_argument("--batch", help="batch size") | ||
parser.add_argument("--created", help="most recent create_time") | ||
return parser | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters