|
56667
|
1971
|
43
|
2026-05-19T08:16:03.344384+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178563344_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptDto.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormViewINavicareCodeLaravelKeractorFV faVsco. PhostormViewINavicareCodeLaravelKeractorFV faVsco.js°9 JY-20676-delete-report-related-objectsroledeyC ActivityController.ong© AskAnythingController.php© AskAnythingPromptService.php© SetDefaultAvatarListener.phpOAskAnytningPromptuto.onpxpip api_vc.ong(C) AutomatedReport.pnp© SetupCalendarSync.php© AskJiminnyReportsController.phgC)AskAnythingPror© AskAnythingPrompt.php x © Search.phg© SetupMailSync.phpclass AskAnyuninorronor excenas nodeu© Syncintercom.php© SyncPlanhat.php© SyncUserPilot.phpcvalicalesencinamessace.on26 61orotected svnsiole =c)ValidatesencinaNottication.ono> C WebhookE.aitkeepc) ChangeLoaContextCorrelationid.ohp> L Maili> D McDv D Modelsv Activity32 (011protected function casts): arrayt...public function owner(): Relations\BelongsTo{...}C) Activitvimoort.ohoC) ActivitvProcessinaState.ohopublic function get0wner: ?Userf...}C) ActivitvSummarvLoa.ohv© ActivityUploadSetting.php© AvailabilityNotification.php© CoachRequest.php(C) Comment nhnpublic function userPrompts: Relations \HasMany{...}(c) Exoor.onppublic function automatedReports(: Relations HasMany{...}©) ExportLog.onpe exponloken.onopublic function getUuid0: string{...}© Log.phpMessage.ongpublic tunction getldo: int...(e) Moment.phpc Nore.onopublic function get0wnerIdO: 2intf...}ParicioantData.ongc) Participantspeech.phgc) Play.phppublic function getTarget(): AskAnvthingPromptTargets...}C) ProviderUser.phpc) Search.ohrC) Search-ilter.oho* Areturn bool(C) Share,oho(C) Snaoshot.oho15 usades(C) Stats.ohopublic function isDefaultPrompt: boolf...}C) StatsSoecification.ohvc) Subscrintion.nhr© SubscriptionSet.php(C) TonicTriaaer nhn.public function getTitle: stringf...}public function getContent: string{...}(C) Transcrintion.nhn(C) TranscrintionSummarv nhnlM Aiv D AskAnythingC AckinvthinaDromnt nhn(@AckAnvthinaPromotTarget.php© UserAskAnythingPrompt.php• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:02AskJiminnyReportActivityServiceTest v+0 ..= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >1181[130135136 Gt ›146 @t>150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function __construct(UserRepository $userRepository)f...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection...hpublic function toArray@: array{...hprivate function getOptions(): array{...}public function getValue: array{...}lprivate function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}ariec for other lanquades (todav 10-00)CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAucomatedkeport exists. Ine saved-seareh list enapolnt now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Toams 66-1UTF.8Po 4 spaces...
|
NULL
|
8172844541451279130
|
NULL
|
click
|
ocr
|
NULL
|
PhostormViewINavicareCodeLaravelKeractorFV faVsco. PhostormViewINavicareCodeLaravelKeractorFV faVsco.js°9 JY-20676-delete-report-related-objectsroledeyC ActivityController.ong© AskAnythingController.php© AskAnythingPromptService.php© SetDefaultAvatarListener.phpOAskAnytningPromptuto.onpxpip api_vc.ong(C) AutomatedReport.pnp© SetupCalendarSync.php© AskJiminnyReportsController.phgC)AskAnythingPror© AskAnythingPrompt.php x © Search.phg© SetupMailSync.phpclass AskAnyuninorronor excenas nodeu© Syncintercom.php© SyncPlanhat.php© SyncUserPilot.phpcvalicalesencinamessace.on26 61orotected svnsiole =c)ValidatesencinaNottication.ono> C WebhookE.aitkeepc) ChangeLoaContextCorrelationid.ohp> L Maili> D McDv D Modelsv Activity32 (011protected function casts): arrayt...public function owner(): Relations\BelongsTo{...}C) Activitvimoort.ohoC) ActivitvProcessinaState.ohopublic function get0wner: ?Userf...}C) ActivitvSummarvLoa.ohv© ActivityUploadSetting.php© AvailabilityNotification.php© CoachRequest.php(C) Comment nhnpublic function userPrompts: Relations \HasMany{...}(c) Exoor.onppublic function automatedReports(: Relations HasMany{...}©) ExportLog.onpe exponloken.onopublic function getUuid0: string{...}© Log.phpMessage.ongpublic tunction getldo: int...(e) Moment.phpc Nore.onopublic function get0wnerIdO: 2intf...}ParicioantData.ongc) Participantspeech.phgc) Play.phppublic function getTarget(): AskAnvthingPromptTargets...}C) ProviderUser.phpc) Search.ohrC) Search-ilter.oho* Areturn bool(C) Share,oho(C) Snaoshot.oho15 usades(C) Stats.ohopublic function isDefaultPrompt: boolf...}C) StatsSoecification.ohvc) Subscrintion.nhr© SubscriptionSet.php(C) TonicTriaaer nhn.public function getTitle: stringf...}public function getContent: string{...}(C) Transcrintion.nhn(C) TranscrintionSummarv nhnlM Aiv D AskAnythingC AckinvthinaDromnt nhn(@AckAnvthinaPromotTarget.php© UserAskAnythingPrompt.php• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:02AskJiminnyReportActivityServiceTest v+0 ..= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >1181[130135136 Gt ›146 @t>150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function __construct(UserRepository $userRepository)f...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection...hpublic function toArray@: array{...hprivate function getOptions(): array{...}public function getValue: array{...}lprivate function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}ariec for other lanquades (todav 10-00)CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAucomatedkeport exists. Ine saved-seareh list enapolnt now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Toams 66-1UTF.8Po 4 spaces...
|
56665
|
NULL
|
NULL
|
NULL
|
|
56666
|
1970
|
34
|
2026-05-19T08:16:03.344422+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178563344_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptDto.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:02Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
1317409121578208609
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:02Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56669
|
1971
|
44
|
2026-05-19T08:16:06.881371+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178566881_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-351575931525056321
|
-8132358351805502526
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
PhostormVIeWINavicarecodeKeractorTOOISWindowFV faVsco.js?9 JY-20676-delete-report-related-objectsProiect vCActivityController.ongphp api.php© AskAnythingController.phpD AskAnything© AskAnythingPromptService.php XAskAnytningPromptuto.onpxpip api_vc.ong(C) AutomatedReport.pnpv D Dtos©) AskAnythingPromptServiceTest.php© AskAnythingPromptDto.phpD events©) AsKAnytningPromptservice.ongchistorvservice.ono0 AskJiminnyAiD AWSw cachew country1 Database→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystem• беско[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasIM Nudae1M Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistProphetDronhotAfM DrosnorWorkeMAuoncnamespace Jiminny Component ASkAnything dtos:use JaminnyModels AskAnvthinoAskanvthinopromotTarget:class AskAnythingPromptdtopublic function constructdpublic string $id,public string Stitle,public string Scontent,public AskAnythingPromptTarget $targetpublic ?string $ownerId = null,public ?array $shareUsers = null,public ?array $shareGroups = nullpubLic bool snaskeporus = talse.pubLic tunccion coArray. array'1d' => Sth1S->1d'content' => sthis->content.'target' => Sthis->target->namelif (Sthis->ownerId |== null) {Sdatallowner id' = Sthis->ownerid:tCthis->sharelisens 1== nuubSdatal'share usens'l = Sthis->sharellsens.if ($this->shareGroups |== null) {Sdatali chane anouncll = Cthice-schanofnaune.notunn Sdata.© Search.phpoc for other lanquades (todav 10-00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:06AskJiminnyReportActivityServiceTest v+O •VIAV= custom.log= laravel.log« SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118131135136 Gt ›146 @t>150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}lprivate function getDefaultValue@: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything_promot id' = null. "status' = falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teams20-8UTF.8Po 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56668
|
1970
|
35
|
2026-05-19T08:16:06.903731+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178566903_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.016666668,"height":0.02111111},"on_screen":false,"role_description":"text"}]...
|
2673033699231265117
|
-8132358351805502526
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:06Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
56666
|
NULL
|
NULL
|
NULL
|
|
56670
|
1970
|
36
|
2026-05-19T08:16:08.740567+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178568740_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\AskAnything;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
class AskAnythingPromptService
{
public function __construct(
private readonly AskAnythingRepository $askAnythingRepository,
private readonly UserRepository $userRepository,
private readonly GroupRepositoryInterface $groupRepository,
) {
}
/**
* @return array<AskAnythingPromptDto>
*/
public function get(User $user, AskAnythingPromptTarget $target): array
{
$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(
$user,
$target
);
$promptDtos = [];
foreach ($prompts as $prompt) {
$ownerUuid = null;
if ($prompt->getOwner() !== null) {
$ownerUuid = $prompt->getOwner()->getUuid();
}
$shareUsers = null;
$shareGroups = null;
// Provide users and groups only if owner of the prompt is current user
if ($prompt->getOwnerId() === $user->getId()) {
[$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);
}
$promptDtos[] = new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$ownerUuid,
$shareUsers,
$shareGroups,
$prompt->has_reports,
);
}
return $promptDtos;
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*/
public function create(
User $user,
string $title,
string $content,
AskAnythingPromptTarget $target,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
$prompt = $this->askAnythingRepository->createPrompt(
$user,
$target,
$title,
$content,
$shareUsers,
$shareGroups,
);
return new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$prompt->has_reports,
);
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*
* @throws InvalidArgumentException
*/
public function edit(
AskAnythingPrompt $prompt,
User $user,
string $title,
string $content,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
$newPrompt = $this->askAnythingRepository->createPrompt(
$user,
$prompt->getTarget(),
$title,
$content,
$shareUsers,
$shareGroups,
);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$newPrompt = $this->askAnythingRepository->editPrompt(
$prompt,
$title,
$content,
$shareUsers,
$shareGroups,
);
} else {
throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());
}
return new AskAnythingPromptDto(
$newPrompt->getUuid(),
$newPrompt->getTitle(),
$newPrompt->getContent(),
$newPrompt->getTarget(),
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$newPrompt->has_reports,
);
}
public function delete(
AskAnythingPrompt $prompt,
User $user
): AskAnythingPrompt {
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$userPrompt?->delete();
// For each relation, re-create the prompt for the receiver as their own
$this->recreatePromptsForEachRelation($prompt);
// Finally, delete the prompt
$this->deletePromptIfNoRelations($prompt);
} else {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);
// If the prompt is shared directly with the user, then "unshare" it
if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {
$userPrompt->delete();
$this->deletePromptIfNoRelations($prompt);
} elseif ($groupPrompt instanceof UserAskAnythingPrompt) {
// If the prompt is shared with the user and the group, then hide it for this user
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} else {
throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());
}
}
return $prompt;
}
public function reorder(
User $user,
array $promptUuids,
): void {
foreach ($promptUuids as $index => $promptUuid) {
$prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);
$this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);
}
}
/**
* @param AskAnythingPrompt $prompt
*
* @return array[array<string>, array<string>]
*/
private function getReceiverUuids(AskAnythingPrompt $prompt): array
{
$shareUsers = [];
$shareGroups = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {
$shareUsers[] = $sharedUser->getUuid();
}
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
$shareGroups[] = $sharedGroup->getUuid();
}
}
return [$shareUsers, $shareGroups];
}
private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void
{
if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {
// Disable and orphan any AutomatedReports that use this prompt
$prompt->automatedReports()->withTrashed()->update([
'ask_anything_prompt_id' => null,
'status' => false,
]);
// Delete only if there are no other relations to it.
$this->askAnythingRepository->deletePrompt($prompt);
}
}
private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void
{
[$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);
$this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);
}
private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array
{
$sharedUsersIds = [];
$sharedUsersRemovedIds = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedPrompt->isRemoved() === true) {
$sharedUsersRemovedIds[] = $sharedUser->getId();
}
if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {
$sharedUsersIds[] = $sharedUser->getId();
$this->askAnythingRepository->createPrompt(
$sharedUser,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
$sharedPrompt->delete();
}
}
return [$sharedUsersIds, $sharedUsersRemovedIds];
}
private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void
{
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
foreach ($sharedGroup->getMembers() as $member) {
if (! in_array($member->getId(), $sharedUsersIds)
&& ! in_array($member->getId(), $sharedUsersRemovedIds)) {
$sharedUsersIds[] = $member->getId();
$this->askAnythingRepository->createPrompt(
$member,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
}
}
$sharedPrompt->delete();
}
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.016666668,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.016666668,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.014583333,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\AskAnything;\n\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\n\nclass AskAnythingPromptService\n{\n public function __construct(\n private readonly AskAnythingRepository $askAnythingRepository,\n private readonly UserRepository $userRepository,\n private readonly GroupRepositoryInterface $groupRepository,\n ) {\n }\n\n /**\n * @return array<AskAnythingPromptDto>\n */\n public function get(User $user, AskAnythingPromptTarget $target): array\n {\n $prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(\n $user,\n $target\n );\n\n $promptDtos = [];\n foreach ($prompts as $prompt) {\n $ownerUuid = null;\n if ($prompt->getOwner() !== null) {\n $ownerUuid = $prompt->getOwner()->getUuid();\n }\n $shareUsers = null;\n $shareGroups = null;\n\n // Provide users and groups only if owner of the prompt is current user\n if ($prompt->getOwnerId() === $user->getId()) {\n [$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);\n }\n\n $promptDtos[] = new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $ownerUuid,\n $shareUsers,\n $shareGroups,\n $prompt->has_reports,\n );\n }\n\n return $promptDtos;\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n */\n public function create(\n User $user,\n string $title,\n string $content,\n AskAnythingPromptTarget $target,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n $prompt = $this->askAnythingRepository->createPrompt(\n $user,\n $target,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n\n return new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $prompt->has_reports,\n );\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n *\n * @throws InvalidArgumentException\n */\n public function edit(\n AskAnythingPrompt $prompt,\n User $user,\n string $title,\n string $content,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n\n $newPrompt = $this->askAnythingRepository->createPrompt(\n $user,\n $prompt->getTarget(),\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $newPrompt = $this->askAnythingRepository->editPrompt(\n $prompt,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } else {\n throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());\n }\n\n return new AskAnythingPromptDto(\n $newPrompt->getUuid(),\n $newPrompt->getTitle(),\n $newPrompt->getContent(),\n $newPrompt->getTarget(),\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $newPrompt->has_reports,\n );\n }\n\n public function delete(\n AskAnythingPrompt $prompt,\n User $user\n ): AskAnythingPrompt {\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $userPrompt?->delete();\n // For each relation, re-create the prompt for the receiver as their own\n $this->recreatePromptsForEachRelation($prompt);\n\n // Finally, delete the prompt\n $this->deletePromptIfNoRelations($prompt);\n } else {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);\n\n // If the prompt is shared directly with the user, then \"unshare\" it\n if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {\n $userPrompt->delete();\n $this->deletePromptIfNoRelations($prompt);\n } elseif ($groupPrompt instanceof UserAskAnythingPrompt) {\n // If the prompt is shared with the user and the group, then hide it for this user\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } else {\n throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());\n }\n }\n\n return $prompt;\n }\n\n public function reorder(\n User $user,\n array $promptUuids,\n ): void {\n foreach ($promptUuids as $index => $promptUuid) {\n $prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);\n $this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);\n }\n }\n\n /**\n * @param AskAnythingPrompt $prompt\n *\n * @return array[array<string>, array<string>]\n */\n private function getReceiverUuids(AskAnythingPrompt $prompt): array\n {\n $shareUsers = [];\n $shareGroups = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $shareUsers[] = $sharedUser->getUuid();\n }\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n $shareGroups[] = $sharedGroup->getUuid();\n }\n }\n\n return [$shareUsers, $shareGroups];\n }\n\n private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void\n {\n if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {\n // Disable and orphan any AutomatedReports that use this prompt\n $prompt->automatedReports()->withTrashed()->update([\n 'ask_anything_prompt_id' => null,\n 'status' => false,\n ]);\n\n // Delete only if there are no other relations to it.\n $this->askAnythingRepository->deletePrompt($prompt);\n }\n }\n\n private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void\n {\n [$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);\n $this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);\n }\n\n private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array\n {\n $sharedUsersIds = [];\n $sharedUsersRemovedIds = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedPrompt->isRemoved() === true) {\n $sharedUsersRemovedIds[] = $sharedUser->getId();\n }\n if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $sharedUsersIds[] = $sharedUser->getId();\n $this->askAnythingRepository->createPrompt(\n $sharedUser,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n $sharedPrompt->delete();\n }\n }\n\n return [$sharedUsersIds, $sharedUsersRemovedIds];\n }\n\n private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void\n {\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n foreach ($sharedGroup->getMembers() as $member) {\n if (! in_array($member->getId(), $sharedUsersIds)\n && ! in_array($member->getId(), $sharedUsersRemovedIds)) {\n $sharedUsersIds[] = $member->getId();\n $this->askAnythingRepository->createPrompt(\n $member,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n }\n }\n $sharedPrompt->delete();\n }\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\AskAnything;\n\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\n\nclass AskAnythingPromptService\n{\n public function __construct(\n private readonly AskAnythingRepository $askAnythingRepository,\n private readonly UserRepository $userRepository,\n private readonly GroupRepositoryInterface $groupRepository,\n ) {\n }\n\n /**\n * @return array<AskAnythingPromptDto>\n */\n public function get(User $user, AskAnythingPromptTarget $target): array\n {\n $prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(\n $user,\n $target\n );\n\n $promptDtos = [];\n foreach ($prompts as $prompt) {\n $ownerUuid = null;\n if ($prompt->getOwner() !== null) {\n $ownerUuid = $prompt->getOwner()->getUuid();\n }\n $shareUsers = null;\n $shareGroups = null;\n\n // Provide users and groups only if owner of the prompt is current user\n if ($prompt->getOwnerId() === $user->getId()) {\n [$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);\n }\n\n $promptDtos[] = new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $ownerUuid,\n $shareUsers,\n $shareGroups,\n $prompt->has_reports,\n );\n }\n\n return $promptDtos;\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n */\n public function create(\n User $user,\n string $title,\n string $content,\n AskAnythingPromptTarget $target,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n $prompt = $this->askAnythingRepository->createPrompt(\n $user,\n $target,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n\n return new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $prompt->has_reports,\n );\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n *\n * @throws InvalidArgumentException\n */\n public function edit(\n AskAnythingPrompt $prompt,\n User $user,\n string $title,\n string $content,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n\n $newPrompt = $this->askAnythingRepository->createPrompt(\n $user,\n $prompt->getTarget(),\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $newPrompt = $this->askAnythingRepository->editPrompt(\n $prompt,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } else {\n throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());\n }\n\n return new AskAnythingPromptDto(\n $newPrompt->getUuid(),\n $newPrompt->getTitle(),\n $newPrompt->getContent(),\n $newPrompt->getTarget(),\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $newPrompt->has_reports,\n );\n }\n\n public function delete(\n AskAnythingPrompt $prompt,\n User $user\n ): AskAnythingPrompt {\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $userPrompt?->delete();\n // For each relation, re-create the prompt for the receiver as their own\n $this->recreatePromptsForEachRelation($prompt);\n\n // Finally, delete the prompt\n $this->deletePromptIfNoRelations($prompt);\n } else {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);\n\n // If the prompt is shared directly with the user, then \"unshare\" it\n if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {\n $userPrompt->delete();\n $this->deletePromptIfNoRelations($prompt);\n } elseif ($groupPrompt instanceof UserAskAnythingPrompt) {\n // If the prompt is shared with the user and the group, then hide it for this user\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } else {\n throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());\n }\n }\n\n return $prompt;\n }\n\n public function reorder(\n User $user,\n array $promptUuids,\n ): void {\n foreach ($promptUuids as $index => $promptUuid) {\n $prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);\n $this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);\n }\n }\n\n /**\n * @param AskAnythingPrompt $prompt\n *\n * @return array[array<string>, array<string>]\n */\n private function getReceiverUuids(AskAnythingPrompt $prompt): array\n {\n $shareUsers = [];\n $shareGroups = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $shareUsers[] = $sharedUser->getUuid();\n }\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n $shareGroups[] = $sharedGroup->getUuid();\n }\n }\n\n return [$shareUsers, $shareGroups];\n }\n\n private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void\n {\n if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {\n // Disable and orphan any AutomatedReports that use this prompt\n $prompt->automatedReports()->withTrashed()->update([\n 'ask_anything_prompt_id' => null,\n 'status' => false,\n ]);\n\n // Delete only if there are no other relations to it.\n $this->askAnythingRepository->deletePrompt($prompt);\n }\n }\n\n private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void\n {\n [$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);\n $this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);\n }\n\n private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array\n {\n $sharedUsersIds = [];\n $sharedUsersRemovedIds = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedPrompt->isRemoved() === true) {\n $sharedUsersRemovedIds[] = $sharedUser->getId();\n }\n if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $sharedUsersIds[] = $sharedUser->getId();\n $this->askAnythingRepository->createPrompt(\n $sharedUser,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n $sharedPrompt->delete();\n }\n }\n\n return [$sharedUsersIds, $sharedUsersRemovedIds];\n }\n\n private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void\n {\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n foreach ($sharedGroup->getMembers() as $member) {\n if (! in_array($member->getId(), $sharedUsersIds)\n && ! in_array($member->getId(), $sharedUsersRemovedIds)) {\n $sharedUsersIds[] = $member->getId();\n $this->askAnythingRepository->createPrompt(\n $member,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n }\n }\n $sharedPrompt->delete();\n }\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
395026636455006835
|
1126917008115010046
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\AskAnything;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
class AskAnythingPromptService
{
public function __construct(
private readonly AskAnythingRepository $askAnythingRepository,
private readonly UserRepository $userRepository,
private readonly GroupRepositoryInterface $groupRepository,
) {
}
/**
* @return array<AskAnythingPromptDto>
*/
public function get(User $user, AskAnythingPromptTarget $target): array
{
$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(
$user,
$target
);
$promptDtos = [];
foreach ($prompts as $prompt) {
$ownerUuid = null;
if ($prompt->getOwner() !== null) {
$ownerUuid = $prompt->getOwner()->getUuid();
}
$shareUsers = null;
$shareGroups = null;
// Provide users and groups only if owner of the prompt is current user
if ($prompt->getOwnerId() === $user->getId()) {
[$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);
}
$promptDtos[] = new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$ownerUuid,
$shareUsers,
$shareGroups,
$prompt->has_reports,
);
}
return $promptDtos;
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*/
public function create(
User $user,
string $title,
string $content,
AskAnythingPromptTarget $target,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
$prompt = $this->askAnythingRepository->createPrompt(
$user,
$target,
$title,
$content,
$shareUsers,
$shareGroups,
);
return new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$prompt->has_reports,
);
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*
* @throws InvalidArgumentException
*/
public function edit(
AskAnythingPrompt $prompt,
User $user,
string $title,
string $content,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
$newPrompt = $this->askAnythingRepository->createPrompt(
$user,
$prompt->getTarget(),
$title,
$content,
$shareUsers,
$shareGroups,
);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$newPrompt = $this->askAnythingRepository->editPrompt(
$prompt,
$title,
$content,
$shareUsers,
$shareGroups,
);
} else {
throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());
}
return new AskAnythingPromptDto(
$newPrompt->getUuid(),
$newPrompt->getTitle(),
$newPrompt->getContent(),
$newPrompt->getTarget(),
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$newPrompt->has_reports,
);
}
public function delete(
AskAnythingPrompt $prompt,
User $user
): AskAnythingPrompt {
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$userPrompt?->delete();
// For each relation, re-create the prompt for the receiver as their own
$this->recreatePromptsForEachRelation($prompt);
// Finally, delete the prompt
$this->deletePromptIfNoRelations($prompt);
} else {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);
// If the prompt is shared directly with the user, then "unshare" it
if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {
$userPrompt->delete();
$this->deletePromptIfNoRelations($prompt);
} elseif ($groupPrompt instanceof UserAskAnythingPrompt) {
// If the prompt is shared with the user and the group, then hide it for this user
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} else {
throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());
}
}
return $prompt;
}
public function reorder(
User $user,
array $promptUuids,
): void {
foreach ($promptUuids as $index => $promptUuid) {
$prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);
$this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);
}
}
/**
* @param AskAnythingPrompt $prompt
*
* @return array[array<string>, array<string>]
*/
private function getReceiverUuids(AskAnythingPrompt $prompt): array
{
$shareUsers = [];
$shareGroups = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {
$shareUsers[] = $sharedUser->getUuid();
}
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
$shareGroups[] = $sharedGroup->getUuid();
}
}
return [$shareUsers, $shareGroups];
}
private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void
{
if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {
// Disable and orphan any AutomatedReports that use this prompt
$prompt->automatedReports()->withTrashed()->update([
'ask_anything_prompt_id' => null,
'status' => false,
]);
// Delete only if there are no other relations to it.
$this->askAnythingRepository->deletePrompt($prompt);
}
}
private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void
{
[$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);
$this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);
}
private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array
{
$sharedUsersIds = [];
$sharedUsersRemovedIds = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedPrompt->isRemoved() === true) {
$sharedUsersRemovedIds[] = $sharedUser->getId();
}
if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {
$sharedUsersIds[] = $sharedUser->getId();
$this->askAnythingRepository->createPrompt(
$sharedUser,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
$sharedPrompt->delete();
}
}
return [$sharedUsersIds, $sharedUsersRemovedIds];
}
private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void
{
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
foreach ($sharedGroup->getMembers() as $member) {
if (! in_array($member->getId(), $sharedUsersIds)
&& ! in_array($member->getId(), $sharedUsersRemovedIds)) {
$sharedUsersIds[] = $member->getId();
$this->askAnythingRepository->createPrompt(
$member,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
}
}
$sharedPrompt->delete();
}
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56671
|
1971
|
45
|
2026-05-19T08:16:08.903311+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178568903_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\AskAnything;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
class AskAnythingPromptService
{
public function __construct(
private readonly AskAnythingRepository $askAnythingRepository,
private readonly UserRepository $userRepository,
private readonly GroupRepositoryInterface $groupRepository,
) {
}
/**
* @return array<AskAnythingPromptDto>
*/
public function get(User $user, AskAnythingPromptTarget $target): array
{
$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(
$user,
$target
);
$promptDtos = [];
foreach ($prompts as $prompt) {
$ownerUuid = null;
if ($prompt->getOwner() !== null) {
$ownerUuid = $prompt->getOwner()->getUuid();
}
$shareUsers = null;
$shareGroups = null;
// Provide users and groups only if owner of the prompt is current user
if ($prompt->getOwnerId() === $user->getId()) {
[$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);
}
$promptDtos[] = new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$ownerUuid,
$shareUsers,
$shareGroups,
$prompt->has_reports,
);
}
return $promptDtos;
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*/
public function create(
User $user,
string $title,
string $content,
AskAnythingPromptTarget $target,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
$prompt = $this->askAnythingRepository->createPrompt(
$user,
$target,
$title,
$content,
$shareUsers,
$shareGroups,
);
return new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$prompt->has_reports,
);
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*
* @throws InvalidArgumentException
*/
public function edit(
AskAnythingPrompt $prompt,
User $user,
string $title,
string $content,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
$newPrompt = $this->askAnythingRepository->createPrompt(
$user,
$prompt->getTarget(),
$title,
$content,
$shareUsers,
$shareGroups,
);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$newPrompt = $this->askAnythingRepository->editPrompt(
$prompt,
$title,
$content,
$shareUsers,
$shareGroups,
);
} else {
throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());
}
return new AskAnythingPromptDto(
$newPrompt->getUuid(),
$newPrompt->getTitle(),
$newPrompt->getContent(),
$newPrompt->getTarget(),
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$newPrompt->has_reports,
);
}
public function delete(
AskAnythingPrompt $prompt,
User $user
): AskAnythingPrompt {
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$userPrompt?->delete();
// For each relation, re-create the prompt for the receiver as their own
$this->recreatePromptsForEachRelation($prompt);
// Finally, delete the prompt
$this->deletePromptIfNoRelations($prompt);
} else {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);
// If the prompt is shared directly with the user, then "unshare" it
if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {
$userPrompt->delete();
$this->deletePromptIfNoRelations($prompt);
} elseif ($groupPrompt instanceof UserAskAnythingPrompt) {
// If the prompt is shared with the user and the group, then hide it for this user
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} else {
throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());
}
}
return $prompt;
}
public function reorder(
User $user,
array $promptUuids,
): void {
foreach ($promptUuids as $index => $promptUuid) {
$prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);
$this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);
}
}
/**
* @param AskAnythingPrompt $prompt
*
* @return array[array<string>, array<string>]
*/
private function getReceiverUuids(AskAnythingPrompt $prompt): array
{
$shareUsers = [];
$shareGroups = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {
$shareUsers[] = $sharedUser->getUuid();
}
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
$shareGroups[] = $sharedGroup->getUuid();
}
}
return [$shareUsers, $shareGroups];
}
private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void
{
if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {
// Disable and orphan any AutomatedReports that use this prompt
$prompt->automatedReports()->withTrashed()->update([
'ask_anything_prompt_id' => null,
'status' => false,
]);
// Delete only if there are no other relations to it.
$this->askAnythingRepository->deletePrompt($prompt);
}
}
private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void
{
[$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);
$this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);
}
private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array
{
$sharedUsersIds = [];
$sharedUsersRemovedIds = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedPrompt->isRemoved() === true) {
$sharedUsersRemovedIds[] = $sharedUser->getId();
}
if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {
$sharedUsersIds[] = $sharedUser->getId();
$this->askAnythingRepository->createPrompt(
$sharedUser,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
$sharedPrompt->delete();
}
}
return [$sharedUsersIds, $sharedUsersRemovedIds];
}
private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void
{
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
foreach ($sharedGroup->getMembers() as $member) {
if (! in_array($member->getId(), $sharedUsersIds)
&& ! in_array($member->getId(), $sharedUsersRemovedIds)) {
$sharedUsersIds[] = $member->getId();
$this->askAnythingRepository->createPrompt(
$member,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
}
}
$sharedPrompt->delete();
}
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\AskAnything;\n\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\n\nclass AskAnythingPromptService\n{\n public function __construct(\n private readonly AskAnythingRepository $askAnythingRepository,\n private readonly UserRepository $userRepository,\n private readonly GroupRepositoryInterface $groupRepository,\n ) {\n }\n\n /**\n * @return array<AskAnythingPromptDto>\n */\n public function get(User $user, AskAnythingPromptTarget $target): array\n {\n $prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(\n $user,\n $target\n );\n\n $promptDtos = [];\n foreach ($prompts as $prompt) {\n $ownerUuid = null;\n if ($prompt->getOwner() !== null) {\n $ownerUuid = $prompt->getOwner()->getUuid();\n }\n $shareUsers = null;\n $shareGroups = null;\n\n // Provide users and groups only if owner of the prompt is current user\n if ($prompt->getOwnerId() === $user->getId()) {\n [$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);\n }\n\n $promptDtos[] = new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $ownerUuid,\n $shareUsers,\n $shareGroups,\n $prompt->has_reports,\n );\n }\n\n return $promptDtos;\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n */\n public function create(\n User $user,\n string $title,\n string $content,\n AskAnythingPromptTarget $target,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n $prompt = $this->askAnythingRepository->createPrompt(\n $user,\n $target,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n\n return new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $prompt->has_reports,\n );\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n *\n * @throws InvalidArgumentException\n */\n public function edit(\n AskAnythingPrompt $prompt,\n User $user,\n string $title,\n string $content,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n\n $newPrompt = $this->askAnythingRepository->createPrompt(\n $user,\n $prompt->getTarget(),\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $newPrompt = $this->askAnythingRepository->editPrompt(\n $prompt,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } else {\n throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());\n }\n\n return new AskAnythingPromptDto(\n $newPrompt->getUuid(),\n $newPrompt->getTitle(),\n $newPrompt->getContent(),\n $newPrompt->getTarget(),\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $newPrompt->has_reports,\n );\n }\n\n public function delete(\n AskAnythingPrompt $prompt,\n User $user\n ): AskAnythingPrompt {\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $userPrompt?->delete();\n // For each relation, re-create the prompt for the receiver as their own\n $this->recreatePromptsForEachRelation($prompt);\n\n // Finally, delete the prompt\n $this->deletePromptIfNoRelations($prompt);\n } else {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);\n\n // If the prompt is shared directly with the user, then \"unshare\" it\n if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {\n $userPrompt->delete();\n $this->deletePromptIfNoRelations($prompt);\n } elseif ($groupPrompt instanceof UserAskAnythingPrompt) {\n // If the prompt is shared with the user and the group, then hide it for this user\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } else {\n throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());\n }\n }\n\n return $prompt;\n }\n\n public function reorder(\n User $user,\n array $promptUuids,\n ): void {\n foreach ($promptUuids as $index => $promptUuid) {\n $prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);\n $this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);\n }\n }\n\n /**\n * @param AskAnythingPrompt $prompt\n *\n * @return array[array<string>, array<string>]\n */\n private function getReceiverUuids(AskAnythingPrompt $prompt): array\n {\n $shareUsers = [];\n $shareGroups = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $shareUsers[] = $sharedUser->getUuid();\n }\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n $shareGroups[] = $sharedGroup->getUuid();\n }\n }\n\n return [$shareUsers, $shareGroups];\n }\n\n private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void\n {\n if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {\n // Disable and orphan any AutomatedReports that use this prompt\n $prompt->automatedReports()->withTrashed()->update([\n 'ask_anything_prompt_id' => null,\n 'status' => false,\n ]);\n\n // Delete only if there are no other relations to it.\n $this->askAnythingRepository->deletePrompt($prompt);\n }\n }\n\n private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void\n {\n [$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);\n $this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);\n }\n\n private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array\n {\n $sharedUsersIds = [];\n $sharedUsersRemovedIds = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedPrompt->isRemoved() === true) {\n $sharedUsersRemovedIds[] = $sharedUser->getId();\n }\n if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $sharedUsersIds[] = $sharedUser->getId();\n $this->askAnythingRepository->createPrompt(\n $sharedUser,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n $sharedPrompt->delete();\n }\n }\n\n return [$sharedUsersIds, $sharedUsersRemovedIds];\n }\n\n private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void\n {\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n foreach ($sharedGroup->getMembers() as $member) {\n if (! in_array($member->getId(), $sharedUsersIds)\n && ! in_array($member->getId(), $sharedUsersRemovedIds)) {\n $sharedUsersIds[] = $member->getId();\n $this->askAnythingRepository->createPrompt(\n $member,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n }\n }\n $sharedPrompt->delete();\n }\n }\n }\n}","depth":4,"bounds":{"left":0.15990691,"top":0.0,"width":0.38098404,"height":1.0},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\AskAnything;\n\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\n\nclass AskAnythingPromptService\n{\n public function __construct(\n private readonly AskAnythingRepository $askAnythingRepository,\n private readonly UserRepository $userRepository,\n private readonly GroupRepositoryInterface $groupRepository,\n ) {\n }\n\n /**\n * @return array<AskAnythingPromptDto>\n */\n public function get(User $user, AskAnythingPromptTarget $target): array\n {\n $prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(\n $user,\n $target\n );\n\n $promptDtos = [];\n foreach ($prompts as $prompt) {\n $ownerUuid = null;\n if ($prompt->getOwner() !== null) {\n $ownerUuid = $prompt->getOwner()->getUuid();\n }\n $shareUsers = null;\n $shareGroups = null;\n\n // Provide users and groups only if owner of the prompt is current user\n if ($prompt->getOwnerId() === $user->getId()) {\n [$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);\n }\n\n $promptDtos[] = new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $ownerUuid,\n $shareUsers,\n $shareGroups,\n $prompt->has_reports,\n );\n }\n\n return $promptDtos;\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n */\n public function create(\n User $user,\n string $title,\n string $content,\n AskAnythingPromptTarget $target,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n $prompt = $this->askAnythingRepository->createPrompt(\n $user,\n $target,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n\n return new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $prompt->has_reports,\n );\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n *\n * @throws InvalidArgumentException\n */\n public function edit(\n AskAnythingPrompt $prompt,\n User $user,\n string $title,\n string $content,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n\n $newPrompt = $this->askAnythingRepository->createPrompt(\n $user,\n $prompt->getTarget(),\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $newPrompt = $this->askAnythingRepository->editPrompt(\n $prompt,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } else {\n throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());\n }\n\n return new AskAnythingPromptDto(\n $newPrompt->getUuid(),\n $newPrompt->getTitle(),\n $newPrompt->getContent(),\n $newPrompt->getTarget(),\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $newPrompt->has_reports,\n );\n }\n\n public function delete(\n AskAnythingPrompt $prompt,\n User $user\n ): AskAnythingPrompt {\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $userPrompt?->delete();\n // For each relation, re-create the prompt for the receiver as their own\n $this->recreatePromptsForEachRelation($prompt);\n\n // Finally, delete the prompt\n $this->deletePromptIfNoRelations($prompt);\n } else {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);\n\n // If the prompt is shared directly with the user, then \"unshare\" it\n if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {\n $userPrompt->delete();\n $this->deletePromptIfNoRelations($prompt);\n } elseif ($groupPrompt instanceof UserAskAnythingPrompt) {\n // If the prompt is shared with the user and the group, then hide it for this user\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } else {\n throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());\n }\n }\n\n return $prompt;\n }\n\n public function reorder(\n User $user,\n array $promptUuids,\n ): void {\n foreach ($promptUuids as $index => $promptUuid) {\n $prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);\n $this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);\n }\n }\n\n /**\n * @param AskAnythingPrompt $prompt\n *\n * @return array[array<string>, array<string>]\n */\n private function getReceiverUuids(AskAnythingPrompt $prompt): array\n {\n $shareUsers = [];\n $shareGroups = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $shareUsers[] = $sharedUser->getUuid();\n }\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n $shareGroups[] = $sharedGroup->getUuid();\n }\n }\n\n return [$shareUsers, $shareGroups];\n }\n\n private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void\n {\n if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {\n // Disable and orphan any AutomatedReports that use this prompt\n $prompt->automatedReports()->withTrashed()->update([\n 'ask_anything_prompt_id' => null,\n 'status' => false,\n ]);\n\n // Delete only if there are no other relations to it.\n $this->askAnythingRepository->deletePrompt($prompt);\n }\n }\n\n private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void\n {\n [$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);\n $this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);\n }\n\n private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array\n {\n $sharedUsersIds = [];\n $sharedUsersRemovedIds = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedPrompt->isRemoved() === true) {\n $sharedUsersRemovedIds[] = $sharedUser->getId();\n }\n if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $sharedUsersIds[] = $sharedUser->getId();\n $this->askAnythingRepository->createPrompt(\n $sharedUser,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n $sharedPrompt->delete();\n }\n }\n\n return [$sharedUsersIds, $sharedUsersRemovedIds];\n }\n\n private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void\n {\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n foreach ($sharedGroup->getMembers() as $member) {\n if (! in_array($member->getId(), $sharedUsersIds)\n && ! in_array($member->getId(), $sharedUsersRemovedIds)) {\n $sharedUsersIds[] = $member->getId();\n $this->askAnythingRepository->createPrompt(\n $member,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n }\n }\n $sharedPrompt->delete();\n }\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
395026636455006835
|
1126917008115010046
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\AskAnything;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
class AskAnythingPromptService
{
public function __construct(
private readonly AskAnythingRepository $askAnythingRepository,
private readonly UserRepository $userRepository,
private readonly GroupRepositoryInterface $groupRepository,
) {
}
/**
* @return array<AskAnythingPromptDto>
*/
public function get(User $user, AskAnythingPromptTarget $target): array
{
$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(
$user,
$target
);
$promptDtos = [];
foreach ($prompts as $prompt) {
$ownerUuid = null;
if ($prompt->getOwner() !== null) {
$ownerUuid = $prompt->getOwner()->getUuid();
}
$shareUsers = null;
$shareGroups = null;
// Provide users and groups only if owner of the prompt is current user
if ($prompt->getOwnerId() === $user->getId()) {
[$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);
}
$promptDtos[] = new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$ownerUuid,
$shareUsers,
$shareGroups,
$prompt->has_reports,
);
}
return $promptDtos;
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*/
public function create(
User $user,
string $title,
string $content,
AskAnythingPromptTarget $target,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
$prompt = $this->askAnythingRepository->createPrompt(
$user,
$target,
$title,
$content,
$shareUsers,
$shareGroups,
);
return new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$prompt->has_reports,
);
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*
* @throws InvalidArgumentException
*/
public function edit(
AskAnythingPrompt $prompt,
User $user,
string $title,
string $content,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
$newPrompt = $this->askAnythingRepository->createPrompt(
$user,
$prompt->getTarget(),
$title,
$content,
$shareUsers,
$shareGroups,
);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$newPrompt = $this->askAnythingRepository->editPrompt(
$prompt,
$title,
$content,
$shareUsers,
$shareGroups,
);
} else {
throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());
}
return new AskAnythingPromptDto(
$newPrompt->getUuid(),
$newPrompt->getTitle(),
$newPrompt->getContent(),
$newPrompt->getTarget(),
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$newPrompt->has_reports,
);
}
public function delete(
AskAnythingPrompt $prompt,
User $user
): AskAnythingPrompt {
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$userPrompt?->delete();
// For each relation, re-create the prompt for the receiver as their own
$this->recreatePromptsForEachRelation($prompt);
// Finally, delete the prompt
$this->deletePromptIfNoRelations($prompt);
} else {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);
// If the prompt is shared directly with the user, then "unshare" it
if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {
$userPrompt->delete();
$this->deletePromptIfNoRelations($prompt);
} elseif ($groupPrompt instanceof UserAskAnythingPrompt) {
// If the prompt is shared with the user and the group, then hide it for this user
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} else {
throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());
}
}
return $prompt;
}
public function reorder(
User $user,
array $promptUuids,
): void {
foreach ($promptUuids as $index => $promptUuid) {
$prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);
$this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);
}
}
/**
* @param AskAnythingPrompt $prompt
*
* @return array[array<string>, array<string>]
*/
private function getReceiverUuids(AskAnythingPrompt $prompt): array
{
$shareUsers = [];
$shareGroups = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {
$shareUsers[] = $sharedUser->getUuid();
}
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
$shareGroups[] = $sharedGroup->getUuid();
}
}
return [$shareUsers, $shareGroups];
}
private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void
{
if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {
// Disable and orphan any AutomatedReports that use this prompt
$prompt->automatedReports()->withTrashed()->update([
'ask_anything_prompt_id' => null,
'status' => false,
]);
// Delete only if there are no other relations to it.
$this->askAnythingRepository->deletePrompt($prompt);
}
}
private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void
{
[$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);
$this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);
}
private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array
{
$sharedUsersIds = [];
$sharedUsersRemovedIds = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedPrompt->isRemoved() === true) {
$sharedUsersRemovedIds[] = $sharedUser->getId();
}
if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {
$sharedUsersIds[] = $sharedUser->getId();
$this->askAnythingRepository->createPrompt(
$sharedUser,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
$sharedPrompt->delete();
}
}
return [$sharedUsersIds, $sharedUsersRemovedIds];
}
private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void
{
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
foreach ($sharedGroup->getMembers() as $member) {
if (! in_array($member->getId(), $sharedUsersIds)
&& ! in_array($member->getId(), $sharedUsersRemovedIds)) {
$sharedUsersIds[] = $member->getId();
$this->askAnythingRepository->createPrompt(
$member,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
}
}
$sharedPrompt->delete();
}
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56669
|
NULL
|
NULL
|
NULL
|
|
56673
|
1971
|
46
|
2026-05-19T08:16:15.550060+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178575550_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-ProiectC ActivityController.ongD AskAnythingAskAnytningPromptservice.pnppip api_vc.ongo AutomatedkeporLonpvm DtosAskJiminnykeporscontroller.png© AskAnythingPromptServiceTest.phg© AskAnythingPromptDto.phpD eventsAsKAnytningPromptservice.ongpublic functionconstructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository,D1...5w country1 Database→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconko[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasn Nudae1M Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlictProphetDronhotAfMAuoncpublic function get(User Suser, AskAnythingPromptTarget $target): array$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(stargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nutuo *sowneruurd = soromort->qetuwner@->qeruurdonsshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharelsens. SshareGrouns = Sthis->aetRecenverluidsSoromot):SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentoStargerSownerUuid,sshareuserschareGroups$prompt->has_reportslCacaada 90111 Command 9el• Extract Surround /=return soromoruros.* eparam arrây «str 1ngts ssharX Reject File 4%€+ 1 of 3 files →denrecated. If vou're not writing in Hungarian vou can cafolv uninctall Huncnoll without affecting the didies for other languages. (today 10:00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:15AskJiminnyReportActivityServiceTest v+0 ..© Search.php= custom.log= laravel.log« SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 ct ›146 0>151 C1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}Ipublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}Accept RejectCascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumW Windsurf Teams50-27 (11 charc) UTF.8Po 4 spaces...
|
NULL
|
1652806578430737753
|
NULL
|
click
|
ocr
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-ProiectC ActivityController.ongD AskAnythingAskAnytningPromptservice.pnppip api_vc.ongo AutomatedkeporLonpvm DtosAskJiminnykeporscontroller.png© AskAnythingPromptServiceTest.phg© AskAnythingPromptDto.phpD eventsAsKAnytningPromptservice.ongpublic functionconstructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository,D1...5w country1 Database→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconko[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasn Nudae1M Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlictProphetDronhotAfMAuoncpublic function get(User Suser, AskAnythingPromptTarget $target): array$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(stargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nutuo *sowneruurd = soromort->qetuwner@->qeruurdonsshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharelsens. SshareGrouns = Sthis->aetRecenverluidsSoromot):SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentoStargerSownerUuid,sshareuserschareGroups$prompt->has_reportslCacaada 90111 Command 9el• Extract Surround /=return soromoruros.* eparam arrây «str 1ngts ssharX Reject File 4%€+ 1 of 3 files →denrecated. If vou're not writing in Hungarian vou can cafolv uninctall Huncnoll without affecting the didies for other languages. (today 10:00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:15AskJiminnyReportActivityServiceTest v+0 ..© Search.php= custom.log= laravel.log« SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 ct ›146 0>151 C1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}Ipublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}Accept RejectCascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumW Windsurf Teams50-27 (11 charc) UTF.8Po 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56672
|
1970
|
37
|
2026-05-19T08:16:15.585179+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178575585_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:15Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
4876021232540716725
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:15Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
56670
|
NULL
|
NULL
|
NULL
|
|
56674
|
1971
|
47
|
2026-05-19T08:16:17.987081+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178577987_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.40292552,"top":0.12529927,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6121287148705449701
|
6644580816357928884
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56673
|
NULL
|
NULL
|
NULL
|
|
56676
|
1971
|
48
|
2026-05-19T08:16:18.755793+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178578755_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.40292552,"top":0.12529927,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6772405443665048833
|
2032894797930540980
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56675
|
1970
|
38
|
2026-05-19T08:16:18.764492+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178578764_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6121287148705449701
|
6644580816357928884
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56677
|
1971
|
49
|
2026-05-19T08:16:20.398948+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178580398_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.40292552,"top":0.12529927,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6121287148705449701
|
6644580816357928884
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56676
|
NULL
|
NULL
|
NULL
|
|
56678
|
1971
|
50
|
2026-05-19T08:16:22.113013+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178582113_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.40292552,"top":0.12529927,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6772405443665048833
|
2032894797930540980
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56679
|
1971
|
51
|
2026-05-19T08:16:25.452031+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178585452_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.40292552,"top":0.12529927,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6121287148705449701
|
6644580816357928884
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56678
|
NULL
|
NULL
|
NULL
|
|
56681
|
1971
|
52
|
2026-05-19T08:16:31.571575+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178591571_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReportsAttribute(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.40226063,"top":0.12529927,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReportsAttribute(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReportsAttribute(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-6590307932661253969
|
2032892598974394292
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReportsAttribute(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56680
|
1970
|
39
|
2026-05-19T08:16:31.571580+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178591571_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReportsAttribute(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReportsAttribute(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReportsAttribute(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-7248260407194138512
|
6644580816357928884
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReportsAttribute(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56675
|
NULL
|
NULL
|
NULL
|
|
56683
|
1971
|
53
|
2026-05-19T08:16:32.404577+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178592404_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormViewINavicareCodeLaravelKeractorTOOISWindo PhostormViewINavicareCodeLaravelKeractorTOOISWindowFV faVsco.js°9 JY-20676-delete-report-related-objectsroledeyC ActivityController.ong© AskAnythingController.php© AskAnythingPromptService.php© SetDefaultAvatarListener.php© SetupCalendarSync.php© SetupMailSync.php© Syncintercom.php© SyncPlanhat.php© SyncUserPilot.phppip api_vc.ong(C) AutomatedReport.pnp© AskJiminnyReportsController.phg© AskAnythingPrompt.php x © Search.phpclass AskAnythingPrompt extends Model26 0protected svis1ble =cvalicalesencinamessace.onc)validalesencinaNotitication.ono> C WebhookE.aitkeep'owner_id',c) ChangeLoaContextCorrelationid.ohp> L Maili32 0)protected function casts): arrayt...> D McDv D Modelsv ActivityC) Activitvimoort.ohoC) ActivitvProcessinaState.ohoC) ActivitvSummarvLoa.ohv© ActivityUploadSetting.php© AvailabilityNotification.php© CoachRequest.php(C) Comment nhn© Export.php© ExportLog.php© ExportToken.php© Log.phpMessage.ong(e) Moment.phpc Nore.ono© ParticipantData.phpc) Participantspeech.phgc) Play.phpc) Provider.phpC) ProviderUser.phpc) Search.ohr© SearchFilter.ohpC) Share.oho@ Snapshot.ohp(C) Stats.ohoC) StatsSoecification.ohvc) Subscrintion.nhr© SubscriptionSet.php(C) TonicTriaaer nhn.(C) Transcrintion.nhn(C) TranscrintionSummarv nhnlM Aiv MAckAnvthingC AckinvthinaDromnt nhn€ AskAnythingPromptTarget.phpC) UserAskAnvthingPrompt.pnppublic function owner(): Relations\BelongsTot...public function get0wner: ?Userf...}no usagespublic function userPrompts): Relations HasMany{...}public function automatedReports: Relations HasMany{...}public function getUuid0: string{...}public function getid0: intf...}public function getOwnerIdO: ?intf...}public function getTarget@: AskAnvthingPromptTargets...}* Promot is considered default when it has no owner* Greturn hool15 usadesnublic function islefaultPromnto• hool..public function getTitle: stringf...}public function getContent(): stringf..,no usagespublic function getHasReportsAttributed: boolreturn Sthis->automatedReports(->exists0:a in Hungarian vou can cafolv uninctall Huncnoll without affectina the dictionarios for other lanquadec (todav 10-00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:32U AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >1118135136 Gt ›146 @t>150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho- Added has reports to Saopends and a getHasRevortsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teams102-27 (A charchUTE.8Po 4 spaces...
|
NULL
|
1742725619662088392
|
NULL
|
click
|
ocr
|
NULL
|
PhostormViewINavicareCodeLaravelKeractorTOOISWindo PhostormViewINavicareCodeLaravelKeractorTOOISWindowFV faVsco.js°9 JY-20676-delete-report-related-objectsroledeyC ActivityController.ong© AskAnythingController.php© AskAnythingPromptService.php© SetDefaultAvatarListener.php© SetupCalendarSync.php© SetupMailSync.php© Syncintercom.php© SyncPlanhat.php© SyncUserPilot.phppip api_vc.ong(C) AutomatedReport.pnp© AskJiminnyReportsController.phg© AskAnythingPrompt.php x © Search.phpclass AskAnythingPrompt extends Model26 0protected svis1ble =cvalicalesencinamessace.onc)validalesencinaNotitication.ono> C WebhookE.aitkeep'owner_id',c) ChangeLoaContextCorrelationid.ohp> L Maili32 0)protected function casts): arrayt...> D McDv D Modelsv ActivityC) Activitvimoort.ohoC) ActivitvProcessinaState.ohoC) ActivitvSummarvLoa.ohv© ActivityUploadSetting.php© AvailabilityNotification.php© CoachRequest.php(C) Comment nhn© Export.php© ExportLog.php© ExportToken.php© Log.phpMessage.ong(e) Moment.phpc Nore.ono© ParticipantData.phpc) Participantspeech.phgc) Play.phpc) Provider.phpC) ProviderUser.phpc) Search.ohr© SearchFilter.ohpC) Share.oho@ Snapshot.ohp(C) Stats.ohoC) StatsSoecification.ohvc) Subscrintion.nhr© SubscriptionSet.php(C) TonicTriaaer nhn.(C) Transcrintion.nhn(C) TranscrintionSummarv nhnlM Aiv MAckAnvthingC AckinvthinaDromnt nhn€ AskAnythingPromptTarget.phpC) UserAskAnvthingPrompt.pnppublic function owner(): Relations\BelongsTot...public function get0wner: ?Userf...}no usagespublic function userPrompts): Relations HasMany{...}public function automatedReports: Relations HasMany{...}public function getUuid0: string{...}public function getid0: intf...}public function getOwnerIdO: ?intf...}public function getTarget@: AskAnvthingPromptTargets...}* Promot is considered default when it has no owner* Greturn hool15 usadesnublic function islefaultPromnto• hool..public function getTitle: stringf...}public function getContent(): stringf..,no usagespublic function getHasReportsAttributed: boolreturn Sthis->automatedReports(->exists0:a in Hungarian vou can cafolv uninctall Huncnoll without affectina the dictionarios for other lanquadec (todav 10-00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:32U AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >1118135136 Gt ›146 @t>150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho- Added has reports to Saopends and a getHasRevortsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teams102-27 (A charchUTE.8Po 4 spaces...
|
56681
|
NULL
|
NULL
|
NULL
|
|
56682
|
1970
|
40
|
2026-05-19T08:16:32.446919+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178592446_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:32Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
-5118510908563921119
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:32Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56684
|
1970
|
41
|
2026-05-19T08:16:33.788122+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178593788_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1382198555050301501
|
-7484840560542888505
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:33Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
56682
|
NULL
|
NULL
|
NULL
|
|
56686
|
1971
|
54
|
2026-05-19T08:16:36.447031+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178596447_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.40226063,"top":0.12529927,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2184774655354516323
|
2067270521124532197
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56685
|
1970
|
42
|
2026-05-19T08:16:36.456620+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178596456_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6041829494737043046
|
2032894806520475636
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56687
|
1970
|
43
|
2026-05-19T08:16:37.375360+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178597375_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2846988005475815044
|
2032894797930541044
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56685
|
NULL
|
NULL
|
NULL
|
|
56688
|
1971
|
55
|
2026-05-19T08:16:37.378744+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178597378_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.40226063,"top":0.12529927,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Models\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Relations;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\Model;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Traits\\RequiresUUID;\n\nclass AskAnythingPrompt extends Model\n{\n use RequiresUUID;\n\n protected $table = 'ask_anything_prompts';\n\n protected $fillable = [\n 'title',\n 'content',\n 'target',\n 'owner_id',\n ];\n\n protected $visible = [\n 'title',\n 'content',\n 'owner_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'title' => 'string',\n 'content' => 'string',\n 'target' => AskAnythingPromptTarget::class,\n 'owner_id' => 'integer',\n ];\n }\n\n public function owner(): Relations\\BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function getOwner(): ?User\n {\n return $this->getAttribute('owner');\n }\n\n public function userPrompts(): Relations\\HasMany\n {\n return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');\n }\n\n public function automatedReports(): Relations\\HasMany\n {\n return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');\n }\n\n public function getUuid(): string\n {\n return $this->getAttribute('id_string');\n }\n\n public function getId(): int\n {\n return $this->getAttribute('id');\n }\n\n public function getOwnerId(): ?int\n {\n return $this->getAttribute('owner_id');\n }\n\n public function getTarget(): AskAnythingPromptTarget\n {\n return $this->getAttribute('target');\n }\n\n /**\n * Prompt is considered default when it has no owner\n *\n * @return bool\n */\n public function isDefaultPrompt(): bool\n {\n return $this->getOwnerId() === null;\n }\n\n public function getTitle(): string\n {\n return $this->getAttribute('title');\n }\n\n public function getContent(): string\n {\n return $this->getAttribute('content');\n }\n \n public function getHasReports(): bool\n {\n return $this->automatedReports()->exists();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2846988005475815044
|
2032894797930541044
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Models\AskAnything;
use Illuminate\Database\Eloquent\Relations;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\Model;
use Jiminny\Models\User;
use Jiminny\Traits\RequiresUUID;
class AskAnythingPrompt extends Model
{
use RequiresUUID;
protected $table = 'ask_anything_prompts';
protected $fillable = [
'title',
'content',
'target',
'owner_id',
];
protected $visible = [
'title',
'content',
'owner_id',
];
protected function casts(): array
{
return [
'title' => 'string',
'content' => 'string',
'target' => AskAnythingPromptTarget::class,
'owner_id' => 'integer',
];
}
public function owner(): Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function getOwner(): ?User
{
return $this->getAttribute('owner');
}
public function userPrompts(): Relations\HasMany
{
return $this->hasMany(UserAskAnythingPrompt::class, 'prompt_id');
}
public function automatedReports(): Relations\HasMany
{
return $this->hasMany(AutomatedReport::class, 'ask_anything_prompt_id');
}
public function getUuid(): string
{
return $this->getAttribute('id_string');
}
public function getId(): int
{
return $this->getAttribute('id');
}
public function getOwnerId(): ?int
{
return $this->getAttribute('owner_id');
}
public function getTarget(): AskAnythingPromptTarget
{
return $this->getAttribute('target');
}
/**
* Prompt is considered default when it has no owner
*
* @return bool
*/
public function isDefaultPrompt(): bool
{
return $this->getOwnerId() === null;
}
public function getTitle(): string
{
return $this->getAttribute('title');
}
public function getContent(): string
{
return $this->getAttribute('content');
}
public function getHasReports(): bool
{
return $this->automatedReports()->exists();
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56686
|
NULL
|
NULL
|
NULL
|
|
56690
|
1971
|
56
|
2026-05-19T08:16:40.602653+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178600602_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1382198555050301501
|
-7484840560542888505
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
PhostormViewINavicareCodeLaravelKeractorTOOISWindowFV faVsco.js°9 JY-20676-delete-report-related-objectsroledeyC ActivityController.ong© AskAnythingPromptService.php© SetDefaultAvatarListener.php© SetupCalendarSync.php© AskJiminnyReportsController.phg© SetupMailSync.phpclass AskAnythingPrompt extends Model© Syncintercom.php© SyncPlanhat.php© SyncUserPilot.php26 0protected svis1ble =cvalicalesencinamessace.onc)ValidatesencinaNottication.ono> C Webhook'owner_id',E.aitkeepc) ChangeLoaContextCorrelationid.ohp> L Maili32 0)protected function casts): arrayt...> D McDv D Modelsv ActivityC) Activitvimoort.ohoC) ActivitvProcessinaState.ohoC) ActivitvSummarvLoa.ohv© ActivityUploadSetting.php© AvailabilityNotification.php© CoachRequest.php(C) Comment nhn(c) Exoor.onp© ExportLog.php© ExportToken.php© Log.phpMessage.ong(e) Moment.phpc Nore.onoParicioantData.ongc) Participantspeech.phgc) Play.phpc) Provider.phpC) ProviderUser.phpc) Search.ohrC) Search-ilter.oho(C) Share,oho@ Snapshot.php.(C) Stats.ohoC) StatsSoecification.ohvc) Subscrintion.nhr© SubscriptionSet.php(C) TonicTriaaer nhn.(C) Transcrintion.nhn(C) TranscrintionSummarv nhnlM Aiv D AskAnythingC AckinvthinaDromnt nhn€ AskAnythingPromptTarget.php© UserAskAnythingPrompt.phppublic function owner(): Relations\BelongsTot...public function get0wner: ?Userf...}no usagespublic function userPrompts): Relations HasMany{...}public function automatedReports: Relations HasMany{...}public function getUuid0: string{...}public function getid0: intf...}public function getOwnerIdO: ?intf...}public function getTarget@: AskAnvthingPromptTargets...}* Promot is considered default when it has no owner* Greturn hool15 usadesnublic function islefaultPromnto• hool..public function getTitle: stringf...}public function getContent(): stringf..,no usagespublic function getHasReportsO: boolCascade 991-1notunn Sthic-sautomntodPonontc/_sovicte/)© AskAnythingController.phppip api_vc.ong(C) AutomatedReport.pnp© AskAnythingPrompt.php x © Search.php• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:40AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >1118131135136 Gt ›146 @t>150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...}public function toArray@: array{...hprivate function getOptions(): array{...}public function getValue®: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}Command 991CascadeASk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything_promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumW Windsurf Teamo102-24(12 charc)UTE.8io 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56689
|
1970
|
44
|
2026-05-19T08:16:40.624213+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178600624_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4701279590415171657
|
-8204420343923494970
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:40Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56692
|
1970
|
45
|
2026-05-19T08:16:41.791159+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178601791_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:41Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
2379393840867739607
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:41Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
56689
|
NULL
|
NULL
|
NULL
|
|
56691
|
1971
|
57
|
2026-05-19T08:16:43.396080+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178603396_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\AskAnything;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
class AskAnythingPromptService
{
public function __construct(
private readonly AskAnythingRepository $askAnythingRepository,
private readonly UserRepository $userRepository,
private readonly GroupRepositoryInterface $groupRepository,
) {
}
/**
* @return array<AskAnythingPromptDto>
*/
public function get(User $user, AskAnythingPromptTarget $target): array
{
$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(
$user,
$target
);
$promptDtos = [];
foreach ($prompts as $prompt) {
$ownerUuid = null;
if ($prompt->getOwner() !== null) {
$ownerUuid = $prompt->getOwner()->getUuid();
}
$shareUsers = null;
$shareGroups = null;
// Provide users and groups only if owner of the prompt is current user
if ($prompt->getOwnerId() === $user->getId()) {
[$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);
}
$promptDtos[] = new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$ownerUuid,
$shareUsers,
$shareGroups,
$prompt->has_reports,
);
}
return $promptDtos;
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*/
public function create(
User $user,
string $title,
string $content,
AskAnythingPromptTarget $target,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
$prompt = $this->askAnythingRepository->createPrompt(
$user,
$target,
$title,
$content,
$shareUsers,
$shareGroups,
);
return new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$prompt->has_reports,
);
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*
* @throws InvalidArgumentException
*/
public function edit(
AskAnythingPrompt $prompt,
User $user,
string $title,
string $content,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
$newPrompt = $this->askAnythingRepository->createPrompt(
$user,
$prompt->getTarget(),
$title,
$content,
$shareUsers,
$shareGroups,
);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$newPrompt = $this->askAnythingRepository->editPrompt(
$prompt,
$title,
$content,
$shareUsers,
$shareGroups,
);
} else {
throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());
}
return new AskAnythingPromptDto(
$newPrompt->getUuid(),
$newPrompt->getTitle(),
$newPrompt->getContent(),
$newPrompt->getTarget(),
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$newPrompt->has_reports,
);
}
public function delete(
AskAnythingPrompt $prompt,
User $user
): AskAnythingPrompt {
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$userPrompt?->delete();
// For each relation, re-create the prompt for the receiver as their own
$this->recreatePromptsForEachRelation($prompt);
// Finally, delete the prompt
$this->deletePromptIfNoRelations($prompt);
} else {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);
// If the prompt is shared directly with the user, then "unshare" it
if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {
$userPrompt->delete();
$this->deletePromptIfNoRelations($prompt);
} elseif ($groupPrompt instanceof UserAskAnythingPrompt) {
// If the prompt is shared with the user and the group, then hide it for this user
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} else {
throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());
}
}
return $prompt;
}
public function reorder(
User $user,
array $promptUuids,
): void {
foreach ($promptUuids as $index => $promptUuid) {
$prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);
$this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);
}
}
/**
* @param AskAnythingPrompt $prompt
*
* @return array[array<string>, array<string>]
*/
private function getReceiverUuids(AskAnythingPrompt $prompt): array
{
$shareUsers = [];
$shareGroups = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {
$shareUsers[] = $sharedUser->getUuid();
}
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
$shareGroups[] = $sharedGroup->getUuid();
}
}
return [$shareUsers, $shareGroups];
}
private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void
{
if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {
// Disable and orphan any AutomatedReports that use this prompt
$prompt->automatedReports()->withTrashed()->update([
'ask_anything_prompt_id' => null,
'status' => false,
]);
// Delete only if there are no other relations to it.
$this->askAnythingRepository->deletePrompt($prompt);
}
}
private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void
{
[$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);
$this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);
}
private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array
{
$sharedUsersIds = [];
$sharedUsersRemovedIds = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedPrompt->isRemoved() === true) {
$sharedUsersRemovedIds[] = $sharedUser->getId();
}
if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {
$sharedUsersIds[] = $sharedUser->getId();
$this->askAnythingRepository->createPrompt(
$sharedUser,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
$sharedPrompt->delete();
}
}
return [$sharedUsersIds, $sharedUsersRemovedIds];
}
private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void
{
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
foreach ($sharedGroup->getMembers() as $member) {
if (! in_array($member->getId(), $sharedUsersIds)
&& ! in_array($member->getId(), $sharedUsersRemovedIds)) {
$sharedUsersIds[] = $member->getId();
$this->askAnythingRepository->createPrompt(
$member,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
}
}
$sharedPrompt->delete();
}
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"4","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\AskAnything;\n\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\n\nclass AskAnythingPromptService\n{\n public function __construct(\n private readonly AskAnythingRepository $askAnythingRepository,\n private readonly UserRepository $userRepository,\n private readonly GroupRepositoryInterface $groupRepository,\n ) {\n }\n\n /**\n * @return array<AskAnythingPromptDto>\n */\n public function get(User $user, AskAnythingPromptTarget $target): array\n {\n $prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(\n $user,\n $target\n );\n\n $promptDtos = [];\n foreach ($prompts as $prompt) {\n $ownerUuid = null;\n if ($prompt->getOwner() !== null) {\n $ownerUuid = $prompt->getOwner()->getUuid();\n }\n $shareUsers = null;\n $shareGroups = null;\n\n // Provide users and groups only if owner of the prompt is current user\n if ($prompt->getOwnerId() === $user->getId()) {\n [$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);\n }\n\n $promptDtos[] = new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $ownerUuid,\n $shareUsers,\n $shareGroups,\n $prompt->has_reports,\n );\n }\n\n return $promptDtos;\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n */\n public function create(\n User $user,\n string $title,\n string $content,\n AskAnythingPromptTarget $target,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n $prompt = $this->askAnythingRepository->createPrompt(\n $user,\n $target,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n\n return new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $prompt->has_reports,\n );\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n *\n * @throws InvalidArgumentException\n */\n public function edit(\n AskAnythingPrompt $prompt,\n User $user,\n string $title,\n string $content,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n\n $newPrompt = $this->askAnythingRepository->createPrompt(\n $user,\n $prompt->getTarget(),\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $newPrompt = $this->askAnythingRepository->editPrompt(\n $prompt,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } else {\n throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());\n }\n\n return new AskAnythingPromptDto(\n $newPrompt->getUuid(),\n $newPrompt->getTitle(),\n $newPrompt->getContent(),\n $newPrompt->getTarget(),\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $newPrompt->has_reports,\n );\n }\n\n public function delete(\n AskAnythingPrompt $prompt,\n User $user\n ): AskAnythingPrompt {\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $userPrompt?->delete();\n // For each relation, re-create the prompt for the receiver as their own\n $this->recreatePromptsForEachRelation($prompt);\n\n // Finally, delete the prompt\n $this->deletePromptIfNoRelations($prompt);\n } else {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);\n\n // If the prompt is shared directly with the user, then \"unshare\" it\n if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {\n $userPrompt->delete();\n $this->deletePromptIfNoRelations($prompt);\n } elseif ($groupPrompt instanceof UserAskAnythingPrompt) {\n // If the prompt is shared with the user and the group, then hide it for this user\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } else {\n throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());\n }\n }\n\n return $prompt;\n }\n\n public function reorder(\n User $user,\n array $promptUuids,\n ): void {\n foreach ($promptUuids as $index => $promptUuid) {\n $prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);\n $this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);\n }\n }\n\n /**\n * @param AskAnythingPrompt $prompt\n *\n * @return array[array<string>, array<string>]\n */\n private function getReceiverUuids(AskAnythingPrompt $prompt): array\n {\n $shareUsers = [];\n $shareGroups = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $shareUsers[] = $sharedUser->getUuid();\n }\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n $shareGroups[] = $sharedGroup->getUuid();\n }\n }\n\n return [$shareUsers, $shareGroups];\n }\n\n private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void\n {\n if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {\n // Disable and orphan any AutomatedReports that use this prompt\n $prompt->automatedReports()->withTrashed()->update([\n 'ask_anything_prompt_id' => null,\n 'status' => false,\n ]);\n\n // Delete only if there are no other relations to it.\n $this->askAnythingRepository->deletePrompt($prompt);\n }\n }\n\n private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void\n {\n [$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);\n $this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);\n }\n\n private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array\n {\n $sharedUsersIds = [];\n $sharedUsersRemovedIds = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedPrompt->isRemoved() === true) {\n $sharedUsersRemovedIds[] = $sharedUser->getId();\n }\n if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $sharedUsersIds[] = $sharedUser->getId();\n $this->askAnythingRepository->createPrompt(\n $sharedUser,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n $sharedPrompt->delete();\n }\n }\n\n return [$sharedUsersIds, $sharedUsersRemovedIds];\n }\n\n private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void\n {\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n foreach ($sharedGroup->getMembers() as $member) {\n if (! in_array($member->getId(), $sharedUsersIds)\n && ! in_array($member->getId(), $sharedUsersRemovedIds)) {\n $sharedUsersIds[] = $member->getId();\n $this->askAnythingRepository->createPrompt(\n $member,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n }\n }\n $sharedPrompt->delete();\n }\n }\n }\n}","depth":4,"bounds":{"left":0.15990691,"top":0.0,"width":0.38098404,"height":1.0},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\AskAnything;\n\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\n\nclass AskAnythingPromptService\n{\n public function __construct(\n private readonly AskAnythingRepository $askAnythingRepository,\n private readonly UserRepository $userRepository,\n private readonly GroupRepositoryInterface $groupRepository,\n ) {\n }\n\n /**\n * @return array<AskAnythingPromptDto>\n */\n public function get(User $user, AskAnythingPromptTarget $target): array\n {\n $prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(\n $user,\n $target\n );\n\n $promptDtos = [];\n foreach ($prompts as $prompt) {\n $ownerUuid = null;\n if ($prompt->getOwner() !== null) {\n $ownerUuid = $prompt->getOwner()->getUuid();\n }\n $shareUsers = null;\n $shareGroups = null;\n\n // Provide users and groups only if owner of the prompt is current user\n if ($prompt->getOwnerId() === $user->getId()) {\n [$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);\n }\n\n $promptDtos[] = new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $ownerUuid,\n $shareUsers,\n $shareGroups,\n $prompt->has_reports,\n );\n }\n\n return $promptDtos;\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n */\n public function create(\n User $user,\n string $title,\n string $content,\n AskAnythingPromptTarget $target,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n $prompt = $this->askAnythingRepository->createPrompt(\n $user,\n $target,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n\n return new AskAnythingPromptDto(\n $prompt->getUuid(),\n $prompt->getTitle(),\n $prompt->getContent(),\n $target,\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $prompt->has_reports,\n );\n }\n\n /**\n * @param array<string> $shareUsersUuids\n * @param array<string> $shareGroupsUuids\n *\n * @throws InvalidArgumentException\n */\n public function edit(\n AskAnythingPrompt $prompt,\n User $user,\n string $title,\n string $content,\n array $shareUsersUuids,\n array $shareGroupsUuids\n ): AskAnythingPromptDto {\n $shareUsers = $shareGroups = [];\n foreach ($shareUsersUuids as $userUuid) {\n $shareUsers[] = $this->userRepository->findByUuid($userUuid);\n }\n foreach ($shareGroupsUuids as $groupUuid) {\n $shareGroups[] = $this->groupRepository->findByUuid($groupUuid);\n }\n\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n\n $newPrompt = $this->askAnythingRepository->createPrompt(\n $user,\n $prompt->getTarget(),\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $newPrompt = $this->askAnythingRepository->editPrompt(\n $prompt,\n $title,\n $content,\n $shareUsers,\n $shareGroups,\n );\n } else {\n throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());\n }\n\n return new AskAnythingPromptDto(\n $newPrompt->getUuid(),\n $newPrompt->getTitle(),\n $newPrompt->getContent(),\n $newPrompt->getTarget(),\n $user->getUuid(),\n $shareUsersUuids,\n $shareGroupsUuids,\n $newPrompt->has_reports,\n );\n }\n\n public function delete(\n AskAnythingPrompt $prompt,\n User $user\n ): AskAnythingPrompt {\n if ($prompt->isDefaultPrompt()) {\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } elseif ($prompt->getOwnerId() === $user->getId()) {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $userPrompt?->delete();\n // For each relation, re-create the prompt for the receiver as their own\n $this->recreatePromptsForEachRelation($prompt);\n\n // Finally, delete the prompt\n $this->deletePromptIfNoRelations($prompt);\n } else {\n $userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);\n $groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);\n\n // If the prompt is shared directly with the user, then \"unshare\" it\n if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {\n $userPrompt->delete();\n $this->deletePromptIfNoRelations($prompt);\n } elseif ($groupPrompt instanceof UserAskAnythingPrompt) {\n // If the prompt is shared with the user and the group, then hide it for this user\n $this->askAnythingRepository->hidePromptForUser($prompt, $user);\n } else {\n throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());\n }\n }\n\n return $prompt;\n }\n\n public function reorder(\n User $user,\n array $promptUuids,\n ): void {\n foreach ($promptUuids as $index => $promptUuid) {\n $prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);\n $this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);\n }\n }\n\n /**\n * @param AskAnythingPrompt $prompt\n *\n * @return array[array<string>, array<string>]\n */\n private function getReceiverUuids(AskAnythingPrompt $prompt): array\n {\n $shareUsers = [];\n $shareGroups = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $shareUsers[] = $sharedUser->getUuid();\n }\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n $shareGroups[] = $sharedGroup->getUuid();\n }\n }\n\n return [$shareUsers, $shareGroups];\n }\n\n private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void\n {\n if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {\n // Disable and orphan any AutomatedReports that use this prompt\n $prompt->automatedReports()->withTrashed()->update([\n 'ask_anything_prompt_id' => null,\n 'status' => false,\n ]);\n\n // Delete only if there are no other relations to it.\n $this->askAnythingRepository->deletePrompt($prompt);\n }\n }\n\n private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void\n {\n [$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);\n $this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);\n }\n\n private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array\n {\n $sharedUsersIds = [];\n $sharedUsersRemovedIds = [];\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedUser = $sharedPrompt->getUser();\n if ($sharedPrompt->isRemoved() === true) {\n $sharedUsersRemovedIds[] = $sharedUser->getId();\n }\n if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {\n $sharedUsersIds[] = $sharedUser->getId();\n $this->askAnythingRepository->createPrompt(\n $sharedUser,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n $sharedPrompt->delete();\n }\n }\n\n return [$sharedUsersIds, $sharedUsersRemovedIds];\n }\n\n private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void\n {\n foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {\n $sharedGroup = $sharedPrompt->getGroup();\n if ($sharedGroup instanceof Group) {\n foreach ($sharedGroup->getMembers() as $member) {\n if (! in_array($member->getId(), $sharedUsersIds)\n && ! in_array($member->getId(), $sharedUsersRemovedIds)) {\n $sharedUsersIds[] = $member->getId();\n $this->askAnythingRepository->createPrompt(\n $member,\n $prompt->getTarget(),\n $prompt->getTitle(),\n $prompt->getContent(),\n [],\n [],\n );\n }\n }\n $sharedPrompt->delete();\n }\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
395026636455006835
|
1126917008115010046
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
4
2
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\AskAnything;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
class AskAnythingPromptService
{
public function __construct(
private readonly AskAnythingRepository $askAnythingRepository,
private readonly UserRepository $userRepository,
private readonly GroupRepositoryInterface $groupRepository,
) {
}
/**
* @return array<AskAnythingPromptDto>
*/
public function get(User $user, AskAnythingPromptTarget $target): array
{
$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(
$user,
$target
);
$promptDtos = [];
foreach ($prompts as $prompt) {
$ownerUuid = null;
if ($prompt->getOwner() !== null) {
$ownerUuid = $prompt->getOwner()->getUuid();
}
$shareUsers = null;
$shareGroups = null;
// Provide users and groups only if owner of the prompt is current user
if ($prompt->getOwnerId() === $user->getId()) {
[$shareUsers, $shareGroups] = $this->getReceiverUuids($prompt);
}
$promptDtos[] = new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$ownerUuid,
$shareUsers,
$shareGroups,
$prompt->has_reports,
);
}
return $promptDtos;
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*/
public function create(
User $user,
string $title,
string $content,
AskAnythingPromptTarget $target,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
$prompt = $this->askAnythingRepository->createPrompt(
$user,
$target,
$title,
$content,
$shareUsers,
$shareGroups,
);
return new AskAnythingPromptDto(
$prompt->getUuid(),
$prompt->getTitle(),
$prompt->getContent(),
$target,
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$prompt->has_reports,
);
}
/**
* @param array<string> $shareUsersUuids
* @param array<string> $shareGroupsUuids
*
* @throws InvalidArgumentException
*/
public function edit(
AskAnythingPrompt $prompt,
User $user,
string $title,
string $content,
array $shareUsersUuids,
array $shareGroupsUuids
): AskAnythingPromptDto {
$shareUsers = $shareGroups = [];
foreach ($shareUsersUuids as $userUuid) {
$shareUsers[] = $this->userRepository->findByUuid($userUuid);
}
foreach ($shareGroupsUuids as $groupUuid) {
$shareGroups[] = $this->groupRepository->findByUuid($groupUuid);
}
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
$newPrompt = $this->askAnythingRepository->createPrompt(
$user,
$prompt->getTarget(),
$title,
$content,
$shareUsers,
$shareGroups,
);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$newPrompt = $this->askAnythingRepository->editPrompt(
$prompt,
$title,
$content,
$shareUsers,
$shareGroups,
);
} else {
throw new InvalidArgumentException('Edit not allowed for prompt ' . $prompt->getUuid());
}
return new AskAnythingPromptDto(
$newPrompt->getUuid(),
$newPrompt->getTitle(),
$newPrompt->getContent(),
$newPrompt->getTarget(),
$user->getUuid(),
$shareUsersUuids,
$shareGroupsUuids,
$newPrompt->has_reports,
);
}
public function delete(
AskAnythingPrompt $prompt,
User $user
): AskAnythingPrompt {
if ($prompt->isDefaultPrompt()) {
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} elseif ($prompt->getOwnerId() === $user->getId()) {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$userPrompt?->delete();
// For each relation, re-create the prompt for the receiver as their own
$this->recreatePromptsForEachRelation($prompt);
// Finally, delete the prompt
$this->deletePromptIfNoRelations($prompt);
} else {
$userPrompt = $this->askAnythingRepository->findSharedPromptByUser($prompt->getId(), $user);
$groupPrompt = $this->askAnythingRepository->findSharedPromptByUserGroup($prompt->getId(), $user);
// If the prompt is shared directly with the user, then "unshare" it
if ($userPrompt instanceof UserAskAnythingPrompt && $groupPrompt === null) {
$userPrompt->delete();
$this->deletePromptIfNoRelations($prompt);
} elseif ($groupPrompt instanceof UserAskAnythingPrompt) {
// If the prompt is shared with the user and the group, then hide it for this user
$this->askAnythingRepository->hidePromptForUser($prompt, $user);
} else {
throw new InvalidArgumentException('Unknown delete allowance for prompt ' . $prompt->getUuid());
}
}
return $prompt;
}
public function reorder(
User $user,
array $promptUuids,
): void {
foreach ($promptUuids as $index => $promptUuid) {
$prompt = $this->askAnythingRepository->getPromptByUuid($promptUuid);
$this->askAnythingRepository->orderPromptForUser($prompt, $user, $index + 1);
}
}
/**
* @param AskAnythingPrompt $prompt
*
* @return array[array<string>, array<string>]
*/
private function getReceiverUuids(AskAnythingPrompt $prompt): array
{
$shareUsers = [];
$shareGroups = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedUser instanceof User && $sharedUser->isStatusActive()) {
$shareUsers[] = $sharedUser->getUuid();
}
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
$shareGroups[] = $sharedGroup->getUuid();
}
}
return [$shareUsers, $shareGroups];
}
private function deletePromptIfNoRelations(AskAnythingPrompt $prompt): void
{
if ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId())->isEmpty()) {
// Disable and orphan any AutomatedReports that use this prompt
$prompt->automatedReports()->withTrashed()->update([
'ask_anything_prompt_id' => null,
'status' => false,
]);
// Delete only if there are no other relations to it.
$this->askAnythingRepository->deletePrompt($prompt);
}
}
private function recreatePromptsForEachRelation(AskAnythingPrompt $prompt): void
{
[$sharedUsersIds, $sharedUsersRemovedIds] = $this->recreatePromptsForUserRelations($prompt);
$this->recreatePromptsForGroupRelations($prompt, $sharedUsersIds, $sharedUsersRemovedIds);
}
private function recreatePromptsForUserRelations(AskAnythingPrompt $prompt): array
{
$sharedUsersIds = [];
$sharedUsersRemovedIds = [];
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedUser = $sharedPrompt->getUser();
if ($sharedPrompt->isRemoved() === true) {
$sharedUsersRemovedIds[] = $sharedUser->getId();
}
if ($sharedPrompt->isRemoved() !== true && $sharedUser instanceof User && $sharedUser->isStatusActive()) {
$sharedUsersIds[] = $sharedUser->getId();
$this->askAnythingRepository->createPrompt(
$sharedUser,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
$sharedPrompt->delete();
}
}
return [$sharedUsersIds, $sharedUsersRemovedIds];
}
private function recreatePromptsForGroupRelations(AskAnythingPrompt $prompt, array $sharedUsersIds, array $sharedUsersRemovedIds): void
{
foreach ($this->askAnythingRepository->findSharedUsersAndGroupsByPromptId($prompt->getId()) as $sharedPrompt) {
$sharedGroup = $sharedPrompt->getGroup();
if ($sharedGroup instanceof Group) {
foreach ($sharedGroup->getMembers() as $member) {
if (! in_array($member->getId(), $sharedUsersIds)
&& ! in_array($member->getId(), $sharedUsersRemovedIds)) {
$sharedUsersIds[] = $member->getId();
$this->askAnythingRepository->createPrompt(
$member,
$prompt->getTarget(),
$prompt->getTitle(),
$prompt->getContent(),
[],
[],
);
}
}
$sharedPrompt->delete();
}
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56690
|
NULL
|
NULL
|
NULL
|
|
56694
|
1971
|
58
|
2026-05-19T08:16:48.873442+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178608873_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiectC ActivityController.ong© AskAnythingController.phpD AskAnythingAskAnytingPromptserwice.onppip api_vc.ong(C) AutomatedReport.pnpvm DtosAskJiminnykeporscontroller.png©) AskAnyt© AskAnythingPromptDto.phpD eventsclass AskAnythingPromptServiceAsKAnytningPromptservice.ongpublic functionconstructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository,D1...5w country1 Dataoase→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconkoC Gong- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasIM NudaeM Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistProphetDronhotAfpublic function get(User Suser, AskAnythingPromptTarget $target): array$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(srargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nutuo *sowneruurd = soromort->qetuwner@->qeruurdonsshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharelsens. SshareGrouns = Sthis->aetRecenverluidsSoromot):SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentoStargerSownerUuid,sshareusersno parametersSchareGroups,$prompt->getHasReports(Dreturn soromorutos.* Ooaram arrauz or aedits shoX Reject File 4%€+ 1 of 3 files →enrecated. If vou're not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the diies for other languages. (today 10:00)© Search.php• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:48AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 ct ›146 0>151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}Ipublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reports.AskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumCaving "faVsco.is' settingsWN Windsurf Teams50-40UTF.8io 4 spaces...
|
NULL
|
-246570546310507809
|
NULL
|
click
|
ocr
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiectC ActivityController.ong© AskAnythingController.phpD AskAnythingAskAnytingPromptserwice.onppip api_vc.ong(C) AutomatedReport.pnpvm DtosAskJiminnykeporscontroller.png©) AskAnyt© AskAnythingPromptDto.phpD eventsclass AskAnythingPromptServiceAsKAnytningPromptservice.ongpublic functionconstructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository,D1...5w country1 Dataoase→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconkoC Gong- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasIM NudaeM Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistProphetDronhotAfpublic function get(User Suser, AskAnythingPromptTarget $target): array$prompts = $this->askAnythingRepository->findPromptsByUserAndTarget(srargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nutuo *sowneruurd = soromort->qetuwner@->qeruurdonsshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharelsens. SshareGrouns = Sthis->aetRecenverluidsSoromot):SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentoStargerSownerUuid,sshareusersno parametersSchareGroups,$prompt->getHasReports(Dreturn soromorutos.* Ooaram arrauz or aedits shoX Reject File 4%€+ 1 of 3 files →enrecated. If vou're not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the diies for other languages. (today 10:00)© Search.php• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:48AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 ct ›146 0>151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}Ipublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reports.AskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend service tect covers nromnt delete navload.G..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumCaving "faVsco.is' settingsWN Windsurf Teams50-40UTF.8io 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56693
|
1970
|
46
|
2026-05-19T08:16:48.914892+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178608914_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptService.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:48Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
-1689924722068916561
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:48Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56695
|
1970
|
47
|
2026-05-19T08:16:53.333025+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178613333_m1.jpg...
|
Firefox
|
NULL
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:53Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
-5329796262622018275
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:53Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
56693
|
NULL
|
NULL
|
NULL
|
|
56696
|
1971
|
59
|
2026-05-19T08:16:53.337413+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178613337_m2.jpg...
|
PhpStorm
|
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiectC ActivityController.ong© AskAnythingController.phpD AskAnythingAskAnytingPromptserwice.onppip api_vc.ong(C) AutomatedReport.pnpvm DtosAskJiminnykeporscontroller.png© AskAnythingPrompt.php x © Search.php© AskAnythingPromptDto.phpD eventsAsKAnytningPromptservice.ongpublic functionconstructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository.D1...5w country1 Database→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconko[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasM Notilicationn NudaeM Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistDronhotDronhotAf*@return_arrau<AskAnuthinaPromnt0to>public function get(User $user, AskAnythingPromptTarget $target): array$prompts = Sthis->askAnythingRepository->findPromptsByUserAndTarget(stargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nulu *sowneruurd = soromort->qetuwnero->qeruurd:sshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharellsens. SshareGrouns = Sthis->aetRecerverluidsSoromot)•SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentolStargerSownerUuid,sshareusersSchareGroups.$prompt->getHasReportsOreturn soromorutos.* Cparam arrây «str 1ngis sshaX Reject File 4%€+ 1 of 3 files →enrecated. If vou're not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the diies for other languages. (today 10:00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:53U AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 Gt ›146 C151 C1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function __construct(UserRepository $userRepository)f...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...?lpublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teamc51-48 UTE.8Po 4 spaces...
|
NULL
|
2165083458000167189
|
NULL
|
click
|
ocr
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiectC ActivityController.ong© AskAnythingController.phpD AskAnythingAskAnytingPromptserwice.onppip api_vc.ong(C) AutomatedReport.pnpvm DtosAskJiminnykeporscontroller.png© AskAnythingPrompt.php x © Search.php© AskAnythingPromptDto.phpD eventsAsKAnytningPromptservice.ongpublic functionconstructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository.D1...5w country1 Database→ DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM SloquentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconko[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasM Notilicationn NudaeM Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistDronhotDronhotAf*@return_arrau<AskAnuthinaPromnt0to>public function get(User $user, AskAnythingPromptTarget $target): array$prompts = Sthis->askAnythingRepository->findPromptsByUserAndTarget(stargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nulu *sowneruurd = soromort->qetuwnero->qeruurd:sshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharellsens. SshareGrouns = Sthis->aetRecerverluidsSoromot)•SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentolStargerSownerUuid,sshareusersSchareGroups.$prompt->getHasReportsOreturn soromorutos.* Cparam arrây «str 1ngis sshaX Reject File 4%€+ 1 of 3 files →enrecated. If vou're not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the diies for other languages. (today 10:00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:53U AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 Gt ›146 C151 C1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function __construct(UserRepository $userRepository)f...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...?lpublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teamc51-48 UTE.8Po 4 spaces...
|
56694
|
NULL
|
NULL
|
NULL
|
|
56697
|
1970
|
48
|
2026-05-19T08:16:55.852050+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178615852_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPrompt.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:55Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
4080323406144176184
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov®. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3h 44 m100% <73• Tue 19 May 11:16:55Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56699
|
1971
|
60
|
2026-05-19T08:16:57.717937+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178617717_m2.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiectC ActivityController.ongpip aplionp© AskAnythingController.phpD AskAnythingAskAnytingPromptserwice.onp© AskAnythingPrompt.phpphp api_v2.phpvm Dtosc) Automateakeport.pnp©) AskAnythingPromptServiceTest.php© Search.php© AskAnythingPromptDto.phpD eventsAsKAnytningPromptservice.ongpublic function constructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository.D1...5w country1 DataoaseD DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM sloauentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconko[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasM NotilicationIM Nudae1M Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistDronhotDronhotAf*@return_arrau<AskAnuthinaPromnt0to>public function get(User $user, AskAnythingPromptTarget $target): array$prompts = Sthis->askAnythingRepository->findPromptsByUserAndTarget(srargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nulu *sowneruurd = soromort->qetuwnero->qeruurd:sshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharellsens. SshareGrouns = Sthis->aetRecerverluidsSoromot)•SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentoStargerSownerUuid,sshareusersSshareGroups$prompt->getHasReportsOreturn soromoruros.* Cparam arrây «str 1ngis sshaX Reject File 4%€+ 1 of 3 files →enrecated. If vou're not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the diies for other languages. (today 10:00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:57AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 Gt ›146 C151 C1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function __construct(UserRepository $userRepository)f...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...?lpublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that filejusers/lukas//1niny/app/tests/Feature/Htp/Contro1lers/APZ/VZ/AskJininnyReportsContro1lerTest.e" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumWN Windsurf Teamc51-48 UTE.8Po 4 spaces...
|
NULL
|
-3461938994727916470
|
NULL
|
click
|
ocr
|
NULL
|
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-d PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiectC ActivityController.ongpip aplionp© AskAnythingController.phpD AskAnythingAskAnytingPromptserwice.onp© AskAnythingPrompt.phpphp api_v2.phpvm Dtosc) Automateakeport.pnp©) AskAnythingPromptServiceTest.php© Search.php© AskAnythingPromptDto.phpD eventsAsKAnytningPromptservice.ongpublic function constructchistorvservice.ono0 AskJiminnyAiD AWSw cache&NBNprivate readonly AskAnythingRepository $askAnythingRepository,private readonly UserRepository SuserRepository,private readonly GroupRepositoryInterface $groupRepository.D1...5w country1 DataoaseD DatadogN DateTtimeN DealinsiahtsN DealRisksIM SlacticSearchM sloauentEncodingD EncryptionM Saken1 FeaturerlagsWrrMpegD FileSystemMconko[ Gong.- GuzzleHttpW KeyPointsW KIOSKDLoCKS2 MediaPioeline/ MobileSettinasM NotilicationIM Nudae1M Paragranh BreakerM PartitionedCookieM PlavbackPadeM PlavlistDronhotDronhotAf*@return_arrau<AskAnuthinaPromnt0to>public function get(User $user, AskAnythingPromptTarget $target): array$prompts = Sthis->askAnythingRepository->findPromptsByUserAndTarget(srargetspromptutos =foreach ($prompts as Sprompt) {1t Cspromot->oeruwnero == nulu *sowneruurd = soromort->qetuwnero->qeruurd:sshareGroups = null.Provide users and aroups only if owner of the promot is current usenif (Soromot->aetOwnerId() === Suser->aetId0) ≤Ssharellsens. SshareGrouns = Sthis->aetRecerverluidsSoromot)•SoromotDtosl=new_AskAnvthinaPromot0toSoromot->aetluido$prompt->getTitle,Snnomnt.>aotContentoStargerSownerUuid,sshareusersSshareGroups$prompt->getHasReportsOreturn soromoruros.* Cparam arrây «str 1ngis sshaX Reject File 4%€+ 1 of 3 files →enrecated. If vou're not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the diies for other languages. (today 10:00)• supoont Dally • In 3n 44 m100% 5• Tue 19 May 11:16:57AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclarelscrict_cypes=1)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 Gt ›146 C151 C1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function __construct(UserRepository $userRepository)f...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...?lpublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that filejusers/lukas//1niny/app/tests/Feature/Htp/Contro1lers/APZ/VZ/AskJininnyReportsContro1lerTest.e" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..3 files +22 -5>Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumWN Windsurf Teamc51-48 UTE.8Po 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56698
|
1970
|
49
|
2026-05-19T08:16:59.096200+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178619096_m1.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"9","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.016666668,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.014583333,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-3318323997297636737
|
-6976847208096224411
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56697
|
NULL
|
NULL
|
NULL
|
|
56700
|
1971
|
61
|
2026-05-19T08:17:00.608842+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178620608_m2.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"9","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-3318323997297636737
|
-6976847208096224411
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56699
|
NULL
|
NULL
|
NULL
|
|
56701
|
1970
|
50
|
2026-05-19T08:17:04.286756+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178624286_m1.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKERO ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKERO ₴1DEV (-zsh)₴2app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3 h 43 m100% <73• Tue 19 May 11:17:04Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
-2921992861596063823
|
NULL
|
click
|
ocr
|
NULL
|
SlackFileEditViewGoHistoryWindowHelpAPPDOCKERO ₴1D SlackFileEditViewGoHistoryWindowHelpAPPDOCKERO ₴1DEV (-zsh)₴2app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3 h 43 m100% <73• Tue 19 May 11:17:04Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56702
|
1971
|
62
|
2026-05-19T08:17:04.298326+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178624298_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormProiectVIewINavicarecodeLaravelRefactorTOO PhostormProiectVIewINavicarecodeLaravelRefactorTOOISWindowFV faVsco.js?9 JY-20676-delete-report-related-objectsC ActivityController.ong© AskAnythingController.php= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyurrosoeclupedlea.ong© SetupintegrationEvent.php© stageupaatea.ong© StatusUpdated.phpIlleupoatea.onpGIrackimporteatvent.ong© TrackReady.php0 AiAutomation• AicaliscorinaW AuthAutomatedReportsW CalendarslimoortM NudaesM PlavbooksM PlavlistsM SidokickM Teamsfh TranscrintionMlisersC Event.phpc) EventDispatcher.onpD ExceptionsD FFMpeg0 FormatsC Guards> 0 HelpersC Http> @ AccessTokenProvider0 ControllersV DAP.• DAIcalscorinoAlReports. M DealinsiahtsOoportunityM Page• # ScorecardsD SettingsIM TeaminsiahtsD Themesv MUserAutomatedRenorts© AskAnythingPromptService.php© AutomatedReport.php© AskAnythingPrompt.phpphp api_v2.php© Search.phpA console [STAGING]© CoachingFeedbackCoachUserln.php Xstoheclass Asku1minnykeporcstoncrotler excenas concrouter124125126 C"t_types=1)~/jiminny/app/tests/Unit/Component/AskAnything/AskAnythingPromptServiceTest.php* loggle ASk Jiminny report scacuslenable/uisanamespace Jiminny Component Activ1tySearch Filterder1n1t1on:PATCH /api/v2/ai-reports/{uuid) (api.v2.ai-reports.togale-status]public tunction togqlestatus Request Srequest, string suuld: Jsonresponse› use ...150v Mv2161© UserAutomatedReportsController.f 162163@ ActivityV2Controller.php0) AckAnvthinaController. nhn164165AskJiminnyReportsController.php166(e) NonleW2Controller nhn167© OnDemandV2Controller.php** dvar User Suser *Suser = Srequest->userO:final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterfacetry {srenort=sthis->automatedRenortsservice->cetReoortsuu1d:1usadeorivate const int No GROUP 10 = 999-3 usagesorivate UserRenository suserRenository:if (Sthis->isNot0wnedByUser(Sreport, $user)) 1return new JsonResponse(l'error'=> 'Report not found'], status: Response::HTTP_NOT_FOUNpublic function__construct(UserRepository $userRepository)1...h29 Ф >public function shouldApplyQueries: boolf...}Senahiled = thoolb Srenuest->innut( kev "enahi ed!)•Reriect34 đ >public function getQueries: FilterDefinitionQueryCollection{...}if (Senabled && Sreport->isAskJiminnyReportO){if (Sreport->getActivitySearchId === null || Sreport->getAskAnythingPromptId ===*recurn new JsonResponsed['error' => 'Cannot enable report with missing saved search or prompt'],status: Response::HTTP_UNPROCESSABLE_ENTITY45 đ >public function toArray@: array{...;private function getOptions(): array{...}public function getValue®: array{...}Sdata = Sthis->automatedReportsService->updateAskJiminnvReportStatus(private function getDefaultValue: array{...}sreport(bool) Srequest->input('enabled'),135136 @t›public function aetValidationRules(2strina Sorefix = null): arrav{...?lSenabled.146 đt ›public function aetSortOrder@: intf...}return new IsonResnonse(Sdata).} catch (ModelNotFoundException $e) {return new JsonResponse(['error' => $e->getMessageO].status: Resnonse: •HTTP NOT FOUND).catchThrowable Se)151 G>public function shouldBeIncluded(Team $team): bool{...}$this->logger->error('Failed to toggle Ask Jiminny report status', [tonnont -s Co-SaotMoccanoo'user_id' => $user->getId(),Iuidi -s Suuidlreturn new JsonResponse(['error' => 'Failed to toggle report status'].status: Response::HIIP INICKNAL SERVEKERRURAccept File &+X Reject File 4%€+ 2 of 3 files →The Huncnell nluain hac heon denrecated. If voulre not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the dictiaries for other languages. (today 10:00)• suppont Dally • In 3n 43 m100% 5• Tue 19 May 11:17:04U AskJiminnyReportActivityServiceTest v+O •CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAucomatedkeport exists. Ine saved-searen list enapoint now includes nas_reportsAskAnvthinaPromot.oho- Added has reports to Saopends and a getHasRevortsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teams110-68UTF.RPo 4 spaces...
|
NULL
|
-1684172407547281935
|
NULL
|
click
|
ocr
|
NULL
|
PhostormProiectVIewINavicarecodeLaravelRefactorTOO PhostormProiectVIewINavicarecodeLaravelRefactorTOOISWindowFV faVsco.js?9 JY-20676-delete-report-related-objectsC ActivityController.ong© AskAnythingController.php= custom.log= laravel.log4 SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyurrosoeclupedlea.ong© SetupintegrationEvent.php© stageupaatea.ong© StatusUpdated.phpIlleupoatea.onpGIrackimporteatvent.ong© TrackReady.php0 AiAutomation• AicaliscorinaW AuthAutomatedReportsW CalendarslimoortM NudaesM PlavbooksM PlavlistsM SidokickM Teamsfh TranscrintionMlisersC Event.phpc) EventDispatcher.onpD ExceptionsD FFMpeg0 FormatsC Guards> 0 HelpersC Http> @ AccessTokenProvider0 ControllersV DAP.• DAIcalscorinoAlReports. M DealinsiahtsOoportunityM Page• # ScorecardsD SettingsIM TeaminsiahtsD Themesv MUserAutomatedRenorts© AskAnythingPromptService.php© AutomatedReport.php© AskAnythingPrompt.phpphp api_v2.php© Search.phpA console [STAGING]© CoachingFeedbackCoachUserln.php Xstoheclass Asku1minnykeporcstoncrotler excenas concrouter124125126 C"t_types=1)~/jiminny/app/tests/Unit/Component/AskAnything/AskAnythingPromptServiceTest.php* loggle ASk Jiminny report scacuslenable/uisanamespace Jiminny Component Activ1tySearch Filterder1n1t1on:PATCH /api/v2/ai-reports/{uuid) (api.v2.ai-reports.togale-status]public tunction togqlestatus Request Srequest, string suuld: Jsonresponse› use ...150v Mv2161© UserAutomatedReportsController.f 162163@ ActivityV2Controller.php0) AckAnvthinaController. nhn164165AskJiminnyReportsController.php166(e) NonleW2Controller nhn167© OnDemandV2Controller.php** dvar User Suser *Suser = Srequest->userO:final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterfacetry {srenort=sthis->automatedRenortsservice->cetReoortsuu1d:1usadeorivate const int No GROUP 10 = 999-3 usagesorivate UserRenository suserRenository:if (Sthis->isNot0wnedByUser(Sreport, $user)) 1return new JsonResponse(l'error'=> 'Report not found'], status: Response::HTTP_NOT_FOUNpublic function__construct(UserRepository $userRepository)1...h29 Ф >public function shouldApplyQueries: boolf...}Senahiled = thoolb Srenuest->innut( kev "enahi ed!)•Reriect34 đ >public function getQueries: FilterDefinitionQueryCollection{...}if (Senabled && Sreport->isAskJiminnyReportO){if (Sreport->getActivitySearchId === null || Sreport->getAskAnythingPromptId ===*recurn new JsonResponsed['error' => 'Cannot enable report with missing saved search or prompt'],status: Response::HTTP_UNPROCESSABLE_ENTITY45 đ >public function toArray@: array{...;private function getOptions(): array{...}public function getValue®: array{...}Sdata = Sthis->automatedReportsService->updateAskJiminnvReportStatus(private function getDefaultValue: array{...}sreport(bool) Srequest->input('enabled'),135136 @t›public function aetValidationRules(2strina Sorefix = null): arrav{...?lSenabled.146 đt ›public function aetSortOrder@: intf...}return new IsonResnonse(Sdata).} catch (ModelNotFoundException $e) {return new JsonResponse(['error' => $e->getMessageO].status: Resnonse: •HTTP NOT FOUND).catchThrowable Se)151 G>public function shouldBeIncluded(Team $team): bool{...}$this->logger->error('Failed to toggle Ask Jiminny report status', [tonnont -s Co-SaotMoccanoo'user_id' => $user->getId(),Iuidi -s Suuidlreturn new JsonResponse(['error' => 'Failed to toggle report status'].status: Response::HIIP INICKNAL SERVEKERRURAccept File &+X Reject File 4%€+ 2 of 3 files →The Huncnell nluain hac heon denrecated. If voulre not writing in Hungarian vou can cafolv uninctall Hunsnell without affecting the dictiaries for other languages. (today 10:00)• suppont Dally • In 3n 43 m100% 5• Tue 19 May 11:17:04U AskJiminnyReportActivityServiceTest v+O •CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAucomatedkeport exists. Ine saved-searen list enapoint now includes nas_reportsAskAnvthinaPromot.oho- Added has reports to Saopends and a getHasRevortsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..3 files +22 -5>Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teams110-68UTF.RPo 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56704
|
1971
|
63
|
2026-05-19T08:17:07.778174+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178627778_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
7940324247802638747
|
-8683903597217656915
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
56702
|
NULL
|
NULL
|
NULL
|
|
56703
|
1970
|
51
|
2026-05-19T08:17:07.800844+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178627800_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
2693982519169618950
|
-8683903597217656915
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All...
|
56701
|
NULL
|
NULL
|
NULL
|
|
56705
|
1970
|
52
|
2026-05-19T08:17:10.511280+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178630511_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-6966022010367698874
|
-564708849257816637
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3 h 43 m100% <73• Tue 19 May 11:17:10Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56706
|
1971
|
64
|
2026-05-19T08:17:10.523753+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178630523_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4701279590415171657
|
-8204420343923494970
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-rProiect• M Auth9 ActivitvAskAnythingTest.php© ExportControllerRateLimitTest.phporakerropnetcllentone) M Middleware>D RequestsInteractions_ InvitationsU JODs_ ListenersD MCP_ Modelsu NouricauionsuOroanizauonserinasRulesa SavedSearchesc SavedSearchcRUdFeatureTest.ondM Search1 ServiceProviders1 ServicesN TeamsQ CustomerApiFeatureTest.php© DeactivateUserFeatureTest.php© FilterScheduledMeetingsFeatureTest.phpNudaeProcessingreature lest.ong@ OrganizationRolesFeatureTest.php© PlanhatServiceFeatureTest.phpaat ScimlsersFeatureTest.phpi ToamPetentionPolicvFeaturelest.onoC [EMAIL]> D Integration0) Services> D StubsC Unit> O Actionscomponent•DActionltems→DActivitvM ActivitvAnalvtics7 ActivitvSearchM AiActi vitvtvoeM AiAutomation>M AiCallScorind•M AckAnvthinglc AckAnvthinaPromntServicetlect nhnC HistorvServiceTest nhn> M Ack liminnvA© AskAnythingController.phpAskAnytningPromptserwice.ong© AskAnythingPrompt.phpphp api_v2.phpc) Automateakeport.pnp© Search.phptunccion cestueleceaskanychlnorromoco. vold$relationMock->shouldReceive( ...methodNames: 'update')->onceO->with(['ask_anything_prompt id' =› null,'status' => falsel):->mechoa con'aucomaceakeporcs')suser->expects(Sth1s->onceopUserAskAnvthinaPromot::class):339sthis->askAnvthinaRenository->expects(Sthis->once0SuserPromot->exnects(Sthis->onceOn'delete'):Sthis->askAnvthinaRenositorv->exnects(Sthis->anv00l'findSharedUsersAndGroupsByPromptId')-swil1Retunn(new Collectiondn)-Sthis-sackAnvthinaRenositonv-seynectc/Sthic-sonceohl350351352->methodd constraint.'deletePrompt'):$this->askAnythingPromptService->delete($prompt, $user):354 D >public function testDeleteAskAnythingPromptWithRelations: void{...}388 D >public function testHideDefaultAskAnythingPromptO: voidf...}400 D>public function testHideSharedWithUserAskAnythingPromptO: void{...}447 D >public function testHideSharedWithUserAndGroupAskAnythingPromptO: void{...}481 D ›public function testHideSharedWithGroupAskAnvthingPromot@): voids...?515 | >public function testDeleteWithNoSharesAndNot0wner(): void{...}550 >nublic function testReorderAskAnvthinaPromotso: voids...~574 0>nublic function testCreateAskAnvthinoPromotWithtwolsenso: voids.A38D >public functin testRecreatel Accept File &- elakieasrile:e yoidi +. of 3 files →ries for other languages. (today 10:00)• suppont Dally • In 3n 43 m100% 5• Tue 19 May 11:17:10AskJiminnyReportActivityServiceTest v+O •= custom.log= laravel.log« SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php X<?phpdeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >118135136 ct ›146 đt ›150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository suserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...}public function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...?lpublic function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload ([*ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..Accent alliramiw ir prom. 3 task per objects. 1. ist with has. reports property. ESearchTransformer. php#L42-49 it is not hereClaude Qnus 1.7 MediumWN Windsurf Teamc228-1 UTE.8Po 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56707
|
1970
|
53
|
2026-05-19T08:17:12.008823+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178632008_m1.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4508527917909716569
|
-8683903597217656915
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
56705
|
NULL
|
NULL
|
NULL
|
|
56708
|
1971
|
65
|
2026-05-19T08:17:12.045097+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178632045_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false}]...
|
-7601088069291092266
|
-8698540296006611025
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}...
|
56706
|
NULL
|
NULL
|
NULL
|
|
56709
|
1971
|
66
|
2026-05-19T08:17:12.573975+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178632573_m2.jpg...
|
PhpStorm
|
faVsco.js – AskAnythingPromptServiceTest.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.3929521,"top":0.12529927,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.40292552,"top":0.12529927,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.4119016,"top":0.123703115,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.4192154,"top":0.123703115,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Tests\\Unit\\Component\\AskAnything;\n\nuse Illuminate\\Database\\Eloquent\\Collection;\nuse Jiminny\\Component\\AskAnything\\AskAnythingPromptService;\nuse Jiminny\\Component\\AskAnything\\Dtos\\AskAnythingPromptDto;\nuse Jiminny\\Contracts\\Repositories\\GroupRepositoryInterface;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPrompt;\nuse Jiminny\\Models\\AskAnything\\AskAnythingPromptTarget;\nuse Jiminny\\Models\\AskAnything\\UserAskAnythingPrompt;\nuse Jiminny\\Models\\Group;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\AskAnythingRepository;\nuse Jiminny\\Repositories\\UserRepository;\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse Tests\\TestCase;\nuse Tests\\Unit\\Traits\\TestPrivateMethod;\n\nclass AskAnythingPromptServiceTest extends TestCase\n{\n use TestPrivateMethod;\n\n private AskAnythingPromptService $askAnythingPromptService;\n private AskAnythingRepository&MockObject $askAnythingRepository;\n private UserRepository&MockObject $userRepository;\n private GroupRepositoryInterface&MockObject $groupRepository;\n\n protected function setUp(): void\n {\n $this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);\n $this->userRepository = $this->createMock(UserRepository::class);\n $this->groupRepository = $this->createMock(GroupRepositoryInterface::class);\n\n $this->askAnythingPromptService = new AskAnythingPromptService(\n $this->askAnythingRepository,\n $this->userRepository,\n $this->groupRepository\n );\n }\n\n public function testGetAskAnythingPrompts(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $user->expects($this->any())\n ->method('getUuid')\n ->willReturn('1');\n $defaultPrompt = $this->createMock(AskAnythingPrompt::class);\n $defaultPrompt->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUser->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('First users prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt');\n $promptOwnedByUser->expects($this->once())\n ->method('getId')\n ->willReturn(99);\n $promptOwnedByUser->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getOwner')\n ->willReturn(null);\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getUuid')\n ->willReturn('default-uuid');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getTitle')\n ->willReturn('Sentiment');\n $defaultPromptOrderedByUser->expects($this->once())\n ->method('getContent')\n ->willReturn('What was the overall sentiment of the customer during the call?');\n $promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);\n $promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))\n ->method('getOwner')\n ->willReturn($user);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-2nd-prompt');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getTitle')\n ->willReturn('Prompt shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getContent')\n ->willReturn('Test prompt that is shared with group');\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getId')\n ->willReturn(109);\n $promptOwnedByUserAndSharedWithGroup->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n $group = $this->createMock(Group::class);\n $group->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-group');\n $sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);\n $sharedWithGroup->expects($this->once())\n ->method('getUser')\n ->willReturn(null);\n $sharedWithGroup->expects($this->once())\n ->method('getGroup')\n ->willReturn($group);\n\n $this->askAnythingRepository->expects($this->exactly(2))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [99, new Collection([])],\n [109, new Collection([$sharedWithGroup])],\n ]);\n\n $prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];\n $this->askAnythingRepository->expects($this->once())\n ->method('findPromptsByUserAndTarget')\n ->willReturn(new Collection($prompts));\n\n $expectedDto1 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto2 = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n 'First users prompt',\n 'Test prompt',\n AskAnythingPromptTarget::call,\n '1',\n [],\n [],\n );\n $expectedDto3 = new AskAnythingPromptDto(\n 'default-uuid',\n 'Sentiment',\n 'What was the overall sentiment of the customer during the call?',\n AskAnythingPromptTarget::call\n );\n $expectedDto4 = new AskAnythingPromptDto(\n 'uuid-2nd-prompt',\n 'Prompt shared with group',\n 'Test prompt that is shared with group',\n AskAnythingPromptTarget::call,\n '1',\n [],\n ['uuid-of-the-group'],\n );\n $dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);\n\n $this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);\n }\n\n public function testEditAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(123);\n $prompt->expects($this->never())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(123);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('owner-uuid');\n\n $title = 'new title';\n $content = 'new content';\n $shareUsers = ['us-1'];\n $shareGroups = ['gr-1', 'gr-2'];\n\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $shareGroup1 = $this->createMock(Group::class);\n $shareGroup2 = $this->createMock(Group::class);\n $this->groupRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['gr-1', $shareGroup1],\n ['gr-2', $shareGroup2],\n ]);\n\n $editPrompt = $this->createMock(AskAnythingPrompt::class);\n $editPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $editPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $editPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $editPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $this->askAnythingRepository->expects($this->once())\n ->method('editPrompt')\n ->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])\n ->willReturn($editPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'owner-uuid',\n $shareUsers,\n $shareGroups\n );\n $editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $editDto);\n }\n\n public function testHideDefaultAndCreateAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('new-owner-uuid');\n $title = 'title';\n $content = 'content';\n $shareUsers = ['us-1'];\n $shareGroups = [];\n $shareUser = $this->createMock(User::class);\n $this->userRepository->expects($this->once())\n ->method('findByUuid')\n ->with('us-1')\n ->willReturn($shareUser);\n $this->groupRepository->expects($this->never())\n ->method('findByUuid');\n\n $newPrompt = $this->createMock(AskAnythingPrompt::class);\n $newPrompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $newPrompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-1st-prompt');\n $newPrompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $newPrompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->willReturn($newPrompt);\n\n $expectedDto = new AskAnythingPromptDto(\n 'uuid-1st-prompt',\n $title,\n $content,\n AskAnythingPromptTarget::call,\n 'new-owner-uuid',\n $shareUsers,\n $shareGroups\n );\n\n $actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);\n\n $this->assertEquals($expectedDto, $actualDto);\n }\n\n public function testDeleteAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n\n // Use Mockery for the relationship mock (more flexible)\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->any())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([]));\n $this->askAnythingRepository->expects($this->once())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteAskAnythingPromptWithRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $user = $this->createMock(User::class);\n $user->expects($this->any())\n ->method('getId')\n ->willReturn(1);\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(1, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('findSharedUsersAndGroupsByPromptId')\n ->willReturnMap([\n [1, new Collection([$userPrompt])],\n [1, new Collection([])],\n ]);\n $this->askAnythingRepository->expects($this->never())\n ->method('deletePrompt');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideDefaultAskAnythingPrompt(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(true);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser');\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(3))\n ->method('getId')\n ->willReturn(33);\n\n $relationMock = \\Mockery::mock(\\Illuminate\\Database\\Eloquent\\Relations\\HasMany::class);\n $relationMock->shouldReceive('withTrashed')\n ->once()\n ->andReturnSelf();\n $relationMock->shouldReceive('update')\n ->once()\n ->with(['ask_anything_prompt_id' => null, 'status' => false]);\n $prompt->expects($this->once())\n ->method('automatedReports')\n ->willReturn($relationMock);\n\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->once())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(33)\n ->willReturn(new Collection([]));\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testHideSharedWithGroupAskAnythingPrompt(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn($userPrompt);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->once())\n ->method('hidePromptForUser')\n ->with($prompt, $user);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testDeleteWithNoSharesAndNotOwner(): void\n {\n $userPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('isDefaultPrompt')\n ->willReturn(false);\n $prompt->expects($this->once())\n ->method('getOwnerId')\n ->willReturn(1);\n $prompt->expects($this->exactly(2))\n ->method('getId')\n ->willReturn(33);\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getId')\n ->willReturn(2);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUser')\n ->with(33, $user)\n ->willReturn(null);\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedPromptByUserGroup')\n ->with(33, $user)\n ->willReturn(null);\n $userPrompt->expects($this->never())\n ->method('delete');\n $this->askAnythingRepository->expects($this->never())\n ->method('hidePromptForUser');\n\n $this->expectException(\\InvalidArgumentException::class);\n\n $this->askAnythingPromptService->delete($prompt, $user);\n }\n\n public function testReorderAskAnythingPrompts(): void\n {\n $prompts = ['id1', 'id2', 'id3'];\n $prompt1 = $this->createMock(AskAnythingPrompt::class);\n $prompt2 = $this->createMock(AskAnythingPrompt::class);\n $prompt3 = $this->createMock(AskAnythingPrompt::class);\n $user = $this->createMock(User::class);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('getPromptByUuid')\n ->willReturnMap([\n ['id1', $prompt1],\n ['id2', $prompt2],\n ['id3', $prompt3],\n ]);\n $this->askAnythingRepository->expects($this->exactly(3))\n ->method('orderPromptForUser')\n ->willReturnMap([\n [[$prompt1, $user, 1]],\n [[$prompt2, $user, 2]],\n [[$prompt3, $user, 3]],\n ]);\n $this->askAnythingPromptService->reorder($user, $prompts);\n }\n\n public function testCreateAskAnythingPromptWithTwoUsers(): void\n {\n $user = $this->createMock(User::class);\n $user->expects($this->once())\n ->method('getUuid')\n ->willReturn('uuid-of-the-user');\n $shareUser1 = $this->createMock(User::class);\n $shareUser2 = $this->createMock(User::class);\n $title = 'Test title';\n $content = 'Test content';\n $target = AskAnythingPromptTarget::call;\n $shareUsers = ['us-1', 'us-2'];\n $shareGroups = [];\n\n $this->userRepository->expects($this->exactly(2))\n ->method('findByUuid')\n ->willReturnMap([\n ['us-1', $shareUser1],\n ['us-2', $shareUser2],\n ]);\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getUuid')\n ->willReturn('prompt-1-uuid');\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn($title);\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn($content);\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt')\n ->with(\n $user,\n $target,\n $title,\n $content,\n [$shareUser1, $shareUser2],\n [],\n )\n ->willReturn($prompt);\n\n $expectedPromptDto = new AskAnythingPromptDto(\n 'prompt-1-uuid',\n $title,\n $content,\n $target,\n 'uuid-of-the-user',\n $shareUsers,\n $shareGroups,\n );\n\n $actualPromptDto = $this->askAnythingPromptService->create(\n $user,\n $title,\n $content,\n $target,\n $shareUsers,\n $shareGroups\n );\n\n $this->assertEquals($expectedPromptDto, $actualPromptDto);\n }\n\n public function testRecreatePromptsForUserRelations(): void\n {\n $prompt = $this->createMock(AskAnythingPrompt::class);\n $prompt->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n $prompt->expects($this->once())\n ->method('getTarget')\n ->willReturn(AskAnythingPromptTarget::call);\n $prompt->expects($this->once())\n ->method('getTitle')\n ->willReturn('Test title');\n $prompt->expects($this->once())\n ->method('getContent')\n ->willReturn('Test content');\n\n $sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);\n $sharedUser = $this->createMock(User::class);\n $sharedUser->expects($this->once())\n ->method('isStatusActive')\n ->willReturn(true);\n $sharedUser->expects($this->once())\n ->method('getId')\n ->willReturn(1);\n\n $sharedPrompt->expects($this->once())\n ->method('getUser')\n ->willReturn($sharedUser);\n $sharedPrompt->expects($this->exactly(2))\n ->method('isRemoved')\n ->willReturn(false);\n $sharedPrompt->expects($this->once())\n ->method('delete');\n\n $this->askAnythingRepository->expects($this->once())\n ->method('findSharedUsersAndGroupsByPromptId')\n ->with(1)\n ->willReturn(new Collection([$sharedPrompt]));\n\n $this->askAnythingRepository->expects($this->once())\n ->method('createPrompt');\n\n $data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);\n\n $this->assertEquals([[1], []], $data);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"bounds":{"left":0.011968086,"top":0.047885075,"width":0.024268618,"height":0.024740623},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
5104049655514026863
|
-8683904146973470803
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
6
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Tests\Unit\Component\AskAnything;
use Illuminate\Database\Eloquent\Collection;
use Jiminny\Component\AskAnything\AskAnythingPromptService;
use Jiminny\Component\AskAnything\Dtos\AskAnythingPromptDto;
use Jiminny\Contracts\Repositories\GroupRepositoryInterface;
use Jiminny\Models\AskAnything\AskAnythingPrompt;
use Jiminny\Models\AskAnything\AskAnythingPromptTarget;
use Jiminny\Models\AskAnything\UserAskAnythingPrompt;
use Jiminny\Models\Group;
use Jiminny\Models\User;
use Jiminny\Repositories\AskAnythingRepository;
use Jiminny\Repositories\UserRepository;
use PHPUnit\Framework\MockObject\MockObject;
use Tests\TestCase;
use Tests\Unit\Traits\TestPrivateMethod;
class AskAnythingPromptServiceTest extends TestCase
{
use TestPrivateMethod;
private AskAnythingPromptService $askAnythingPromptService;
private AskAnythingRepository&MockObject $askAnythingRepository;
private UserRepository&MockObject $userRepository;
private GroupRepositoryInterface&MockObject $groupRepository;
protected function setUp(): void
{
$this->askAnythingRepository = $this->createMock(AskAnythingRepository::class);
$this->userRepository = $this->createMock(UserRepository::class);
$this->groupRepository = $this->createMock(GroupRepositoryInterface::class);
$this->askAnythingPromptService = new AskAnythingPromptService(
$this->askAnythingRepository,
$this->userRepository,
$this->groupRepository
);
}
public function testGetAskAnythingPrompts(): void
{
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$user->expects($this->any())
->method('getUuid')
->willReturn('1');
$defaultPrompt = $this->createMock(AskAnythingPrompt::class);
$defaultPrompt->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPrompt->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPrompt->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPrompt->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUser = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUser->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUser->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$promptOwnedByUser->expects($this->once())
->method('getTitle')
->willReturn('First users prompt');
$promptOwnedByUser->expects($this->once())
->method('getContent')
->willReturn('Test prompt');
$promptOwnedByUser->expects($this->once())
->method('getId')
->willReturn(99);
$promptOwnedByUser->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$defaultPromptOrderedByUser = $this->createMock(AskAnythingPrompt::class);
$defaultPromptOrderedByUser->expects($this->once())
->method('getOwner')
->willReturn(null);
$defaultPromptOrderedByUser->expects($this->once())
->method('getUuid')
->willReturn('default-uuid');
$defaultPromptOrderedByUser->expects($this->once())
->method('getTitle')
->willReturn('Sentiment');
$defaultPromptOrderedByUser->expects($this->once())
->method('getContent')
->willReturn('What was the overall sentiment of the customer during the call?');
$promptOwnedByUserAndSharedWithGroup = $this->createMock(AskAnythingPrompt::class);
$promptOwnedByUserAndSharedWithGroup->expects($this->exactly(2))
->method('getOwner')
->willReturn($user);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getUuid')
->willReturn('uuid-2nd-prompt');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getTitle')
->willReturn('Prompt shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getContent')
->willReturn('Test prompt that is shared with group');
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getId')
->willReturn(109);
$promptOwnedByUserAndSharedWithGroup->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$group = $this->createMock(Group::class);
$group->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-group');
$sharedWithGroup = $this->createMock(UserAskAnythingPrompt::class);
$sharedWithGroup->expects($this->once())
->method('getUser')
->willReturn(null);
$sharedWithGroup->expects($this->once())
->method('getGroup')
->willReturn($group);
$this->askAnythingRepository->expects($this->exactly(2))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[99, new Collection([])],
[109, new Collection([$sharedWithGroup])],
]);
$prompts = [$defaultPrompt, $promptOwnedByUser, $defaultPromptOrderedByUser, $promptOwnedByUserAndSharedWithGroup];
$this->askAnythingRepository->expects($this->once())
->method('findPromptsByUserAndTarget')
->willReturn(new Collection($prompts));
$expectedDto1 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto2 = new AskAnythingPromptDto(
'uuid-1st-prompt',
'First users prompt',
'Test prompt',
AskAnythingPromptTarget::call,
'1',
[],
[],
);
$expectedDto3 = new AskAnythingPromptDto(
'default-uuid',
'Sentiment',
'What was the overall sentiment of the customer during the call?',
AskAnythingPromptTarget::call
);
$expectedDto4 = new AskAnythingPromptDto(
'uuid-2nd-prompt',
'Prompt shared with group',
'Test prompt that is shared with group',
AskAnythingPromptTarget::call,
'1',
[],
['uuid-of-the-group'],
);
$dtos = $this->askAnythingPromptService->get($user, AskAnythingPromptTarget::call);
$this->assertEquals([$expectedDto1, $expectedDto2, $expectedDto3, $expectedDto4], $dtos);
}
public function testEditAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(123);
$prompt->expects($this->never())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(123);
$user->expects($this->once())
->method('getUuid')
->willReturn('owner-uuid');
$title = 'new title';
$content = 'new content';
$shareUsers = ['us-1'];
$shareGroups = ['gr-1', 'gr-2'];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$shareGroup1 = $this->createMock(Group::class);
$shareGroup2 = $this->createMock(Group::class);
$this->groupRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['gr-1', $shareGroup1],
['gr-2', $shareGroup2],
]);
$editPrompt = $this->createMock(AskAnythingPrompt::class);
$editPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$editPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$editPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$editPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$this->askAnythingRepository->expects($this->once())
->method('editPrompt')
->with($prompt, $title, $content, [$shareUser], [$shareGroup1, $shareGroup2])
->willReturn($editPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'owner-uuid',
$shareUsers,
$shareGroups
);
$editDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $editDto);
}
public function testHideDefaultAndCreateAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('new-owner-uuid');
$title = 'title';
$content = 'content';
$shareUsers = ['us-1'];
$shareGroups = [];
$shareUser = $this->createMock(User::class);
$this->userRepository->expects($this->once())
->method('findByUuid')
->with('us-1')
->willReturn($shareUser);
$this->groupRepository->expects($this->never())
->method('findByUuid');
$newPrompt = $this->createMock(AskAnythingPrompt::class);
$newPrompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$newPrompt->expects($this->once())
->method('getUuid')
->willReturn('uuid-1st-prompt');
$newPrompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$newPrompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->willReturn($newPrompt);
$expectedDto = new AskAnythingPromptDto(
'uuid-1st-prompt',
$title,
$content,
AskAnythingPromptTarget::call,
'new-owner-uuid',
$shareUsers,
$shareGroups
);
$actualDto = $this->askAnythingPromptService->edit($prompt, $user, $title, $content, $shareUsers, $shareGroups);
$this->assertEquals($expectedDto, $actualDto);
}
public function testDeleteAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
// Use Mockery for the relationship mock (more flexible)
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->any())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([]));
$this->askAnythingRepository->expects($this->once())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteAskAnythingPromptWithRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->any())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$user = $this->createMock(User::class);
$user->expects($this->any())
->method('getId')
->willReturn(1);
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(1, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->exactly(3))
->method('findSharedUsersAndGroupsByPromptId')
->willReturnMap([
[1, new Collection([$userPrompt])],
[1, new Collection([])],
]);
$this->askAnythingRepository->expects($this->never())
->method('deletePrompt');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideDefaultAskAnythingPrompt(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(true);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser');
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(3))
->method('getId')
->willReturn(33);
$relationMock = \Mockery::mock(\Illuminate\Database\Eloquent\Relations\HasMany::class);
$relationMock->shouldReceive('withTrashed')
->once()
->andReturnSelf();
$relationMock->shouldReceive('update')
->once()
->with(['ask_anything_prompt_id' => null, 'status' => false]);
$prompt->expects($this->once())
->method('automatedReports')
->willReturn($relationMock);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(33)
->willReturn(new Collection([]));
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithUserAndGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn($userPrompt);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testHideSharedWithGroupAskAnythingPrompt(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn($userPrompt);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('hidePromptForUser')
->with($prompt, $user);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testDeleteWithNoSharesAndNotOwner(): void
{
$userPrompt = $this->createMock(UserAskAnythingPrompt::class);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('isDefaultPrompt')
->willReturn(false);
$prompt->expects($this->once())
->method('getOwnerId')
->willReturn(1);
$prompt->expects($this->exactly(2))
->method('getId')
->willReturn(33);
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getId')
->willReturn(2);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUser')
->with(33, $user)
->willReturn(null);
$this->askAnythingRepository->expects($this->once())
->method('findSharedPromptByUserGroup')
->with(33, $user)
->willReturn(null);
$userPrompt->expects($this->never())
->method('delete');
$this->askAnythingRepository->expects($this->never())
->method('hidePromptForUser');
$this->expectException(\InvalidArgumentException::class);
$this->askAnythingPromptService->delete($prompt, $user);
}
public function testReorderAskAnythingPrompts(): void
{
$prompts = ['id1', 'id2', 'id3'];
$prompt1 = $this->createMock(AskAnythingPrompt::class);
$prompt2 = $this->createMock(AskAnythingPrompt::class);
$prompt3 = $this->createMock(AskAnythingPrompt::class);
$user = $this->createMock(User::class);
$this->askAnythingRepository->expects($this->exactly(3))
->method('getPromptByUuid')
->willReturnMap([
['id1', $prompt1],
['id2', $prompt2],
['id3', $prompt3],
]);
$this->askAnythingRepository->expects($this->exactly(3))
->method('orderPromptForUser')
->willReturnMap([
[[$prompt1, $user, 1]],
[[$prompt2, $user, 2]],
[[$prompt3, $user, 3]],
]);
$this->askAnythingPromptService->reorder($user, $prompts);
}
public function testCreateAskAnythingPromptWithTwoUsers(): void
{
$user = $this->createMock(User::class);
$user->expects($this->once())
->method('getUuid')
->willReturn('uuid-of-the-user');
$shareUser1 = $this->createMock(User::class);
$shareUser2 = $this->createMock(User::class);
$title = 'Test title';
$content = 'Test content';
$target = AskAnythingPromptTarget::call;
$shareUsers = ['us-1', 'us-2'];
$shareGroups = [];
$this->userRepository->expects($this->exactly(2))
->method('findByUuid')
->willReturnMap([
['us-1', $shareUser1],
['us-2', $shareUser2],
]);
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getUuid')
->willReturn('prompt-1-uuid');
$prompt->expects($this->once())
->method('getTitle')
->willReturn($title);
$prompt->expects($this->once())
->method('getContent')
->willReturn($content);
$this->askAnythingRepository->expects($this->once())
->method('createPrompt')
->with(
$user,
$target,
$title,
$content,
[$shareUser1, $shareUser2],
[],
)
->willReturn($prompt);
$expectedPromptDto = new AskAnythingPromptDto(
'prompt-1-uuid',
$title,
$content,
$target,
'uuid-of-the-user',
$shareUsers,
$shareGroups,
);
$actualPromptDto = $this->askAnythingPromptService->create(
$user,
$title,
$content,
$target,
$shareUsers,
$shareGroups
);
$this->assertEquals($expectedPromptDto, $actualPromptDto);
}
public function testRecreatePromptsForUserRelations(): void
{
$prompt = $this->createMock(AskAnythingPrompt::class);
$prompt->expects($this->once())
->method('getId')
->willReturn(1);
$prompt->expects($this->once())
->method('getTarget')
->willReturn(AskAnythingPromptTarget::call);
$prompt->expects($this->once())
->method('getTitle')
->willReturn('Test title');
$prompt->expects($this->once())
->method('getContent')
->willReturn('Test content');
$sharedPrompt = $this->createMock(UserAskAnythingPrompt::class);
$sharedUser = $this->createMock(User::class);
$sharedUser->expects($this->once())
->method('isStatusActive')
->willReturn(true);
$sharedUser->expects($this->once())
->method('getId')
->willReturn(1);
$sharedPrompt->expects($this->once())
->method('getUser')
->willReturn($sharedUser);
$sharedPrompt->expects($this->exactly(2))
->method('isRemoved')
->willReturn(false);
$sharedPrompt->expects($this->once())
->method('delete');
$this->askAnythingRepository->expects($this->once())
->method('findSharedUsersAndGroupsByPromptId')
->with(1)
->willReturn(new Collection([$sharedPrompt]));
$this->askAnythingRepository->expects($this->once())
->method('createPrompt');
$data = $this->invokePrivateMethod('recreatePromptsForUserRelations', $this->askAnythingPromptService, [$prompt]);
$this->assertEquals([[1], []], $data);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56710
|
1970
|
54
|
2026-05-19T08:17:15.342327+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178635342_m1.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-4701279590415171657
|
-8204420343923494970
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
SlackFileEditViewGoHistoryWindowHelpAPPDOCKER• ₴1DEV (-zsh)₴82app/Jobs/Crm/MatchActivityCrmData.phpapp/Jobs/Middleware/HandleHubspotRateLimit.phpAPP (-zst47++++++p42++++++*app/Mcp/Servers/JiminnyServer.phpapp/Mcp/Tools/GetMeTool.php157++++++•app/Models/Feature/FeatureEnum.phpapp/Services/Activity/HubSpot/ProviderResolver.php+-app/Services/Activity/HubSpot/ProviderResolverInterface.phpapp/Services/Activity/HubSpot/Providers/Provider.phpapp/Services/Activity/HubSpot/Providers/ProviderKixie.php+-app/Services/Activity/HubSpot/Providers/Provider0rum.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilio.phpapp/Services/Activity/HubSpot/Providers/ProviderTwilioFlex.phpapp/Services/Activity/HubSpot/Service.phpapp/Services/Crm/Hubspot/Client.phpapp/Services/Crm/Hubspot/HubspotClientInterface.phpapp/Services/Crm/Hubspot/Pagination/HubspotPaginationService.phpapp/Services/Crm/Hubspot/Pagination/PaginationState.phpdatabase/migrations/2026_05_13_124153_create_mcp_feature_flag.phptests/Feature/Mcp/GetMeToolFeatureTest.phptests/Feature/Mcp/ListCallsToolFeatureTest.phptests/Feature/Mcp/McpTestHelpersTrait.phptests/Unit/Component/ES/ChunkSizeTest.phptests/Unit/Component/ES/Processor/DT0s/SelectionListTest.phptests/Unit/Component/ES/Processor/TargetEntitiesSelectorTest.phptests/Unit/Component/MeetingBot/Service/ParticipantMatcherTest.phptests/Unit/Exceptions/RateLimitExceptionTest.phptests/Unit/Jobs/Crm/MatchActivityCrmDataTest.phptests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phptests/Unit/Services/Activity/HubSpot/ServiceTest.phptests/Unit/Services/Crm/Hubspot/ClientTest.phptests/Unit/Services/Crm/Hubspot/Pagination/HubspotPaginationServiceTest.php97++++++-132++++++•15++++++21++++--2+-25++++++.140++++++•2+-19++++++50++++++-27++++++-39++++++-6856++++++-+-151++++++-109++++++-250++++++-283++++++=37 files changed, 1587 insertions(+), 344 deletions(-)create mode 100644 app/Component/ES/ChunkSize.phpcreate mode 100644 app/Jobs/Middleware/HandleHubspotRateLimit.phpcreate mode 100644 app/Mcp/Tools/GetMeTool.phpcreate mode 100644 database/migrations/2026_05_13_124153_create_mcp_feature_flag.phpcreate mode 100644 tests/Feature/Mcp/GetMeToolFeatureTest.phpcreate mode 100644 tests/Unit/Component/ES/ChunkSizeTest.phpcreate mode 100644 tests/Unit/Exceptions/RateLimitExceptionTest.phpcreate mode 100644 tests/Unit/Jobs/Middleware/HandleHubspotRateLimitTest.phplukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ git pullAlready up to date.lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20676-delete-reSwitched to a new branch 'JY-20676-delete-report-related-objects'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20676-delete-report-related-obHomeDMsActivityFilesLaterMoreEDJiminny ...# jminny-Dg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages€. Vasil Vasilev8. Nikolay Yankov. Galya Dimitrova. Aneliya Angelovaão Stefka Stoyanova. Stoyan Tomovd Todor Stamatov "Kd. Mario GeorgievNikolay Ivanovdo James Graham2 Stoyan TanevRo Steliyan GeorgievLukas Kovalik y... OAppsJira CloudToastSupport Daily • in 3 h 43 m100% <73• Tue 19 May 11:17:15Describe what you are looking forNikolay Yankov6 0MessagesAdd canvasO Files+Nikolay YankovYesterday ~имаше ли нещь . y-..-Lukas Kovalik 2:28 PMтрябва да си вързан към SF да работиNikolay Yankov 2:28 PMaxaaaNikolay Yankov 2:41 PMимаме approve на PRда го даваме за QA?Lukas Kovalik 2:42 PMдаNikolay Yankov 3:02 PMтестове фейлватрьннах го 2 пътиToday ~Nikolay Yankov 10:05 AM/api/v2/user/ask-anything-prompts?target=on_demandhas_reports/api/v2/user/ask-anything-prompts/3381a35f-f1a3-431d-9510-bd079cd80ed6DELETE/api/vl/activity/saved-searchMessage Nikolay Yankov...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56711
|
1971
|
67
|
2026-05-19T08:17:15.342334+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178635342_m2.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6941260022677200740
|
-8132287983061324858
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
PhostormVIewINavicarecodeFV faVsco.js°9 JY-20676-delete-report-related-objectsProiect© AskAnythingController.php• M Auth9 ActivitvAskAnythingTest.php© ExportControllerRateLimitTest.phporakerropnetcllentone) M Middleware>D RequestsInteractionsInvitationsU JODs_ ListenersD MCP_ ModelsOroanizauonserinasRulesM SavedSearchesc SavedSearchcRUdFeatureTest.ondM Search1 ServiceProviders1 ServicesN TeamsQ CustomerApiFeatureTest.phpTe Deactivatel lcerFeatureTect nhn© FilterScheduledMeetingsFeatureTest.php© NudgeProcessingFeatureTest.php@ OrganizationRolesFeatureTest.php© PlanhatServiceFeatureTest.phpaat ScimlsersFeatureTest.phpwi ToamPetentionPolicvFeaturelest.onpC [EMAIL]> D Integration0) Services> D StubsC Unit> O Actionscomponent•DActionltemsEActivitvM ActivitvAnalvtics7 ActivitvSearch• M AiActivitviivoeM AiAutomation>M AiCallScorind• M AckAnvthinglAskAnytningPromptserwice.ong© AskAnythingPrompt.phpphp api_v2.php420ptServiceTest.php x © Search.php#6V1Atunccion ceschldesnareowichuseraskanychlnorrompr. vold$prompt->expects($this->onceO)'getOwnerId')->WLLLKeCUrn valusprompr->expeccsch1s->exaccly count 500gecloSrelationMock = Mockery::mocklSrelatzonMock->shouldRecerve(:LLuminate Database Eloquent Relations HasManv::class)*'withTrashed')->with(['ask_anything_prompt_id' => null, 'status' => false]):->wnllh RetunnCrplationMockassName: IIsen• •clacs)Susen->eynects/Sthis->onceohl->willReturn( value: 2):$this->askAnythingRepository->expects(Sthis->onceO)enlonealalaluwalnciitIfindChanodDnomn+Rullcont33, Suser)->wILLKecurn suserrronocSthis->askAnythingRepository->expects(Sthis->onceO)'findSharedPromptByUserGroup')35, Suser)->W1LLReturne valunull)"SuserPrompt-›expects(Sthis->onceO)'delete'):sthas->askAnvthinorenosttorv->exoectscsth1s->onceobi•-1ndSharedusersAndcrouosBv?romotid')1->wilReturncnew Collectiondnb0:Sthis->askAnvthinaPromotService->delete(Soromot, suser):public function testHideSharedWithUserAndGroupAskAnythingPrompt: void{...}181Dc AckAnvthinaPromntServicetlect nhnpublic function testHideSharedWithGroupAskAnythingPrompt: void{...}C HistorvServiceTest nhn> M Ack liminnvA515 D >public function testDeleteWithNoSharesAndNotOwner(): voidf...}The Hunsnell nluain hac heon denrecated. If vou're not writing in Hungarian vou can cafolv uninctall Huncnearies for other languages. (today 10:00)• suppont Dally • In 3n 43 m100% 5• Tue 19 May 11:17:15U AskJiminnyReportActivityServiceTest v+0 •= custom.log= laravel.log« SF jiminny@localhost]4 HS_local [jiminny@localhost]& console [PROD]# console [euyA console [STAGING]© CoachingFeedbackCoachUserln.php Xstohedeclare(scrict_cypes=l)nnamespace Jiminny Component Activ1tySearch Filterder1n1t1on:› use ...final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface29 Ф >34 0 >45 đ >1135136 @t›146 Gt ›150151 G>1usadeorivate const int No GROUP 10 = 9993 usagesorivate UserRenository SuserRenository:public function__construct(UserRepository $userRepository)1...hpublic function shouldApplyQueries: boolf...}public function getQueries: FilterDefinitionQueryCollection{...hpublic function toArray@: array{...;private function getOptions(): array{...}public function getValue: array{...}private function getDefaultValue: array{...}public function aetValidationRules(2strina Sorefix = null): arrav{...}public function aetSortOrder@: intf...}public function shouldBeIncluded(Team $team): bool{...}CascadeAsk Jiminny Report MThought for 6sPer vour rules (no unit tests for controllers, no factories), the controller test file | created isn't ideal-AutomatedReport andiAskAnythingPrompt don't have factories and the rule says not to write tests for controllers. Let me remove that file° iusers/Lukas/ 1miny/app/tests/Feature/Htp/Control1ers/APL/VZ/Ask3ininyReperes contrel1etest" SavedSearchcRUdFeatureTest.ono7 7 tasks doneAll tasks comoleteSummaryChanges Made1. has_reports flag on listing endpointsSearch.php - Added has reports to sappends and a gethasReportsAttribute accessor returning whether any relatedAutomatedReport exists. The saved-search list endpoint now includes has_reportsAskAnvthinaPromot.oho - Added has renorts to saopends anda getHasReportsAttribute@ accessor.AskAnythingPromptDto.php - Added bool ShasReports = false constructor argument and emitted has reports in toArray ().AskAnythingPromptService.php - Pass Sprompt->has reports into all three DTO constructions (get, create, edit).2. Disable related reports on deletionActivitvController.ohn: 1116-1131 - deleteActivitvSearch() now undates related renorts with f'activitv search iAskAnythingPromptService.php -deletePromptIfNoRelations() now updates related reports with ['ask anything promot id' = null. 'status' => falsel.3. Toaale validationAskJiminnyReportsController.php:126-169 - In toggleStatus(), when enabled=true and the report is an Ask Jiminnyreport, returns 422 if either activity_search_id or ask_anything_prompt_id is null . Disabling is always allowed.#. TectsAskAnythingPromptServiceTest.php - Updated two existing update() mock expectations to match the new payload (1'ask anvthina promot id' = null."status' = falsel))Per your rules I did not add unit tests for the controller. The existing SavedSearchCRUDFeatureTest covers the searchdelete flow. backend cervice tect covers nromnt delete navloadiG..l..Accent alliSemiw itr prom. 3 task per objects. 1. list with has _reports property. SearchTransformer. php#LA2-49 it is not here.Claude Qnus 1.7 MediumWN Windsurf Teamc420-1UTE.8io 4 spaces...
|
56709
|
NULL
|
NULL
|
NULL
|
|
56712
|
1971
|
68
|
2026-05-19T08:17:17.055544+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178637055_m2.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"9","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.7287234,"top":0.09896249,"width":0.006981383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"bounds":{"left":0.4481383,"top":0.09736632,"width":0.29288563,"height":0.8818835},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
586560502966912416
|
-6976847208096224411
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
56714
|
1971
|
69
|
2026-05-19T08:17:20.682202+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178640682_m2.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"bounds":{"left":0.025930852,"top":0.019952115,"width":0.03856383,"height":0.025538707},"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.098071806,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"bounds":{"left":0.8081782,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"bounds":{"left":0.8234708,"top":0.019952115,"width":0.09208777,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9155585,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"bounds":{"left":0.9268617,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"bounds":{"left":0.9381649,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"bounds":{"left":0.96609044,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"bounds":{"left":0.9773936,"top":0.019952115,"width":0.011303191,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"bounds":{"left":0.9886968,"top":0.019952115,"width":0.011303186,"height":0.025538707},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"9","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.007978723,"height":0.0},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.006981383,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.042220745,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.27027926,"top":1.0,"width":0.008643617,"height":0.0},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.7124335,"top":0.10055866,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.72140956,"top":0.09896249,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1352936380012699925
|
-8138775362302662073
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error...
|
56712
|
NULL
|
NULL
|
NULL
|
|
56713
|
1970
|
55
|
2026-05-19T08:17:20.698681+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178640698_m1.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"9","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.016666668,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.014583333,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1001329875973833614
|
-6976847208096224411
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project...
|
56710
|
NULL
|
NULL
|
NULL
|
|
56715
|
1970
|
56
|
2026-05-19T08:17:42.100807+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-19/1779 /Users/lukas/.screenpipe/data/data/2026-05-19/1779178662100_m1.jpg...
|
PhpStorm
|
faVsco.js – AskJiminnyReportsController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project: faVsco.js, menu","depth":5,"on_screen":true,"help_text":"~/jiminny/app","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JY-20676-delete-report-related-objects, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20676-delete-report-related-objects","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Start Listening for PHP Debug Connections","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"AskJiminnyReportActivityServiceTest","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Run 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Debug 'AskJiminnyReportActivityServiceTest'","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"More Actions","depth":6,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"JetBrains AI","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Search Everywhere","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"IDE and Project Settings","depth":5,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"9","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.016666668,"height":0.02111111},"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.014583333,"height":0.025555555},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\V2;\n\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse Jiminny\\Exceptions\\InvalidArgumentException;\nuse Jiminny\\Exceptions\\ModelNotFoundException;\nuse Jiminny\\Models\\AutomatedReport;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Services\\Kiosk\\AutomatedReports\\AutomatedReportsService;\nuse Psr\\Log\\LoggerInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Throwable;\n\nclass AskJiminnyReportsController extends Controller\n{\n public function __construct(\n private readonly AutomatedReportsService $automatedReportsService,\n private readonly LoggerInterface $logger,\n ) {\n }\n\n private function isNotOwnedByUser(AutomatedReport $report, User $user): bool\n {\n return $report->getTeamId() !== $user->getTeamId()\n || $report->getAttribute('created_by') !== $user->getId();\n }\n\n public function getFormData(Request $request, ?string $uuid = null): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;\n\n return new JsonResponse(\n $this->automatedReportsService->getAskJiminnyReportFormData($user, $report)\n );\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report form data', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch form data'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Create a new Ask Jiminny report.\n */\n public function create(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);\n\n return new JsonResponse($data);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to create Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to create report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Update an existing Ask Jiminny report.\n */\n public function update(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (InvalidArgumentException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);\n } catch (Throwable $e) {\n $this->logger->error('Failed to update Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to update report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Toggle Ask Jiminny report status (enable/disable).\n */\n public function toggleStatus(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $enabled = (bool) $request->input('enabled');\n\n if ($enabled && $report->isAskJiminnyReport()) {\n if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {\n return new JsonResponse(\n ['error' => 'Cannot enable report with missing saved search or prompt'],\n Response::HTTP_UNPROCESSABLE_ENTITY\n );\n }\n }\n\n $data = $this->automatedReportsService->updateAskJiminnyReportStatus(\n $report,\n $enabled,\n );\n\n return new JsonResponse($data);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to toggle Ask Jiminny report status', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to toggle report status'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * List all Ask Jiminny reports.\n */\n public function list(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $sortColumn = $request->input('sort_column', 'created_at');\n $sortDirection = $request->input('sort_direction', 'desc');\n\n $data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);\n\n return new JsonResponse($data);\n } catch (Throwable $e) {\n $this->logger->error('Failed to list Ask Jiminny reports', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch reports'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Get a single Ask Jiminny report.\n */\n public function get(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n return new JsonResponse($this->automatedReportsService->get($uuid));\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to get Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getReportsCount(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $resultsCount = $this->automatedReportsService->getReportResults($report)->count();\n\n return new JsonResponse(['count' => $resultsCount]);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to count report results', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'report_uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to count report results'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n /**\n * Delete an Ask Jiminny report.\n */\n public function delete(Request $request, string $uuid): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n if ($request->boolean('delete_generated_reports')) {\n $this->automatedReportsService->deleteReportResults($uuid);\n }\n\n $report = $this->automatedReportsService->getReport($uuid);\n\n if ($this->isNotOwnedByUser($report, $user)) {\n return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);\n }\n\n $this->automatedReportsService->delete($uuid);\n\n return new JsonResponse(null, Response::HTTP_NO_CONTENT);\n } catch (ModelNotFoundException $e) {\n return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);\n } catch (Throwable $e) {\n $this->logger->error('Failed to delete Ask Jiminny report', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n 'uuid' => $uuid,\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to delete report'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n\n public function getFilters(Request $request): JsonResponse\n {\n /** @var User $user */\n $user = $request->user();\n\n try {\n $filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);\n\n return new JsonResponse(['filters' => $filters]);\n } catch (Throwable $e) {\n $this->logger->error('Failed to fetch Ask Jiminny report filters', [\n 'error' => $e->getMessage(),\n 'user_id' => $user->getId(),\n ]);\n\n return new JsonResponse(\n ['error' => 'Failed to fetch filters'],\n Response::HTTP_INTERNAL_SERVER_ERROR\n );\n }\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sync Changes","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide This Notification","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Code changed:","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.088194445,"height":0.027777778},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Highlighted Error","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Contracts\\Repositories\\UserRepository;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\Feature\\FeatureEnum;\nuse Jiminny\\Models\\Team;\nuse Jiminny\\Traits\\RequiresUUID;\nuse Elastica\\Query;\n\nfinal class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface\n{\n private const int NO_GROUP_ID = 999;\n private UserRepository $userRepository;\n\n public function __construct(UserRepository $userRepository)\n {\n $this->userRepository = $userRepository;\n }\n\n public function shouldApplyQueries(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n $userIds = $this->getValue();\n\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(new Query\\Terms('coachingFeedbacks.coach.id_string', $userIds))\n ->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),\n ]);\n }\n\n public function toArray(): array\n {\n return [\n 'id' => 'coaching-feedback-user-filter',\n 'label' => 'Coach',\n 'helpText' => 'The person who completed the Coaching Framework',\n 'placeholder' => 'Search coaches',\n 'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,\n 'queryParam' => 'coaching_feedback_coach_id',\n 'options' => $this->getOptions(),\n 'groupLabelKey' => 'label',\n 'groupValuesKey' => 'users',\n 'optionLabelKey' => 'name',\n 'optionValueKey' => 'id',\n 'value' => $this->getValue(),\n ];\n }\n\n private function getOptions(): array\n {\n $user = $this->executedBy;\n $query = $user\n ->getTeam()\n ->users()\n ->whereNotIn(\n 'uuid',\n $this->userRepository->findInaccessibleDeactivatedUserUuids($user)\n ->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))\n ->all(),\n )\n ->orderBy('name');\n\n $users = $query\n ->with('group')\n ->get()\n ->reduce(\n static function (array $carry, Models\\User $user): array {\n $group = $user->getGroup();\n $groupId = $group !== null\n ? $group->getUuid()\n : self::NO_GROUP_ID;\n $groupName = $group !== null\n ? $group->getName()\n : '(NON-GROUPED)';\n\n if (! array_key_exists($groupId, $carry)) {\n $carry[$groupId] = [\n 'label' => $groupName,\n 'users' => [],\n ];\n }\n\n $carry[$groupId]['users'][] = [\n 'id' => $user->getUuid(),\n 'name' => sprintf(\n '%s%s',\n $user->getName(),\n ! $user->isStatusActive()\n ? ' (Inactive)'\n : ''\n ),\n ];\n\n return $carry;\n },\n []\n );\n\n return Collection::make($users)\n ->sortBy('label')\n ->values()\n ->toArray();\n }\n\n public function getValue(): array\n {\n if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {\n return $this->getDefaultValue();\n }\n\n return array_diff(\n $this->criteria->getCoachingFeedbackCoachUserId(),\n $this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),\n );\n }\n\n private function getDefaultValue(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n $team = $this->executedBy->getTeam();\n\n return [\n $prefix . 'coaching_feedback_coach_id' => 'array',\n $prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),\n ];\n }\n\n public function getSortOrder(): int\n {\n return 86;\n }\n\n public function shouldBeIncluded(Team $team): bool\n {\n return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Project","depth":3,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Project","depth":3,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New File or Directory…","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Expand Selected","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Collapse All","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Options","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Hide","depth":4,"bounds":{"left":0.0,"top":0.0,"width":0.018055556,"height":0.026666667},"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-3318323997297636737
|
-6976847208096224411
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20676-delete-report-re Project: faVsco.js, menu
JY-20676-delete-report-related-objects, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Sync Changes
Hide This Notification
Code changed:
Hide
9
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\V2;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\ModelNotFoundException;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\User;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class AskJiminnyReportsController extends Controller
{
public function __construct(
private readonly AutomatedReportsService $automatedReportsService,
private readonly LoggerInterface $logger,
) {
}
private function isNotOwnedByUser(AutomatedReport $report, User $user): bool
{
return $report->getTeamId() !== $user->getTeamId()
|| $report->getAttribute('created_by') !== $user->getId();
}
public function getFormData(Request $request, ?string $uuid = null): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $uuid ? $this->automatedReportsService->getReport($uuid) : null;
return new JsonResponse(
$this->automatedReportsService->getAskJiminnyReportFormData($user, $report)
);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report form data', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch form data'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Create a new Ask Jiminny report.
*/
public function create(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$data = $this->automatedReportsService->createAskJiminnyReport($request->all(), $user);
return new JsonResponse($data);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to create Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to create report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Update an existing Ask Jiminny report.
*/
public function update(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$data = $this->automatedReportsService->updateAskJiminnyReport($report, $request->all(), $user);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (InvalidArgumentException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_UNPROCESSABLE_ENTITY);
} catch (Throwable $e) {
$this->logger->error('Failed to update Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to update report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Toggle Ask Jiminny report status (enable/disable).
*/
public function toggleStatus(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$enabled = (bool) $request->input('enabled');
if ($enabled && $report->isAskJiminnyReport()) {
if ($report->getActivitySearchId() === null || $report->getAskAnythingPromptId() === null) {
return new JsonResponse(
['error' => 'Cannot enable report with missing saved search or prompt'],
Response::HTTP_UNPROCESSABLE_ENTITY
);
}
}
$data = $this->automatedReportsService->updateAskJiminnyReportStatus(
$report,
$enabled,
);
return new JsonResponse($data);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to toggle Ask Jiminny report status', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to toggle report status'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* List all Ask Jiminny reports.
*/
public function list(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$sortColumn = $request->input('sort_column', 'created_at');
$sortDirection = $request->input('sort_direction', 'desc');
$data = $this->automatedReportsService->listAskJiminnyReports($user, $sortColumn, $sortDirection);
return new JsonResponse($data);
} catch (Throwable $e) {
$this->logger->error('Failed to list Ask Jiminny reports', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch reports'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Get a single Ask Jiminny report.
*/
public function get(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->automatedReportsService->get($uuid));
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to get Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to fetch report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getReportsCount(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$resultsCount = $this->automatedReportsService->getReportResults($report)->count();
return new JsonResponse(['count' => $resultsCount]);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to count report results', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'report_uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to count report results'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
/**
* Delete an Ask Jiminny report.
*/
public function delete(Request $request, string $uuid): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
if ($request->boolean('delete_generated_reports')) {
$this->automatedReportsService->deleteReportResults($uuid);
}
$report = $this->automatedReportsService->getReport($uuid);
if ($this->isNotOwnedByUser($report, $user)) {
return new JsonResponse(['error' => 'Report not found'], Response::HTTP_NOT_FOUND);
}
$this->automatedReportsService->delete($uuid);
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
} catch (ModelNotFoundException $e) {
return new JsonResponse(['error' => $e->getMessage()], Response::HTTP_NOT_FOUND);
} catch (Throwable $e) {
$this->logger->error('Failed to delete Ask Jiminny report', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
'uuid' => $uuid,
]);
return new JsonResponse(
['error' => 'Failed to delete report'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
public function getFilters(Request $request): JsonResponse
{
/** @var User $user */
$user = $request->user();
try {
$filters = $this->automatedReportsService->getAskJiminnyReportFilters($user);
return new JsonResponse(['filters' => $filters]);
} catch (Throwable $e) {
$this->logger->error('Failed to fetch Ask Jiminny report filters', [
'error' => $e->getMessage(),
'user_id' => $user->getId(),
]);
return new JsonResponse(
['error' => 'Failed to fetch filters'],
Response::HTTP_INTERNAL_SERVER_ERROR
);
}
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ActivitySearch\FilterDefinition;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Contracts\Repositories\UserRepository;
use Jiminny\Models;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Team;
use Jiminny\Traits\RequiresUUID;
use Elastica\Query;
final class CoachingFeedbackCoachUserIn extends FilterDefinition implements ValidatedFilterDefinitionInterface
{
private const int NO_GROUP_ID = 999;
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
public function shouldApplyQueries(): bool
{
return count($this->getValue()) > 0;
}
public function getQueries(): FilterDefinitionQueryCollection
{
$userIds = $this->getValue();
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(new Query\Terms('coachingFeedbacks.coach.id_string', $userIds))
->setPath('coachingFeedbacks.coach', 'coachingFeedbacks'),
]);
}
public function toArray(): array
{
return [
'id' => 'coaching-feedback-user-filter',
'label' => 'Coach',
'helpText' => 'The person who completed the Coaching Framework',
'placeholder' => 'Search coaches',
'inputType' => InputTypeEnum::DROPDOWN_MULTIPLE,
'queryParam' => 'coaching_feedback_coach_id',
'options' => $this->getOptions(),
'groupLabelKey' => 'label',
'groupValuesKey' => 'users',
'optionLabelKey' => 'name',
'optionValueKey' => 'id',
'value' => $this->getValue(),
];
}
private function getOptions(): array
{
$user = $this->executedBy;
$query = $user
->getTeam()
->users()
->whereNotIn(
'uuid',
$this->userRepository->findInaccessibleDeactivatedUserUuids($user)
->map(static fn (string $uuid): string => RequiresUUID::toOptimized($uuid))
->all(),
)
->orderBy('name');
$users = $query
->with('group')
->get()
->reduce(
static function (array $carry, Models\User $user): array {
$group = $user->getGroup();
$groupId = $group !== null
? $group->getUuid()
: self::NO_GROUP_ID;
$groupName = $group !== null
? $group->getName()
: '(NON-GROUPED)';
if (! array_key_exists($groupId, $carry)) {
$carry[$groupId] = [
'label' => $groupName,
'users' => [],
];
}
$carry[$groupId]['users'][] = [
'id' => $user->getUuid(),
'name' => sprintf(
'%s%s',
$user->getName(),
! $user->isStatusActive()
? ' (Inactive)'
: ''
),
];
return $carry;
},
[]
);
return Collection::make($users)
->sortBy('label')
->values()
->toArray();
}
public function getValue(): array
{
if (! $this->criteria->hasCoachingFeedbackCoachUserIds()) {
return $this->getDefaultValue();
}
return array_diff(
$this->criteria->getCoachingFeedbackCoachUserId(),
$this->userRepository->findInaccessibleDeactivatedUserUuids($this->executedBy)->all(),
);
}
private function getDefaultValue(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
$team = $this->executedBy->getTeam();
return [
$prefix . 'coaching_feedback_coach_id' => 'array',
$prefix . 'coaching_feedback_coach_id.*' => 'uuid:users,team_id,' . $team->getId(),
];
}
public function getSortOrder(): int
{
return 86;
}
public function shouldBeIncluded(Team $team): bool
{
return $team->hasFeature(FeatureEnum::COACHING_FRAMEWORK);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|