-
Notifications
You must be signed in to change notification settings - Fork 11
[WIP] Make checking optional for dependent encoding profiles #162
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
15 commits
Select commit
Hold shift + click to select a range
6194325
prepare db and model for skipping subencoding checks
zuntrax a367515
add migration for skipping subencoding checks
zuntrax 1f9eae3
add checkboxes for skip_on_dependent to state config view
zuntrax 48a2399
isSkippable in state model
zuntrax 5cbde77
fix isSkippable
zuntrax d8e55c1
change wording: subticket -> dependent profile
zuntrax 8e84443
move explanation to title
zuntrax 239ff00
more title text
zuntrax 1f000bd
change state settings view to one column layout
zuntrax d654064
make checkbox columns bigger in state settings view
zuntrax 0a861a7
center checkboxes in their columns in state settings view
zuntrax 2d9d669
center some column titles in state settings view
zuntrax 99268b9
only show needed headings in state settings view
zuntrax da5eeed
hide tooltips for hidden column headers in state config view
zuntrax 4b07689
Enhance layout
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
152 changes: 152 additions & 0 deletions
152
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
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_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 | ||
|
|
@@ -19,7 +19,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 | ||
|
Member
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. Like with other properties before, for performance improvements a column "is_master" in tbl_ticket filled on INSERT e.g. using a trigger might be useful. |
||
| 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; | ||
|
|
@@ -30,7 +39,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 +56,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 +114,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 +129,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_project_id, param_ticket_type, ret, param_ticket_id); | ||
| IF NOT FOUND THEN | ||
| ret := NULL; | ||
| EXIT; | ||
|
|
||
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
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.
Mh, not really convinced having that extra parameter is a good idea.
Before this change, the function was generic, independent of a specific ticket, hence all the parameters to answer the question at hand. But now it's for a single ticket, so you could go ahead and just have ticket_id as only parameter, since all the other information is stored in the database as well.
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.
What do you suggest? Moving to
ticket_idas only parameter or switching toencoding_profile_[version_]_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.
Both would work. I don't have a strong opinion on this.
Are there any callers, where no ticket_id is available or hard to determine?
I'm all for simplifying, if possible.
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.
This should behave the same way as the old function when calling, without
ticket_id, but we should check that again.