Skip to content

Commit

Permalink
DD-1637 Add age option to deposit-createreport script (#66)
Browse files Browse the repository at this point in the history
* DD-1637 Add age option to deposit-createreport script

* Update src/datastation/deposit_create_report.py

* DD-1637 Add age option to deposit-createreport script - type age is int

* DD-1637 Add age option to deposit-createreport script - type age is int - II

---------

Co-authored-by: Ali Sheikhi <[email protected]>
Co-authored-by: Jo Pol <[email protected]>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent c7429a1 commit 9f9c283
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/datastation/deposit_create_report.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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', 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')
parser.add_argument('-f', '--format', dest='file_format', default='text/csv', help='Output data format')
Expand All @@ -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: # Note: args is a Namespace object
vars(args)['startdate'] = (date.today() + timedelta(days=-args.age)).strftime('%Y/%m/%d')

server_url = config['manage_deposit']['service_baseurl'] + '/report'

ReportHandler(server_url, args).handle_request()
Expand Down

0 comments on commit 9f9c283

Please sign in to comment.