Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add catch & redirect to specific project & issue number. #1

Open
LiamKarlMitchell opened this issue Nov 29, 2018 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@LiamKarlMitchell
Copy link
Owner

Maybe something like this (untested).

{
	"redirectFilters": [
		{
			"projectId": "*",
			"targetProjectId": 361,
			"targetIssueNumber": 1,
			"errorOnBillable": true
		},
		{
			"projects": [1,2,3,4,5],
			"targetProjectId": 1,
			"targetIssueNumber": 1,
			"errorOnBillable": true
		},
		{
			"tags": ["catch"],
			"targetProjectId": 1,
			"targetIssueNumber": 1,
			"errorOnBillable": true	
		},
		{
                        "projectId": 361
			"pattern": "misc|meeting,",
			"targetIssueNumber": 1,
			"errorOnBillable": true
		}
	]
}
if (config.redirectFilters) {

	for (var i=0; i < config.redirectFilters.length; i++) {
		let filter = redirectFilters[i];
		var applyFilter = true;

		// Check if the pattern would not be matched by.

		// Pattern.
		if (filter.pattern && timeEntry.description.match(filter.pattern) === null) {
		  applyFilter = false
		}

		// ProjectID wild card or exact match.
		if (filter.projectId && !(filter.projectId === '*' || timeEntry.activeCollabProjectId !== filter.projectId)) {
		  applyFilter = false
		}

		// Project ID in array.
		if (filter.projects && Array.isArray(filter.projects) && filter.projects.includes(timeEntry.activeCollabProjectId) === false) {
			applyFilter = false
		}

		if (applyFilter === true) {
			// Fail if error on billable is set to true and timeEntry is marked as billable.
			if (filter.errorOnBillable === true && timeEntry.billable === true) {
				// Fail as billable would have been met by this filter.
				throw new Error('Filter error on billable.');
			}

			// Over-ride values with the target values.
                        if (filter.targetProjectId) {
                            timeEntry.activeCollabProjectId = projectid = filter.targetProjectId
                        }
			timeEntry.issueNumber = issueNumber = filter.targetIssueNumber

			// Get the new mappings.
                       projectMapping = projectMappings.find((_projectMapping) => {
                               return _projectMapping.activeCollabProjectId === timeEntry.activeCollabProjectId
                       })

                        if (!projectMapping) {
                                // Error target project mapping not found.
                        }
                        projectTasks = await getActiveCollabProjectTasks(projectMapping.activeCollabProjectId)
			break
		}
	}
}
@LiamKarlMitchell LiamKarlMitchell added the enhancement New feature or request label Nov 29, 2018
@LiamKarlMitchell LiamKarlMitchell self-assigned this Nov 29, 2018
@LiamKarlMitchell
Copy link
Owner Author

LiamKarlMitchell commented Nov 29, 2018

Also add an ignoreIfMatched boolean.
I have a bunch of historical timeEntries that I would tag as "tracked" and I'de like to do a full sync of the month to get anything I missed in the interim.

Would also be a good idea to have.
useExactSummary = true
and overrideBillable = true

@LiamKarlMitchell
Copy link
Owner Author

Would also be good to have flags to apply it in circumstances, e.g No Issue Number found, Task not Found, PID not found.

LiamKarlMitchell added a commit that referenced this issue Dec 3, 2018
Redirect Filter added #1
Has a way to skip entry if filter matched, and deletes previous entry if skipped.
Fixed error with the date time from last commit.
A DEBUG tag will now breakpoint in the time entry processing and filter processing logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant