From b0e8b891c4e33f58f0617da45b5a40efc29541e5 Mon Sep 17 00:00:00 2001 From: Ali Sheikhi Date: Tue, 10 Sep 2024 15:21:54 +0200 Subject: [PATCH 1/4] DD-1637 Add age option to deposit-createreport script --- src/datastation/deposit_create_report.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/datastation/deposit_create_report.py b/src/datastation/deposit_create_report.py index 4e6a49b..c383dbb 100755 --- a/src/datastation/deposit_create_report.py +++ b/src/datastation/deposit_create_report.py @@ -1,4 +1,6 @@ import argparse +from datetime import date, timedelta + from datastation.managedeposit.manage_deposit import ManageDeposit from datastation.common.config import init from datastation.common.send_mail import SendMail @@ -46,7 +48,11 @@ def main(): parser.add_argument('-o', '--output-file', dest='output_file', default='-', help='the file to write the output and send recipient to a to or - for stdout') parser.add_argument('-e', '--enddate', dest='enddate', help='Filter until the record creation of this date') - parser.add_argument('-s', '--startdate', dest='startdate', help='Filter from the record creation of this date') + + group = parser.add_mutually_exclusive_group(required=False) + group.add_argument('-s', '--startdate', dest='startdate', help='Filter from the record creation of this date') + group.add_argument('-a', '--age', dest='age', help='the number of days before today ') + parser.add_argument('-t', '--state', help='The state of the deposit') parser.add_argument('-u', '--user', dest='user', help='The depositor name') parser.add_argument('-f', '--format', dest='file_format', default='text/csv', help='Output data format') @@ -56,6 +62,9 @@ def main(): parser.add_argument('--bcc-email-to', dest='bcc_email_to', help='will be sent only if email-to is defined') args = parser.parse_args() + if args.age is not None and str(args.age).isnumeric(): # Note: args is a Namespace object + vars(args)['startdate'] = (date.today() + timedelta(days=-int(args.age))).strftime('%Y/%m/%d') + server_url = config['manage_deposit']['service_baseurl'] + '/report' ReportHandler(server_url, args).handle_request() From f3253d4dcd809d3b0ec962828595103e6c77d645 Mon Sep 17 00:00:00 2001 From: Jo Pol Date: Tue, 10 Sep 2024 15:38:11 +0200 Subject: [PATCH 2/4] Update src/datastation/deposit_create_report.py --- src/datastation/deposit_create_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datastation/deposit_create_report.py b/src/datastation/deposit_create_report.py index c383dbb..4fe29d1 100755 --- a/src/datastation/deposit_create_report.py +++ b/src/datastation/deposit_create_report.py @@ -51,7 +51,7 @@ def main(): group = parser.add_mutually_exclusive_group(required=False) group.add_argument('-s', '--startdate', dest='startdate', help='Filter from the record creation of this date') - group.add_argument('-a', '--age', dest='age', help='the number of days before today ') + group.add_argument('-a', '--age', dest='age', help='Filter from record creation not older than a number of days before today ') parser.add_argument('-t', '--state', help='The state of the deposit') parser.add_argument('-u', '--user', dest='user', help='The depositor name') From 9dc76c5ba03debd85c8ea2494feae44df82533d0 Mon Sep 17 00:00:00 2001 From: Ali Sheikhi Date: Tue, 24 Sep 2024 16:24:39 +0200 Subject: [PATCH 3/4] DD-1637 Add age option to deposit-createreport script - type age is int --- src/datastation/deposit_create_report.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datastation/deposit_create_report.py b/src/datastation/deposit_create_report.py index af24ea0..7df7d4c 100755 --- a/src/datastation/deposit_create_report.py +++ b/src/datastation/deposit_create_report.py @@ -51,7 +51,7 @@ def main(): group = parser.add_mutually_exclusive_group(required=False) group.add_argument('-s', '--startdate', dest='startdate', help='Filter from the record creation of this date') - group.add_argument('-a', '--age', dest='age', help='Filter from record creation not older than a number of days before today ') + group.add_argument('-a', '--age', dest='age', type=int, help='Filter from record creation not older than a number of days before today ') parser.add_argument('-t', '--state', help='The state of the deposit (repeatable)', action='append') parser.add_argument('-u', '--user', dest='user', help='The depositor name (repeatable)', action='append') @@ -62,7 +62,7 @@ def main(): parser.add_argument('--bcc-email-to', dest='bcc_email_to', help='will be sent only if email-to is defined') args = parser.parse_args() - if args.age is not None and str(args.age).isnumeric(): # Note: args is a Namespace object + if args.age is not None: # Note: args is a Namespace object vars(args)['startdate'] = (date.today() + timedelta(days=-int(args.age))).strftime('%Y/%m/%d') server_url = config['manage_deposit']['service_baseurl'] + '/report' From 0f524e9010eccfd01437aa8c0bfabb6fadcafba2 Mon Sep 17 00:00:00 2001 From: Ali Sheikhi Date: Tue, 24 Sep 2024 16:29:56 +0200 Subject: [PATCH 4/4] DD-1637 Add age option to deposit-createreport script - type age is int - II --- src/datastation/deposit_create_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datastation/deposit_create_report.py b/src/datastation/deposit_create_report.py index 7df7d4c..9fce711 100755 --- a/src/datastation/deposit_create_report.py +++ b/src/datastation/deposit_create_report.py @@ -63,7 +63,7 @@ def main(): args = parser.parse_args() if args.age is not None: # Note: args is a Namespace object - vars(args)['startdate'] = (date.today() + timedelta(days=-int(args.age))).strftime('%Y/%m/%d') + vars(args)['startdate'] = (date.today() + timedelta(days=-args.age)).strftime('%Y/%m/%d') server_url = config['manage_deposit']['service_baseurl'] + '/report'