-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Job, Dep Field code-prepending support (#206)
* Job, Dep Field code-prepending support * auto map feature * fix comments - add util func, handle code in VENDOR_TYPE * fix existing test cases * Add check for syncing jobs, deps and add test cases * update func name * added unit tests * fix failing test * add project import related test cases * fix lint * remove redundant db calls * rename helper func, fix is_job_sync_allowed method * add support for code prepending in CATEGORY (#208) * add support for code prepending in CATEGORY * rename the helper method * rename the helper method * add support for code prepending in MERCHANT (#209) * add support for code prepending in MERCHANT * change the callback methods are sent * bug fix * rename the helper method * fix callback method mapping of vendor * Code naming support cost center (#210) * add support for code prepending in COST_CENTER * rename the helper method * add support for code prepending in CUSTOM attribute (#211) * add support for code prepending in CUSTOM attribute * improve test case
- Loading branch information
1 parent
1e91694
commit 4c99385
Showing
28 changed files
with
1,635 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from datetime import datetime, timedelta, timezone | ||
from apps.mappings.models import ImportLog | ||
|
||
|
||
def prepend_code_to_name(prepend_code_in_name: bool, value: str, code: str = None) -> str: | ||
""" | ||
Format the attribute name based on the use_code_in_naming flag | ||
""" | ||
if prepend_code_in_name and code: | ||
return "{} {}".format(code, value) | ||
return value | ||
|
||
|
||
def is_job_sync_allowed(import_log: ImportLog = None) -> bool: | ||
""" | ||
Check if job sync is allowed | ||
""" | ||
time_difference = datetime.now(timezone.utc) - timedelta(minutes=30) | ||
time_difference = time_difference.replace(tzinfo=timezone.utc) | ||
|
||
if ( | ||
not import_log | ||
or import_log.last_successful_run_at is None | ||
or import_log.last_successful_run_at < time_difference | ||
): | ||
return True | ||
|
||
return False |
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.