-
Notifications
You must be signed in to change notification settings - Fork 11
[WIP] Make checking optional for dependent encoding profiles #171
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
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c959b10
prepare db and model for skipping subencoding checks
zuntrax abc24c3
add migration for skipping subencoding checks
zuntrax 1b95d4b
add checkboxes for skip_on_dependent to state config view
zuntrax ca2bc37
isSkippable in state model
zuntrax 94cd450
fix isSkippable
zuntrax 7bf7ed1
change wording: subticket -> dependent profile
zuntrax 4e5990e
move explanation to title
zuntrax 5b5347b
more title text
zuntrax 5ec3e8a
change state settings view to one column layout
zuntrax d2ee8bf
make checkbox columns bigger in state settings view
zuntrax a3d3eba
center checkboxes in their columns in state settings view
zuntrax 46c7917
center some column titles in state settings view
zuntrax f137a07
only show needed headings in state settings view
zuntrax 31f5430
hide tooltips for hidden column headers in state config view
zuntrax c030243
Enhance layout
zuntrax b5eacb9
WIP ticket_state_next params
zuntrax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ BEGIN; | |
|
|
||
| SET ROLE TO postgres; | ||
|
|
||
| CREATE OR REPLACE FUNCTION ticket_state_next(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_state enum_ticket_state) | ||
| CREATE OR REPLACE FUNCTION ticket_state_next(param_ticket_id bigint) | ||
| RETURNS TABLE(ticket_state enum_ticket_state, service_executable boolean) AS | ||
| $$ | ||
| DECLARE | ||
|
|
@@ -11,17 +11,61 @@ BEGIN | |
| SELECT | ||
| pts.ticket_state, pts.service_executable | ||
| FROM | ||
| tbl_ticket_state ts1 | ||
| tbl_ticket t | ||
| JOIN | ||
| tbl_project_ticket_state pts ON pts.ticket_type = ts1.ticket_type AND pts.ticket_state = ts1.ticket_state | ||
| tbl_ticket_state ts_this ON ts_this.ticket_type = t.ticket_type AND ts_this.ticket_state = t.ticket_state | ||
| JOIN | ||
| tbl_ticket_state ts2 ON ts1.ticket_type = ts2.ticket_type AND ts1.sort > ts2.sort | ||
| tbl_project_ticket_state pts ON pts.project_id = t.project_id AND pts.ticket_type = t.ticket_type | ||
| JOIN | ||
| tbl_ticket_state ts_other ON ts_other.ticket_type = pts.ticket_type AND ts_other.ticket_state = pts.ticket_state | ||
| WHERE | ||
| pts.project_id = param_project_id AND | ||
| ts2.ticket_type = param_ticket_type AND | ||
| ts2.ticket_state = param_ticket_state | ||
| ORDER BY | ||
| ts1.sort ASC | ||
| t.id = param_ticket_id AND | ||
| ts_other.sort > ts_this.sort AND | ||
| (pts.skip_on_dependent = FALSE OR | ||
| ( /* is master encoding ticket */ | ||
| SELECT ep.depends_on | ||
| FROM tbl_ticket t | ||
| JOIN tbl_encoding_profile_version epv ON epv.id = t.encoding_profile_version_id | ||
| JOIN tbl_encoding_profile ep ON ep.id = epv.encoding_profile_id | ||
| WHERE t.id = param_ticket_id | ||
| ) IS NULL ) | ||
| ORDER BY ts_other.sort ASC | ||
| LIMIT 1; | ||
| IF NOT FOUND THEN | ||
| RETURN QUERY SELECT NULL::enum_ticket_state, false; | ||
| END IF; | ||
| END | ||
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| CREATE OR REPLACE FUNCTION ticket_state_previous(param_ticket_id bigint) | ||
| RETURNS TABLE(ticket_state enum_ticket_state, service_executable boolean) AS | ||
| $$ | ||
| DECLARE | ||
| BEGIN | ||
| RETURN QUERY | ||
| SELECT | ||
| pts.ticket_state, pts.service_executable | ||
| FROM | ||
| tbl_ticket t | ||
| JOIN | ||
| tbl_ticket_state ts_this ON ts_this.ticket_type = t.ticket_type AND ts_this.ticket_state = t.ticket_state | ||
| JOIN | ||
| tbl_project_ticket_state pts ON pts.project_id = t.project_id AND pts.ticket_type = t.ticket_type | ||
| JOIN | ||
| tbl_ticket_state ts_other ON ts_other.ticket_type = pts.ticket_type AND ts_other.ticket_state = pts.ticket_state | ||
| WHERE | ||
| t.id = param_ticket_id AND | ||
| ts_other.sort < ts_this.sort AND | ||
| (pts.skip_on_dependent = FALSE OR | ||
| ( /* is master encoding ticket */ | ||
| SELECT ep.depends_on | ||
| FROM tbl_ticket t | ||
| JOIN tbl_encoding_profile_version epv ON epv.id = t.encoding_profile_version_id | ||
| JOIN tbl_encoding_profile ep ON ep.id = epv.encoding_profile_id | ||
| WHERE t.id = param_ticket_id | ||
| ) IS NULL ) | ||
| ORDER BY ts_other.sort DESC | ||
| LIMIT 1; | ||
| IF NOT FOUND THEN | ||
| RETURN QUERY SELECT NULL::enum_ticket_state, false; | ||
|
|
@@ -30,7 +74,7 @@ END | |
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| CREATE OR REPLACE FUNCTION ticket_state_previous(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_state enum_ticket_state) | ||
| CREATE OR REPLACE FUNCTION ticket_state_previous(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_state enum_ticket_state, param_ticket_id bigint default NULL) | ||
| RETURNS TABLE(ticket_state enum_ticket_state, service_executable boolean) AS | ||
| $$ | ||
| DECLARE | ||
|
|
@@ -47,7 +91,16 @@ BEGIN | |
| WHERE | ||
| pts.project_id = param_project_id AND | ||
| ts2.ticket_type = param_ticket_type AND | ||
| ts2.ticket_state = param_ticket_state | ||
| ts2.ticket_state = param_ticket_state AND | ||
| (pts.skip_on_dependent = false OR | ||
| ( /* is master encoding ticket */ | ||
| SELECT ep.depends_on | ||
| FROM tbl_ticket t | ||
| JOIN tbl_encoding_profile_version epv ON epv.id = t.encoding_profile_version_id | ||
| JOIN tbl_encoding_profile ep ON ep.id = epv.encoding_profile_id | ||
| WHERE t.id = param_ticket_id | ||
| ) IS NULL | ||
| ) | ||
| ORDER BY | ||
| ts1.sort DESC | ||
| LIMIT 1; | ||
|
|
@@ -96,7 +149,7 @@ END | |
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| CREATE OR REPLACE FUNCTION ticket_state_commence(param_project_id bigint, param_ticket_type enum_ticket_type) | ||
| CREATE OR REPLACE FUNCTION ticket_state_commence(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_id bigint) | ||
| RETURNS enum_ticket_state AS | ||
| $$ | ||
| DECLARE | ||
|
|
@@ -111,7 +164,7 @@ BEGIN | |
| ret := (SELECT ticket_state_initial(param_project_id, param_ticket_type)); | ||
|
|
||
| WHILE ret IS NOT NULL LOOP | ||
| SELECT * INTO next_state FROM ticket_state_next(param_project_id, param_ticket_type, ret); | ||
| SELECT * INTO next_state FROM ticket_state_next(param_ticket_id); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: eliminating ret from parameters will probably produce endless loops. |
||
| IF NOT FOUND THEN | ||
| ret := NULL; | ||
| EXIT; | ||
|
|
@@ -129,4 +182,4 @@ END | |
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| COMMIT; | ||
| COMMIT; | ||
152 changes: 152 additions & 0 deletions
152
src/Application/Migrations/__tmp_upgrade_tables-2017-08-21-subencoding-skips.sql
This file contains hidden or 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,152 @@ | ||
| BEGIN; | ||
|
|
||
| SET ROLE TO postgres; | ||
|
|
||
| DROP FUNCTION ticket_state_next(bigint, enum_ticket_type, enum_ticket_state); | ||
| CREATE OR REPLACE FUNCTION ticket_state_next(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_state enum_ticket_state, param_ticket_id bigint default NULL) | ||
| RETURNS TABLE(ticket_state enum_ticket_state, service_executable boolean) AS | ||
| $$ | ||
| DECLARE | ||
| BEGIN | ||
| RETURN QUERY | ||
| SELECT | ||
| pts.ticket_state, pts.service_executable | ||
| FROM | ||
| tbl_ticket_state ts1 | ||
| JOIN | ||
| tbl_project_ticket_state pts ON pts.ticket_type = ts1.ticket_type AND pts.ticket_state = ts1.ticket_state | ||
| JOIN | ||
| tbl_ticket_state ts2 ON ts1.ticket_type = ts2.ticket_type AND ts1.sort > ts2.sort | ||
| WHERE | ||
| pts.project_id = param_project_id AND | ||
| ts2.ticket_type = param_ticket_type AND | ||
| ts2.ticket_state = param_ticket_state AND | ||
| (pts.skip_on_dependent = false OR | ||
| ( /* is master encoding ticket */ | ||
| SELECT ep.depends_on | ||
| FROM tbl_ticket t | ||
| JOIN tbl_encoding_profile_version epv ON epv.id = t.encoding_profile_version_id | ||
| JOIN tbl_encoding_profile ep ON ep.id = epv.encoding_profile_id | ||
| WHERE t.id = param_ticket_id | ||
| ) IS NULL | ||
| ) | ||
| ORDER BY | ||
| ts1.sort ASC | ||
| LIMIT 1; | ||
| IF NOT FOUND THEN | ||
| RETURN QUERY SELECT NULL::enum_ticket_state, false; | ||
| END IF; | ||
| END | ||
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| DROP FUNCTION ticket_state_previous(bigint, enum_ticket_type, enum_ticket_state); | ||
| CREATE OR REPLACE FUNCTION ticket_state_previous(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_state enum_ticket_state, param_ticket_id bigint default NULL) | ||
| RETURNS TABLE(ticket_state enum_ticket_state, service_executable boolean) AS | ||
| $$ | ||
| DECLARE | ||
| BEGIN | ||
| RETURN QUERY | ||
| SELECT | ||
| pts.ticket_state, pts.service_executable | ||
| FROM | ||
| tbl_ticket_state ts1 | ||
| JOIN | ||
| tbl_project_ticket_state pts ON pts.ticket_type = ts1.ticket_type AND pts.ticket_state = ts1.ticket_state | ||
| JOIN | ||
| tbl_ticket_state ts2 ON ts1.ticket_type = ts2.ticket_type AND ts1.sort < ts2.sort | ||
| WHERE | ||
| pts.project_id = param_project_id AND | ||
| ts2.ticket_type = param_ticket_type AND | ||
| ts2.ticket_state = param_ticket_state AND | ||
| (pts.skip_on_dependent = false OR | ||
| ( /* is master encoding ticket */ | ||
| SELECT ep.depends_on | ||
| FROM tbl_ticket t | ||
| JOIN tbl_encoding_profile_version epv ON epv.id = t.encoding_profile_version_id | ||
| JOIN tbl_encoding_profile ep ON ep.id = epv.encoding_profile_id | ||
| WHERE t.id = param_ticket_id | ||
| ) IS NULL | ||
| ) | ||
| ORDER BY | ||
| ts1.sort DESC | ||
| LIMIT 1; | ||
| IF NOT FOUND THEN | ||
| RETURN QUERY SELECT NULL::enum_ticket_state, false; | ||
| END IF; | ||
| END | ||
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| DROP FUNCTION ticket_state_commence(bigint, enum_ticket_type); | ||
| CREATE OR REPLACE FUNCTION ticket_state_commence(param_project_id bigint, param_ticket_type enum_ticket_type, param_ticket_id bigint) | ||
| RETURNS enum_ticket_state AS | ||
| $$ | ||
| DECLARE | ||
| ret enum_ticket_state; | ||
| next_state record; | ||
| BEGIN | ||
| -- special case: meta ticket, since it has no serviceable states | ||
| IF param_ticket_type = 'meta' THEN | ||
| RETURN 'staged'::enum_ticket_state; | ||
| END IF; | ||
|
|
||
| ret := (SELECT ticket_state_initial(param_project_id, param_ticket_type)); | ||
|
|
||
| WHILE ret IS NOT NULL LOOP | ||
| SELECT * INTO next_state FROM ticket_state_next(param_project_id, param_ticket_type, ret, param_ticket_id); | ||
| IF NOT FOUND THEN | ||
| ret := NULL; | ||
| EXIT; | ||
| END IF; | ||
|
|
||
| -- exit, if serviceable state is found | ||
| EXIT WHEN next_state.service_executable IS TRUE; | ||
|
|
||
| -- otherwise set current state as possible commence state | ||
| ret := next_state.ticket_state; | ||
| END LOOP; | ||
|
|
||
| RETURN ret; | ||
| END | ||
| $$ | ||
| LANGUAGE plpgsql; | ||
|
|
||
| CREATE OR REPLACE FUNCTION update_ticket_next_state() | ||
| RETURNS trigger AS | ||
| $BODY$ | ||
| DECLARE | ||
| next_state record; | ||
| BEGIN | ||
| next_state := ticket_state_next(NEW.project_id, NEW.ticket_type, NEW.ticket_state, NEW.id); | ||
|
|
||
| NEW.ticket_state_next := next_state.ticket_state; | ||
| NEW.service_executable := next_state.service_executable; | ||
|
|
||
| RETURN NEW; | ||
| END | ||
| $BODY$ | ||
| LANGUAGE plpgsql VOLATILE; | ||
|
|
||
| CREATE OR REPLACE FUNCTION update_all_tickets_progress_and_next_state(param_project_id bigint) | ||
| RETURNS VOID AS | ||
| $BODY$ | ||
| BEGIN | ||
|
|
||
| UPDATE tbl_ticket t SET | ||
| (progress, ticket_state_next, service_executable) | ||
| = (tp, (n).ticket_state, (n).service_executable) | ||
| FROM ( | ||
| SELECT id, ticket_state_next(t2.project_id, t2.ticket_type, t2.ticket_state, t2.id) AS n, ticket_progress(t2.id) as tp | ||
| FROM tbl_ticket t2 | ||
| WHERE t2.project_id = param_project_id AND param_project_id IS NOT NULL | ||
| ) AS x | ||
| WHERE t.id = x.id; | ||
|
|
||
| END; | ||
| $BODY$ | ||
| LANGUAGE plpgsql VOLATILE; | ||
|
|
||
| ALTER TABLE tbl_project_ticket_state ADD COLUMN skip_on_dependent BOOLEAN NOT NULL DEFAULT FALSE; | ||
|
|
||
| COMMIT; |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jjeising @pegro
Continuing discussion
This doesn't work,
Ticket::expandRecordingcallsTicket::queryPreviousStatewithstate='preparing', differing from the current state of the ticket, which would usually becutting.I'd suggest using an additional parameter
skip_dependent DEFAULT FALSEand adding a new function (maybe with a trigger as suggested)ticket_is_masterto pass that in from outside and keep this function completely ticket agnostic.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said before, if determining a next/previous ticket state depends on more as just the ticket type and state, I'm fine with changing all functions to just requiring a ticket_id and migrate all users accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new issue here is: ticket_state_next is also used with a state different from the current state of the ticket (with
param_ticket_id).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to query for all possible ticket states of the current ticket, I would then add a second optional parameter param_state as a state of reference which defaults to the current ticket state.
So you could call ticket_state_next(param_ticket_id) to get the next state in relation to the current state. And you could call ticket_state_next(param_ticket_id, param_ticket_state) to query for the next state the ticket would get advanced to, if the ticket would be in state param_ticket_state.
At least that's what I'd suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zuntrax That's what we discussed previously, can you implement that?