-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### Feature or Bugfix - Feature - ### Detail - Details mentioned in the GH issue - #1083 ### Relates - #1083 ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? No - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? No - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? No - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? Yes - Have you used the least-privilege principle? How? Yes By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: trajopadhye <tejas.rajopadhye@yahooinc.com>
- Loading branch information
1 parent
eb89983
commit 76a7a3e
Showing
47 changed files
with
3,823 additions
and
130 deletions.
There are no files selected for viewing
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
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,30 @@ | ||
import calendar | ||
from datetime import date, datetime | ||
from dateutil.relativedelta import relativedelta | ||
from dataall.base.api import GraphQLEnumMapper | ||
|
||
|
||
class ExpirationUtils: | ||
@staticmethod | ||
def calculate_expiry_date(expirationPeriod, expirySetting): | ||
currentDate = date.today() | ||
if expirySetting == Expiration.Quartely.value: | ||
quarterlyCalculatedDate = currentDate + relativedelta(months=expirationPeriod * 3 - 1) | ||
day = calendar.monthrange(quarterlyCalculatedDate.year, quarterlyCalculatedDate.month)[1] | ||
shareExpiryDate = datetime(quarterlyCalculatedDate.year, quarterlyCalculatedDate.month, day) | ||
elif expirySetting == Expiration.Monthly.value: | ||
monthlyCalculatedDate = currentDate + relativedelta(months=expirationPeriod - 1) | ||
monthEndDay = calendar.monthrange(monthlyCalculatedDate.year, monthlyCalculatedDate.month)[1] | ||
shareExpiryDate = datetime(monthlyCalculatedDate.year, monthlyCalculatedDate.month, monthEndDay) | ||
else: | ||
shareExpiryDate = None | ||
|
||
return shareExpiryDate | ||
|
||
|
||
# Enums used for dataset expiration. | ||
# Could be repurposed for environment, worksheet, etc if need be | ||
# This is defined here instead of the dataset_enums file because this is used in expiration_util.py | ||
class Expiration(GraphQLEnumMapper): | ||
Monthly = 'Monthly' | ||
Quartely = 'Quarterly' |
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
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
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
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
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
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
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
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
Oops, something went wrong.