-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #638 from bigcapitalhq/use-standard-date-format-ex…
…port fix: use standard ISO 8601 format for exported data
- Loading branch information
Showing
7 changed files
with
105 additions
and
14 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
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,48 @@ | ||
import { Service } from 'typedi'; | ||
import { AsyncLocalStorage } from 'async_hooks'; | ||
|
||
@Service() | ||
export class ExportAls { | ||
private als: AsyncLocalStorage<Map<string, any>>; | ||
|
||
constructor() { | ||
this.als = new AsyncLocalStorage(); | ||
} | ||
|
||
/** | ||
* Runs a callback function within the context of a new AsyncLocalStorage store. | ||
* @param callback The function to be executed within the AsyncLocalStorage context. | ||
* @returns The result of the callback function. | ||
*/ | ||
public run<T>(callback: () => T): T { | ||
return this.als.run<T>(new Map(), () => { | ||
this.markAsExport(); | ||
|
||
return callback(); | ||
}); | ||
} | ||
|
||
/** | ||
* Retrieves the current AsyncLocalStorage store. | ||
* @returns The current store or undefined if not in a valid context. | ||
*/ | ||
public getStore(): Map<string, any> | undefined { | ||
return this.als.getStore(); | ||
} | ||
|
||
/** | ||
* Marks the current context as an export operation. | ||
* @param flag Boolean flag to set or unset the export status. Defaults to true. | ||
*/ | ||
public markAsExport(flag: boolean = true): void { | ||
const store = this.getStore(); | ||
store?.set('isExport', flag); | ||
} | ||
/** | ||
* Checks if the current context is an export operation. | ||
* @returns {boolean} True if the context is an export operation, false otherwise. | ||
*/ | ||
public get isExport(): boolean { | ||
return !!this.getStore()?.get('isExport'); | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export const EXPORT_SIZE_LIMIT = 9999999; | ||
export const EXPORT_SIZE_LIMIT = 9999999; | ||
export const EXPORT_DTE_FORMAT = 'YYYY-MM-DD'; |
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