Repository navigation
feat(FOUR-30668): add API_FAST_TASK fast path for V1.1 task show #9097
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
Open
gproly
wants to merge
10
commits into
develop
Choose a base branch
from
feature/FOUR-30668
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d0d33f
feat(FOUR-30668): add API_FAST_TASK fast path for V1.1 task show
gproly a24306a
test(FOUR-30668): stabilize V1_1 PHPUnit timing and saved-search asse…
gproly 30560c6
refactor(FOUR-30668): hydrate request data on fast task show only
gproly 41ca5ed
chore(FOUR-30668): restore ProcessVariableControllerTest from develop
gproly 89245de
chore(FOUR-30668): align DataManagerTest with develop
gproly d1b4ecb
Merge branch 'develop' into feature/FOUR-30668
gproly 8376e37
refactor(FOUR-30668): rename fast task flag and align requestor on sh…
gproly e10bc8e
Merge branch 'develop' into feature/FOUR-30668
gproly 458df49
test(FOUR-30668): relax showFast timing ratio default for CI
gproly de64f20
test(FOUR-30668): raise showFast timing ratio default to 0.66
gproly 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace ProcessMaker\Repositories; | ||
|
|
||
| use Illuminate\Support\Facades\DB; | ||
| use ProcessMaker\Models\Process; | ||
| use ProcessMaker\Models\ProcessRequest; | ||
| use ProcessMaker\Models\ProcessRequestToken; | ||
| use ProcessMaker\Models\User; | ||
|
|
||
| class TaskV11ShowFastRepository | ||
| { | ||
| private const USER_COLUMNS = [ | ||
| 'id', 'uuid', 'email', 'firstname', 'lastname', 'username', 'status', | ||
| 'address', 'city', 'state', 'postal', 'country', 'phone', 'fax', 'cell', | ||
| 'title', 'birthdate', 'timezone', 'datetime_format', 'language', 'meta', | ||
| 'is_administrator', 'expires_at', 'loggedin_at', 'created_at', 'updated_at', | ||
| 'delegation_user_id', 'manager_id', 'schedule', 'avatar', | ||
| ]; | ||
|
|
||
| public function findForShow(int $taskId): ProcessRequestToken | ||
| { | ||
| $token = ProcessRequestToken::query()->where('id', $taskId)->firstOrFail(); | ||
|
|
||
| $row = DB::selectOne( | ||
| 'SELECT id, uuid, process_id, user_id, parent_request_id, status, do_not_sanitize, errors, | ||
| completed_at, initiated_at, created_at, updated_at, case_title, case_number, callable_id, | ||
| process_version_id, name | ||
| FROM process_requests | ||
| WHERE id = ? | ||
| LIMIT 1', | ||
| [$token->process_request_id] | ||
| ); | ||
|
|
||
| $processRequest = new ProcessRequest(); | ||
| $processRequest->setRawAttributes((array) $row, true); | ||
| $processRequest->exists = true; | ||
| $token->setRelation('processRequest', $processRequest); | ||
|
|
||
| if ($token->user_id) { | ||
| $user = User::query()->select(self::USER_COLUMNS)->find($token->user_id); | ||
| $token->setRelation('user', $user); | ||
| } | ||
|
|
||
| if ($processRequest->user_id) { | ||
| $requestor = User::query()->select(self::USER_COLUMNS)->find($processRequest->user_id); | ||
| $processRequest->setRelation('user', $requestor); | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| if ($token->process_id) { | ||
| $process = Process::query()->select(['id', 'name'])->find($token->process_id); | ||
| $token->setRelation('process', $process); | ||
| } | ||
|
|
||
| $token->load(['draft' => function ($query) { | ||
| $query->select(['id', 'task_id', 'data']); | ||
| }]); | ||
|
|
||
| return $token; | ||
| } | ||
|
|
||
| /** | ||
| * Load process_requests.data onto the lean processRequest relation (fast show only). | ||
| */ | ||
| public function hydrateProcessRequestData(ProcessRequestToken $token): void | ||
| { | ||
| $processRequest = $token->processRequest; | ||
| if (!$processRequest || !$processRequest->getKey()) { | ||
| return; | ||
| } | ||
|
|
||
| if (array_key_exists('data', $processRequest->getAttributes())) { | ||
| return; | ||
| } | ||
|
|
||
| $raw = DB::table('process_requests') | ||
| ->where('id', $processRequest->getKey()) | ||
| ->value('data'); | ||
|
|
||
| $data = []; | ||
| if (is_array($raw)) { | ||
| $data = $raw; | ||
| } elseif (is_string($raw)) { | ||
| $data = json_decode($raw, true) ?? []; | ||
| } | ||
|
|
||
| $processRequest->setAttribute('data', $data); | ||
| } | ||
| } | ||
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.
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.
Uh oh!
There was an error while loading. Please reload this page.