|
35125
|
1314
|
15
|
2026-05-13T12:13:06.342368+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674386342_m2.jpg...
|
PhpStorm
|
faVsco.js – console [PROD]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
7581618884890279806
|
-8204352174202572862
|
visual_change
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
PhostormVIeWINavigarecodeFV faVsco.js°9 JY-20891-improve-sms-text-relaProject(C) UserinvitationDTo.ong(C) MailboxController.oholM$ CLAUDE.mdC) TextRelayService.phpc) Sso.php© SsoController.phpcomposer.lsoncomposer.lockdenendencv-checker.ison© TextMessagingService.phgsms-relay-ralled.blade.pnp©)smsmessage.png© SmsLength.phgdevison© TextRelay.phpE ids.txt=infection.ison.distM-INSTALLmdM+ INTERNAL WEBHOOK SETUP 30=iminny storaddM_llicenses.moM MakefileJ package-lock.jsonE phpstan.neon.distE phpstan-baseline.neon<> phpunit.xmlTaraw_sqL_query.sqMIDSANMS md< sonar-project.propertiesEtest.py‹> Untitled Diagram.xmlJs vetur.confia.isM+ WEBHOOK FILTERING_IMPLEM 44› ih External Librariesv EScratches and Consolesv _ Darabase consolesVLEU¿ console (EUlIA DEAL RISKS (EU1ADITEUIAEU TEU#liminnv@llocalhostIconsole lliminnvalocalho.#Di lfiminnv@localhost4 HS local fiiminnv@localhc 57… SE fliminnv@localhostlA zoho_dev fiminny@localhV A PRODconcale [oponI# concolo 1 ropOn1A DI [PRODI> AQA> A QAi> A QAI PRODacuivilystatusin.onpxclass Activitystatusin extends Filterbefinition impLements6 OTV A STAGING& console SIAGING& console SIAGING¿ uranus ISTAGING1> D Extensions.ououc runction cetouerteso:Fulterderintiondvervcollectionnew Query Termse tield: "status.kevword', sthis->qetvalueoopublic function isSearchingForFutureActivities: boolif (! $this->hasValue()) {neturn false:neturn Collection:-makpd1Models Activitv:•STATIIS SCHENIIL EN.Models \Activity::STATUS_PENDING->intersect($this->getValueO)->count() > 0:Z usagesprivate function hasValue: boolf...}orivate tunction cetvalueo: arravif (1 Sthis->criteria->hasActivitvStatusValues@) {returnModels Activity:: STATUS COMPLETED.IModels Activity:: STATUS FAILED.neturnSthis-scnitenia->aetActivitvStatusVal.uesOrnublic function toAnnavo• arnalnotunn71 0f >public function getValidationRules(?string Sprefix = null): array{...> D Scratches=laravel.logA SF (jiminny@localhost]4 HS_local [jiminny@localhost]A console [EU]# concole ISTAGiNGiI=| v So jiminny040 A1 A40 V 65 ^select * from users u join calendars c 1<->1..n: on c.user id = u.idwhere u.team_id = 882select * from activities where id = 74049485: # team 563 crm 537select * from activities where id = 73272382;# team 563 crm 537select * fron activities where id = 64400389• # team 563 crm 537select * from activities where563 crm 537select * from activities where id = 54520297: # team 563 crm 537.select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759:select * from accounts where crm_configuration_id = 537 and id = 19003658*select * from automated report_ results where id = 1976:select * from automated reports where id = 583:select * from activity searches where id = 87714:select * from activity search_filters where activity search_id = 87714:SELECT * FROM activities WHERE uvid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid to bin('47842446-af51-4bcb-854f-cc6560290101*) = uuid:SELECT * FROM crm configurations WHERE provider = 'hubspot'.select * from rate_limits;select * fromand id IN (181872) :select * fromSELECT * FROM usens WHERE id TN (24623.29443. 29613) ÷esults where media tvoe = 'odf' and status = 2SELECT * FROM automated_report_results WHERE Uuid_tO_bän('822fa41b-afd3-43a9-a248-86b0e36f3131') = uid;select * fron teyt nelavs where created at > 12926-05-01'# and id IN (32415, 32416);and id = 72412.select * from users where team id = 2 and email like '%scott%' and id = 29510SELECT * FROM activities WHERE vuid to bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436Support Daily - 2m left100% L2• Wed 13 May 15:13:06U AskJiminnyReportActivityServiceTest vcascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..→>counto > 0:This aftects the Activ1tyRecorded Tilter (Uines 30-36" phopubiae tunctzon shouldAppLycuersest): B00LSth1s→>activ1tystatusin→>w1thcr1ter1a(sth1s->cr1ter1a):sthis-sactivitvStatusin-swithconsumer(sthis->executedBy)SisSearchingForFutureActivities = Sthis->activityStatusIn->isSearchingForFutureActivities():return Sthis-shasValue) sc I SicSearchinaForFutureActivitieceKev FindinaThe activitv SHOULD abpear in the dashboard based on all the conditions.• Status "failed" is included by default• • Type "conference" is allowedHas actual start timeNot private•V Has recording•• Within default 90-day date rangePecommended InvestigationSince the activitv is visiole in OnDemand out not in Dashboard, check.1. ElasticSearch indexing: Veritv the activity is indexed in Elasticsearch with all required tields2 Ucer conteyt. Verify the ucer fucer id. 200801 hac nroner nermiccions and toam accecc3. Date range: Check if the dashboard date range filter includes May 12, 2026# Actual filter values: Check it anv custom filters are heing annlied that micht eyclude this activitv5. Teaminsights/ActivityRecorded override: The override to OPTION_ALL might not be working as expectedThe most likelv issue is that the ActivitvRecorded filter's DEFAULT VALUE override in Teaminsiahts context miaht noibe tunctioning correctly, or there's a custom filter being applied that excludes talled activitiesGive me the whole flowComnlete bachhoard Acrivitv Slow1 ADl Poquoct Entrv DointFile: DashboardController.pho:33-68public function fetch Request Srequest): sonResponseSuser = Sthis->getUserFromRequest(Srequest:Ask anvthina (84L)« Code SWF-1.6W Windsurf TeamoJUTE.A...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35126
|
1314
|
16
|
2026-05-13T12:13:09.366203+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674389366_m2.jpg...
|
PhpStorm
|
faVsco.js – console [PROD]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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 Jiminny\Component\ActivitySearch\FilterDefinition;
use Elastica\Query;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\HiddenFilterDefinitionInterface;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Models;
class ActivityStatusIn extends FilterDefinition implements
ValidatedFilterDefinitionInterface,
HiddenFilterDefinitionInterface
{
public function shouldApplyQueries(): bool
{
return $this->hasValue();
}
public function getQueries(): FilterDefinitionQueryCollection
{
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(
new Query\Terms('status.keyword', $this->getValue())
),
]);
}
public function isSearchingForFutureActivities(): bool
{
if (! $this->hasValue()) {
return false;
}
return Collection::make([
Models\Activity::STATUS_SCHEDULED,
Models\Activity::STATUS_PENDING,
])
->intersect($this->getValue())
->count() > 0;
}
private function hasValue(): bool
{
return count($this->getValue()) > 0;
}
private function getValue(): array
{
if (! $this->criteria->hasActivityStatusValues()) {
return [
Models\Activity::STATUS_COMPLETED,
Models\Activity::STATUS_FAILED,
];
}
return $this->criteria->getActivityStatusValues();
}
public function toArray(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
/**
* @todo improve validation by enlisting all enum values
*/
return [$prefix . 'status' => 'array'];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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 Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Elastica\\Query;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\HiddenFilterDefinitionInterface;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Models;\n\nclass ActivityStatusIn extends FilterDefinition implements\n ValidatedFilterDefinitionInterface,\n HiddenFilterDefinitionInterface\n{\n public function shouldApplyQueries(): bool\n {\n return $this->hasValue();\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(\n new Query\\Terms('status.keyword', $this->getValue())\n ),\n ]);\n }\n\n public function isSearchingForFutureActivities(): bool\n {\n if (! $this->hasValue()) {\n return false;\n }\n\n return Collection::make([\n Models\\Activity::STATUS_SCHEDULED,\n Models\\Activity::STATUS_PENDING,\n ])\n ->intersect($this->getValue())\n ->count() > 0;\n }\n\n private function hasValue(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n private function getValue(): array\n {\n if (! $this->criteria->hasActivityStatusValues()) {\n return [\n Models\\Activity::STATUS_COMPLETED,\n Models\\Activity::STATUS_FAILED,\n ];\n }\n\n return $this->criteria->getActivityStatusValues();\n }\n\n public function toArray(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n /**\n * @todo improve validation by enlisting all enum values\n */\n\n return [$prefix . 'status' => 'array'];\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Elastica\\Query;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\HiddenFilterDefinitionInterface;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Models;\n\nclass ActivityStatusIn extends FilterDefinition implements\n ValidatedFilterDefinitionInterface,\n HiddenFilterDefinitionInterface\n{\n public function shouldApplyQueries(): bool\n {\n return $this->hasValue();\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(\n new Query\\Terms('status.keyword', $this->getValue())\n ),\n ]);\n }\n\n public function isSearchingForFutureActivities(): bool\n {\n if (! $this->hasValue()) {\n return false;\n }\n\n return Collection::make([\n Models\\Activity::STATUS_SCHEDULED,\n Models\\Activity::STATUS_PENDING,\n ])\n ->intersect($this->getValue())\n ->count() > 0;\n }\n\n private function hasValue(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n private function getValue(): array\n {\n if (! $this->criteria->hasActivityStatusValues()) {\n return [\n Models\\Activity::STATUS_COMPLETED,\n Models\\Activity::STATUS_FAILED,\n ];\n }\n\n return $this->criteria->getActivityStatusValues();\n }\n\n public function toArray(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n /**\n * @todo improve validation by enlisting all enum values\n */\n\n return [$prefix . 'status' => 'array'];\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","role_description":"text entry area","is_enabled":true,"is_focused":true,"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}]...
|
-3943840198194522253
|
2218600140881933893
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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 Jiminny\Component\ActivitySearch\FilterDefinition;
use Elastica\Query;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\HiddenFilterDefinitionInterface;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Models;
class ActivityStatusIn extends FilterDefinition implements
ValidatedFilterDefinitionInterface,
HiddenFilterDefinitionInterface
{
public function shouldApplyQueries(): bool
{
return $this->hasValue();
}
public function getQueries(): FilterDefinitionQueryCollection
{
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(
new Query\Terms('status.keyword', $this->getValue())
),
]);
}
public function isSearchingForFutureActivities(): bool
{
if (! $this->hasValue()) {
return false;
}
return Collection::make([
Models\Activity::STATUS_SCHEDULED,
Models\Activity::STATUS_PENDING,
])
->intersect($this->getValue())
->count() > 0;
}
private function hasValue(): bool
{
return count($this->getValue()) > 0;
}
private function getValue(): array
{
if (! $this->criteria->hasActivityStatusValues()) {
return [
Models\Activity::STATUS_COMPLETED,
Models\Activity::STATUS_FAILED,
];
}
return $this->criteria->getActivityStatusValues();
}
public function toArray(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
/**
* @todo improve validation by enlisting all enum values
*/
return [$prefix . 'status' => 'array'];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
35125
|
NULL
|
NULL
|
NULL
|
|
35127
|
1313
|
11
|
2026-05-13T12:13:27.798165+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674407798_m1.jpg...
|
PhpStorm
|
faVsco.js – console [PROD]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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 Jiminny\Component\ActivitySearch\FilterDefinition;
use Elastica\Query;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\HiddenFilterDefinitionInterface;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Models;
class ActivityStatusIn extends FilterDefinition implements
ValidatedFilterDefinitionInterface,
HiddenFilterDefinitionInterface
{
public function shouldApplyQueries(): bool
{
return $this->hasValue();
}
public function getQueries(): FilterDefinitionQueryCollection
{
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(
new Query\Terms('status.keyword', $this->getValue())
),
]);
}
public function isSearchingForFutureActivities(): bool
{
if (! $this->hasValue()) {
return false;
}
return Collection::make([
Models\Activity::STATUS_SCHEDULED,
Models\Activity::STATUS_PENDING,
])
->intersect($this->getValue())
->count() > 0;
}
private function hasValue(): bool
{
return count($this->getValue()) > 0;
}
private function getValue(): array
{
if (! $this->criteria->hasActivityStatusValues()) {
return [
Models\Activity::STATUS_COMPLETED,
Models\Activity::STATUS_FAILED,
];
}
return $this->criteria->getActivityStatusValues();
}
public function toArray(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
/**
* @todo improve validation by enlisting all enum values
*/
return [$prefix . 'status' => 'array'];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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 Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Elastica\\Query;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\HiddenFilterDefinitionInterface;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Models;\n\nclass ActivityStatusIn extends FilterDefinition implements\n ValidatedFilterDefinitionInterface,\n HiddenFilterDefinitionInterface\n{\n public function shouldApplyQueries(): bool\n {\n return $this->hasValue();\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(\n new Query\\Terms('status.keyword', $this->getValue())\n ),\n ]);\n }\n\n public function isSearchingForFutureActivities(): bool\n {\n if (! $this->hasValue()) {\n return false;\n }\n\n return Collection::make([\n Models\\Activity::STATUS_SCHEDULED,\n Models\\Activity::STATUS_PENDING,\n ])\n ->intersect($this->getValue())\n ->count() > 0;\n }\n\n private function hasValue(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n private function getValue(): array\n {\n if (! $this->criteria->hasActivityStatusValues()) {\n return [\n Models\\Activity::STATUS_COMPLETED,\n Models\\Activity::STATUS_FAILED,\n ];\n }\n\n return $this->criteria->getActivityStatusValues();\n }\n\n public function toArray(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n /**\n * @todo improve validation by enlisting all enum values\n */\n\n return [$prefix . 'status' => 'array'];\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ActivitySearch\\FilterDefinition;\n\nuse Elastica\\Query;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinition;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQueryCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\HiddenFilterDefinitionInterface;\nuse Jiminny\\Contracts\\ActivitySearch\\ValidatedFilterDefinitionInterface;\nuse Jiminny\\Models;\n\nclass ActivityStatusIn extends FilterDefinition implements\n ValidatedFilterDefinitionInterface,\n HiddenFilterDefinitionInterface\n{\n public function shouldApplyQueries(): bool\n {\n return $this->hasValue();\n }\n\n public function getQueries(): FilterDefinitionQueryCollection\n {\n return FilterDefinitionQueryCollection::make([\n FilterDefinitionQuery::instance()\n ->setQuery(\n new Query\\Terms('status.keyword', $this->getValue())\n ),\n ]);\n }\n\n public function isSearchingForFutureActivities(): bool\n {\n if (! $this->hasValue()) {\n return false;\n }\n\n return Collection::make([\n Models\\Activity::STATUS_SCHEDULED,\n Models\\Activity::STATUS_PENDING,\n ])\n ->intersect($this->getValue())\n ->count() > 0;\n }\n\n private function hasValue(): bool\n {\n return count($this->getValue()) > 0;\n }\n\n private function getValue(): array\n {\n if (! $this->criteria->hasActivityStatusValues()) {\n return [\n Models\\Activity::STATUS_COMPLETED,\n Models\\Activity::STATUS_FAILED,\n ];\n }\n\n return $this->criteria->getActivityStatusValues();\n }\n\n public function toArray(): array\n {\n return [];\n }\n\n public function getValidationRules(?string $prefix = null): array\n {\n /**\n * @todo improve validation by enlisting all enum values\n */\n\n return [$prefix . 'status' => 'array'];\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
-3943840198194522253
|
2218600140881933893
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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 Jiminny\Component\ActivitySearch\FilterDefinition;
use Elastica\Query;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch\FilterDefinition;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ActivitySearch\FilterDefinitionQueryCollection;
use Jiminny\Contracts\ActivitySearch\HiddenFilterDefinitionInterface;
use Jiminny\Contracts\ActivitySearch\ValidatedFilterDefinitionInterface;
use Jiminny\Models;
class ActivityStatusIn extends FilterDefinition implements
ValidatedFilterDefinitionInterface,
HiddenFilterDefinitionInterface
{
public function shouldApplyQueries(): bool
{
return $this->hasValue();
}
public function getQueries(): FilterDefinitionQueryCollection
{
return FilterDefinitionQueryCollection::make([
FilterDefinitionQuery::instance()
->setQuery(
new Query\Terms('status.keyword', $this->getValue())
),
]);
}
public function isSearchingForFutureActivities(): bool
{
if (! $this->hasValue()) {
return false;
}
return Collection::make([
Models\Activity::STATUS_SCHEDULED,
Models\Activity::STATUS_PENDING,
])
->intersect($this->getValue())
->count() > 0;
}
private function hasValue(): bool
{
return count($this->getValue()) > 0;
}
private function getValue(): array
{
if (! $this->criteria->hasActivityStatusValues()) {
return [
Models\Activity::STATUS_COMPLETED,
Models\Activity::STATUS_FAILED,
];
}
return $this->criteria->getActivityStatusValues();
}
public function toArray(): array
{
return [];
}
public function getValidationRules(?string $prefix = null): array
{
/**
* @todo improve validation by enlisting all enum values
*/
return [$prefix . 'status' => 'array'];
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35128
|
NULL
|
0
|
2026-05-13T12:13:31.155231+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674411155_m1.jpg...
|
PhpStorm
|
faVsco.js – ActivityStatusIn.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
5712202241521779175
|
-8348537731026670142
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More> 0lallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSupport Daily • 2m left100% <78•Wed 13 May 15:13:30Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
35127
|
NULL
|
NULL
|
NULL
|
|
35129
|
1314
|
17
|
2026-05-13T12:13:31.143101+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674411143_m2.jpg...
|
PhpStorm
|
faVsco.js – ActivityStatusIn.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
5712202241521779175
|
-8348537731026670142
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
PhostormVIewINavigarecodeFV faVsco.js°9 JY-20891-improve-sms-text-relaProject(C) UserinvitationDTo.ong(C) MailboxController.ohnlM$ CLAUDE.mdC) TextRelayService.onpc) Sso.php© SsoController.phpcomposer.lsoncomposer.lockdenendencv-checker.ison© TextMessagingService.phgsms-relay-ralled.blade.pnp©)smsmessage.png© SmsLength.phgdevison© TextRelay.phpE ids.txt=infection.ison.distM-INSTALLmdM+ INTERNAL WEBHOOK SETUP 30=iminny storaddM_llicenses.moM MakefileJ package-lock.jsonE phpstan.neon.distE phpstan-baseline.neon<> phpunit.xmlTaraw_sqL_query.sqMIDSANMS md< sonar-project.propertiesEtest.py‹> Untitled Diagram.xmlJs vetur.confia.isM+ WEBHOOK FILTERING_IMPLEM 44› ih External Librariesv EScratches and Consolesv _ Darabase consolesVLEU¿ console (EUlIA DEAL RISKS (EU1ADITEUIAEU TEUT#liminnv@llocalhostIconsole lliminnvalocalho.#Di lfiminnv@localhost4 HS local fiiminnv@localhc 57… SE fliminnv@localhostlA zoho_dev fiminny@localhV A PRODconcale [oponI# concolo 1 ropOn1A DI [PRODI> AQA> A QAi> A QAI PRODacuivilystatusin.onpxclass Activitystatusin extends Filterbefinition impLements6 OTV A STAGING& console SIAGING& console SIAGING¿ uranus ISTAGING1> D Extensions.ououc runction cetouerteso:Fulterderintionduervcollectionnew Query Termse tield: "status.kevword', sthis->qetvalueoopublic function isSearchingForFutureActivities: boolif (! $this->hasValue()) {neturn false:neturn Collection:-makedlModels Activitv:•STATIIS SCHENIIL EN.Models \Activity::STATUS_PENDING->intersect($this->getValueO)->count() > 0:Z usagesprivate function hasValue: boolf...}orivate tunction cetvalueo: arravif (1 Sthis->criteria->hasActivitvStatusValues@) {returnModels Activity:: STATUS COMPLETED.IModels Activity:: STATUS FAILED.neturnSthis-scnitenia->aetActivitvStatusVal.uesOrnublic function toAnnavo• arnalnotunn71 0f >public function getValidationRules(?string Sprefix = null): array{...> D Scratches=laravel.logA SF (jiminny@localhost]4 HS_local [jiminny@localhost]& console (PROD] X A console [EU]# concole ISTAGiNGiI=| v liminny040 A1 A40 V 65 ^select * from users u join calendars c 1<->1..n: on c.user id = u.idwhere u.team_id = 882select * from activities where id = 74049485: # team 563 crm 537select * from activities where id = 73272382;# team 563 crm 537select * fron activities where id = 64400389• # team 563 crm 537select * from activities whereselect * from activities where id = 54520297: # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account id = 19003658 onden hv undated at desc-select * from contacts where crm_configuration_id = 537 and id = 35957759:select * from accounts where crm_configuration_id = 537 and id = 19003658*select * from automated report results where id = 1976:select * from automated reports where id = 583:select * from activity searches where id = 87714:select * from activity search_filters where activity search_id = 87714:SELECT * FROM activities WHERE uvid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid to bin('47842446-af51-4bcb-854f-cc6560290101*) = uuid:SELECT * FROM crm configurations WHERE provider = 'hubspot'.select * from rate_limits;select * fromautomated_report_results where media type = 'pdf' and status = 2and id IN (18l1872):select * fromSELECT * FROM usens WHERE id TN (24623.29443. 29613) ÷SELECT * FROM automated_report_results WHERE Uuid_tO_bän('822fa41b-afd3-43a9-a248-86b0e36f3131') = uid;select * fron teyt nelavs where created at > 12926-05-01'# and id IN (32415, 32416);and id = 72412.select * from users where team id = 2 and email like '%scott%' and id = 29510SELECT * FROM activities WHERE uuid to bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid: # 79763436Support Daily - 2m left100% S2Wed 13 May 15:13:30U AskJiminnyReportActivityServiceTest vcascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. AP Reduest Entrv PointFile: DashboardController-php: 33-68bphppublic tunction tetch Request Srequest): Jsonkesponsesuser - schis->geruserr ronkequestisrequesteScriteria = Criteria::createFromRequest(Srequest-sallo. Suser->aetTimezone@)•Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),return $this->response->withArray(["widaets! = l'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),/... other widaetsContext set: CONTEXT_TEAM_INSIGHTS_ ACTIVITY = 'team-insights-activity'2. Filter Set CreationFile: ActivitySearch.php: 132-244a ohoorivate tunction detteaminsiantsPageFilters(oool SisExoort = talse): FilterderinitioncollectionPoweawlarntaneanlaetanoeoeCollection: :make([special casesFilterDerinition Teaminsiahts DateRangeFilter::class.FilterDefinition\TeamInsights\Exists::classRestrictream::class,RestrictUserGroupScope::classRectrictlicerActive:tclacelregular filtersAsk anvthina (84L)< CodeSWE-16W Windsurf Teams672-25JUTE.A...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35130
|
NULL
|
0
|
2026-05-13T12:13:33.632167+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674413632_m2.jpg...
|
PhpStorm
|
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project Files
Preview
Filter
Open in Find Tool Win Project Files
Preview
Filter
Open in Find Tool Window
sms-relay-failed
sms-relay-failed.blade.php resources/views/emails/activities
sms-relay-failed.blade.php resources/views/emails/activities
resources/views/emails/activities/sms-relay-failed.blade.php
Open In Right Split...
|
[{"role":"AXButton","text" [{"role":"AXButton","text":"Project Files","depth":2,"bounds":{"left":0.6968085,"top":0.24181964,"width":0.03557181,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Preview","depth":2,"bounds":{"left":0.73238033,"top":0.24181964,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Filter","depth":2,"bounds":{"left":0.74102396,"top":0.24181964,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open in Find Tool Window","depth":2,"bounds":{"left":0.7496675,"top":0.24181964,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextField","text":"sms-relay-failed","depth":1,"bounds":{"left":0.50232714,"top":0.27214685,"width":0.25598404,"height":0.023144454},"on_screen":true,"value":"sms-relay-failed","role_description":"text field","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"sms-relay-failed.blade.php resources/views/emails/activities","depth":2,"bounds":{"left":0.4993351,"top":0.30407023,"width":0.26196808,"height":0.017557861},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"sms-relay-failed.blade.php resources/views/emails/activities","depth":4,"bounds":{"left":0.4993351,"top":0.30407023,"width":0.26196808,"height":0.017557861},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"resources/views/emails/activities/sms-relay-failed.blade.php","depth":1,"bounds":{"left":0.50598407,"top":0.75259376,"width":0.11402926,"height":0.013567438},"on_screen":true,"help_text":"resources/views/emails/activities/sms-relay-failed.blade.php","role_description":"text"},{"role":"AXLink","text":"Open In Right Split","depth":1,"bounds":{"left":0.71476066,"top":0.75259376,"width":0.03856383,"height":0.013567438},"on_screen":true,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
5051736206904953749
|
-6333830591997730050
|
visual_change
|
accessibility
|
NULL
|
Project Files
Preview
Filter
Open in Find Tool Win Project Files
Preview
Filter
Open in Find Tool Window
sms-relay-failed
sms-relay-failed.blade.php resources/views/emails/activities
sms-relay-failed.blade.php resources/views/emails/activities
resources/views/emails/activities/sms-relay-failed.blade.php
Open In Right Split...
|
35129
|
NULL
|
NULL
|
NULL
|
|
35131
|
1316
|
0
|
2026-05-13T12:13:45.754376+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674425754_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
Analyzing…
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"Analyzing…","depth":4,"bounds":{"left":0.3849734,"top":0.17478053,"width":0.019946808,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"bounds":{"left":0.122340426,"top":0.17158818,"width":0.2855718,"height":0.8076616},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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},{"role":"AXStaticText","text":"app ~/jiminny/app, folder","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".cursor, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".github","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".sonarlint, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".vscode, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".windsurf, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"app, sources root","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Actions, folder","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InviteUserToTeamAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MarkUserAsOnboardableAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SyncRecordingFlagsAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateTeamMemberAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateUserRolesAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Component","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Acl","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActionItems","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Activity","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityAnalytics","depth":9,"on_screen":false,"role_description":"text"}]...
|
7357230409197453827
|
2218881650218383181
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
Analyzing…
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35132
|
1315
|
0
|
2026-05-13T12:13:45.975717+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674425975_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
Analyzing…
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
EventSubscriber, folder
FilterDefinition, folder
DealInsights, folder
Security, folder
TeamInsights, folder
ActivityActualDate.php
ActivityChannel.php
ActivityDurationRange.php
ActivityFilter.php
ActivityPlaylistIn.php
ActivityProviderIn.php
ActivityRecorded.php
ActivityRecordingStopped.php, final class
ActivityScheduledDate.php, final class
ActivityStatusIn.php, class
ActivityType.php, final class
ActivityUpdatedDate.php, final class
AiCallScoreFilter.php, final class
AutoScoreFilter.php, final class
ClosedDealsFilter.php, final class
CoachingFeedbackAverageScore.php, final class
CoachingFeedbackCoachUserIn.php, final class
CommentCountRange.php, final class
CrmFieldCollection.php, final class
CurrentStage.php, final class
Customer.php, final class...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"Analyzing…","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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},{"role":"AXStaticText","text":"app ~/jiminny/app, folder","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".cursor, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".github","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".sonarlint, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".vscode, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".windsurf, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"app, sources root","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Actions, folder","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InviteUserToTeamAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MarkUserAsOnboardableAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SyncRecordingFlagsAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateTeamMemberAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateUserRolesAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Component","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Acl","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActionItems","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Activity","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityAnalytics","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivitySearch","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"EventSubscriber, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"FilterDefinition, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealInsights, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Security, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TeamInsights, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityActualDate.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityChannel.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityDurationRange.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityFilter.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityPlaylistIn.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityProviderIn.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityRecorded.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityRecordingStopped.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityScheduledDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityStatusIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityType.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityUpdatedDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AiCallScoreFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AutoScoreFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ClosedDealsFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedbackAverageScore.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedbackCoachUserIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CommentCountRange.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CrmFieldCollection.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CurrentStage.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Customer.php, final class","depth":11,"on_screen":false,"role_description":"text"}]...
|
-6365011757698063338
|
2218881650218383181
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
Analyzing…
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
EventSubscriber, folder
FilterDefinition, folder
DealInsights, folder
Security, folder
TeamInsights, folder
ActivityActualDate.php
ActivityChannel.php
ActivityDurationRange.php
ActivityFilter.php
ActivityPlaylistIn.php
ActivityProviderIn.php
ActivityRecorded.php
ActivityRecordingStopped.php, final class
ActivityScheduledDate.php, final class
ActivityStatusIn.php, class
ActivityType.php, final class
ActivityUpdatedDate.php, final class
AiCallScoreFilter.php, final class
AutoScoreFilter.php, final class
ClosedDealsFilter.php, final class
CoachingFeedbackAverageScore.php, final class
CoachingFeedbackCoachUserIn.php, final class
CommentCountRange.php, final class
CrmFieldCollection.php, final class
CurrentStage.php, final class
Customer.php, final class...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35133
|
1315
|
1
|
2026-05-13T12:13:47.974866+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674427974_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false}]...
|
-7285285044845922623
|
-7200408448544417441
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}...
|
35132
|
NULL
|
NULL
|
NULL
|
|
35134
|
1316
|
1
|
2026-05-13T12:13:47.974844+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674427974_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.38464096,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
983806314493535812
|
-8132342958709953598
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
PhostormFV faVsco.js~ViewINavigarecode%9 JY-20891-improve-sms-text-relaProletey© UserInvitationDTO.php© MailboxController.php© NotSupportedException.f© NumberUnavailableExcepTextkelayservice.php© Sso.phpossocontroller.ong© OperationException.php© OutOfBoundsException.pl © TextMessagingService.phpsms-relay-ralled.blade.pnp©smsMessage.png© SmsLength.php© QuotaExceededException© RateLimitException.php© RegistrationInvitationMisn© RequestQueuedForDeferr© ResponseException.phpdeclare(strict_types=1);kingcentralexception.ong© RingCentralExtensionNotfnamespace Jiminny\Http\Controllers\API\TeamInsights;kunumeexception.phg( sequencenumoer-xcepu› use ...(5 servicelnceqration-xcepu© ServiceUnavailableExceptclass DashboardController extends BaseController( SidekickSettinasExceptio( Socia AccountNotFound =24 đ( Socia AccountTokeninvali© SyncActivityException.phTenant solation Exceotion© TextRelayException.phppublic function __construct(Response $response,private readonly ActivitySearch\Service\ActivitySearch $activitySearch,privace readonly leaminstgntskepostcory srepostcoryD 4...F(4TooManvFailedActivities..© TranscriptionNotindexedE(4) UnexoectedCallExceotion33 (0g ›ctl/aoi/viream-insicnts/dasnboaraceaminsiants.aashboarolpublic function fetch(Request $request): JsonResponsef...,© UnexpectedEloquentMod© UnexpectedValueExceptis© ZipAttackException.php? private function getActivity0verTime(User $user, FilterpefinitionCollection $filterSet): array{...}› DD FFMpeg> D Formatsv D Guardsprivate function getCoachingBreakdownBvUserRole(User Suser. Criteria Scriteria): arravS...}l© Sso.php© ViewerGuard.php> D Helpers~ ДHttPprivate function getCoachinaOverTimedUser Suser,Criteria Scriteria.> D AccessTokenProviderv controllers~ DAPI> D AiCallScoring): array f..}AlReports> D Dealinsiahts• Oooortunitvprivate function getEngagementStats(FilterDefinitionCollection $filterSet): array{….}› D PageM Scorecardslusage• M Settinas209private function getCommonTopics(FilterDefinitionCollection $filterSet): arrayf…,v Teaminsiahts© ActivityStatsCor 251(C) CoachinaFeedb:(C) TeaminciahtsAi(5|X1 A v 632633634- vE laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] x& console [EU]A console [STAGING]Tx: AutovORDER BY t.name, calendar domain:liminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 74049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uvid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate Zimits:select * from &ated_report_results where gedie type = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text_relays where created_at › '2026-05-01'# and id IN (32415, 32416);and id = 32412;select * from users where team_id = 2 and email like "%scott%' and id = 29510;SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436Support Daily - 2m left100% L2Wed 13 May 15:13:47U AskJiminnyReportActivityServiceTest vCascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..ThoughtComplete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php:33-68bphppublic tunction tetch Request Srequest): Jsonkesponsesuser - schis->getuserr ronkequestisrequesciScriteria = Criteria::createFromRequest(Srequest-sallo. Suser->aetTimezone@)•Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),return Sthis->response->withArray(["widaets! = l'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),/... other widaetsContext set: CONTEXT_TEAM_ INSIGHTS_ACTIVITY = 'tean-insights-activity'2. Filter Set CreationFile: ActivitySearch.php: 132-244a ohoorivate tunction detteaminsiantsPageFilters(oool SisExoort = talse): FilterderinitioncollectionPoweawlarntaneanlaetanoeoeCollection: :make(lspecial casesFilterDefinition Teaminsiants DateRangeFilter::class.FilterDefinition\TeamInsights\Exists::class,Restrictream::class,RestrictUserGroupScope::classRectrictlicerActive:tclacelregular filtersAsk anvthina (84L)< CodeSWE-16W Windsurf Teams 71:60 UTF-8f 4 spaces...
|
35131
|
NULL
|
NULL
|
NULL
|
|
35135
|
1315
|
2
|
2026-05-13T12:13:50.803911+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674430803_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"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":"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":"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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
4046529603893115453
|
2218881650218382925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35136
|
1316
|
2
|
2026-05-13T12:13:50.803905+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674430803_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"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":"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":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.38464096,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"bounds":{"left":0.122340426,"top":0.17158818,"width":0.2855718,"height":0.8284118},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"}]...
|
-6030343723500956387
|
-7200399789889300129
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35137
|
1315
|
3
|
2026-05-13T12:14:00.018792+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674440018_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More> 0lallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSupport Daily • 2m left100% <78•Wed 13 May 15:13:59Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
-2075834801708757864
|
NULL
|
click
|
ocr
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More> 0lallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSupport Daily • 2m left100% <78•Wed 13 May 15:13:59Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
35135
|
NULL
|
NULL
|
NULL
|
|
35138
|
1316
|
3
|
2026-05-13T12:14:00.033148+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674440033_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891- PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891-improve-sms-text-reProledey© NotSupportedException.g© NumberUnavailableExcep© OperationException.php©OutOfBoundsException.pl© QuotaExceededException© RateLimitException.php© RegistrationInvitationMisn® RequestQueuedForDeferr© ResponseException.phpkingcentralexception.ong© RingCentralExtensionNotfkunumeexception.phg© SequenceNumberExcepti-( servicelnceqration-xcepr24 G® ServiceUnavailableExcept( SidekickSettinasExceptio© SocialAccountNotFoundE( Socia AccountTokeninvali© SyncActivityException.phTenant solation Exceotion© TextRelayException.php(4TooManvFailedActivities..© TranscriptionNotindexedE(4) UnexoectedCallExceotion© UnexpectedEloquentMod( UneynectedValueSycenti© ZipAttackException.php› DFFMpeg> D Formatsv D Guards© Sso.php© ViewerGuard.php> D Helpers> D AccessTokenProviderv controllers~ DAPI> D AiCallScoringAlReports> D Dealinsiahts• Oooortunitv› D PageM Scorecards• M Settinasv Teaminsiahts(C) ActivitvStatsCon(C) CoachinaFeedb:(C) TeaminciahtsAic|© MailboxController.php© Sso.php© SsoController.phpSmsMessage.png© SmsLength.phpnamespace Jiminny\Http\Controllers\API\TeamInsights;› use ...class DashboardController extends BaseControllerpublic function __construct(kesponse sresponseprivare readonly Accivicysearch service Accivicysearch saccivicysearchprivate readonly leaminsightskepository srepository,) 4..7GET/api/vl/team-insights/dashboardteam_insights.dashboardpublic function fetch(Request $request): JsonResponsef...}orivate function getActivitvovertimeUser Suser. FilterdefinitionCollection SfilterSet): arravSavarlabLeActivitychannels = Collection::makedModels Activity: TYPE SOFTPHONE.Models\Activity::TYPE_SOFTPHONE_INBOUND,SactivityChannels = $availableActivityChannels->flip()->map(static function (): int {...});$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)->map(static function (array $data) use ($activityChannels): array {..});return ['Labels' => $activityChannels-›keys()->all(),'points' => $data-›all(),private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): arrayf...7orivate Function detcoachino0vertime.User Suser.Criteria Scriteria.E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console (EU]A console [STAGING]=| X11 v —670Tx: AutovORDER BY t.name, calendar domain:liminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 537select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * from autlated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text_relays where created_at › '2026-05-01'# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;- 672 vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436Support Daily - 2m left100% L2Wed 13 May 15:13:59U AskJiminnyReportActivityServiceTest vCascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..ThoughtComplete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php:33-68bphppublic tunction tetch Request Srequest): Jsonkesponsesuser - schis->getuserr ronkequestisrequesciScriteria = Criteria::createFromRequest(Srequest-sallo. Suser->aetTimezone@):Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),return Sthis->response->withArray(["widaets! = l'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),/... other widaetsContext set: CONTEXT_TEAM_ INSIGHTS_ACTIVITY = 'tean-insights-activity'2. Filter Set CreationFile: ActivitySearch.php: 132-244a ohoorivate tunction detteaminsiantsPageFilters(oool SisExoort = talse): FilterderinitioncollectionPoweawlentaneaRlalethnoeoueCollection: :make(lspecial casesFilterDerinition Teaminsiahts DateRangeFilter::class.FilterDefinition\TeamInsights\Exists::class,Restrictream::class,RestrictUserGroupScope::classRectrictlicerActive:tclacelregular filtersAsk anvthina (84L)< CodeSWE-16W Windsurf Teams 71:60 UTF-8f 4 spaces...
|
NULL
|
-4477937132084257290
|
NULL
|
click
|
ocr
|
NULL
|
PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891- PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891-improve-sms-text-reProledey© NotSupportedException.g© NumberUnavailableExcep© OperationException.php©OutOfBoundsException.pl© QuotaExceededException© RateLimitException.php© RegistrationInvitationMisn® RequestQueuedForDeferr© ResponseException.phpkingcentralexception.ong© RingCentralExtensionNotfkunumeexception.phg© SequenceNumberExcepti-( servicelnceqration-xcepr24 G® ServiceUnavailableExcept( SidekickSettinasExceptio© SocialAccountNotFoundE( Socia AccountTokeninvali© SyncActivityException.phTenant solation Exceotion© TextRelayException.php(4TooManvFailedActivities..© TranscriptionNotindexedE(4) UnexoectedCallExceotion© UnexpectedEloquentMod( UneynectedValueSycenti© ZipAttackException.php› DFFMpeg> D Formatsv D Guards© Sso.php© ViewerGuard.php> D Helpers> D AccessTokenProviderv controllers~ DAPI> D AiCallScoringAlReports> D Dealinsiahts• Oooortunitv› D PageM Scorecards• M Settinasv Teaminsiahts(C) ActivitvStatsCon(C) CoachinaFeedb:(C) TeaminciahtsAic|© MailboxController.php© Sso.php© SsoController.phpSmsMessage.png© SmsLength.phpnamespace Jiminny\Http\Controllers\API\TeamInsights;› use ...class DashboardController extends BaseControllerpublic function __construct(kesponse sresponseprivare readonly Accivicysearch service Accivicysearch saccivicysearchprivate readonly leaminsightskepository srepository,) 4..7GET/api/vl/team-insights/dashboardteam_insights.dashboardpublic function fetch(Request $request): JsonResponsef...}orivate function getActivitvovertimeUser Suser. FilterdefinitionCollection SfilterSet): arravSavarlabLeActivitychannels = Collection::makedModels Activity: TYPE SOFTPHONE.Models\Activity::TYPE_SOFTPHONE_INBOUND,SactivityChannels = $availableActivityChannels->flip()->map(static function (): int {...});$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)->map(static function (array $data) use ($activityChannels): array {..});return ['Labels' => $activityChannels-›keys()->all(),'points' => $data-›all(),private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): arrayf...7orivate Function detcoachino0vertime.User Suser.Criteria Scriteria.E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console (EU]A console [STAGING]=| X11 v —670Tx: AutovORDER BY t.name, calendar domain:liminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 537select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * from autlated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text_relays where created_at › '2026-05-01'# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;- 672 vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436Support Daily - 2m left100% L2Wed 13 May 15:13:59U AskJiminnyReportActivityServiceTest vCascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..ThoughtComplete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php:33-68bphppublic tunction tetch Request Srequest): Jsonkesponsesuser - schis->getuserr ronkequestisrequesciScriteria = Criteria::createFromRequest(Srequest-sallo. Suser->aetTimezone@):Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),return Sthis->response->withArray(["widaets! = l'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),/... other widaetsContext set: CONTEXT_TEAM_ INSIGHTS_ACTIVITY = 'tean-insights-activity'2. Filter Set CreationFile: ActivitySearch.php: 132-244a ohoorivate tunction detteaminsiantsPageFilters(oool SisExoort = talse): FilterderinitioncollectionPoweawlentaneaRlalethnoeoueCollection: :make(lspecial casesFilterDerinition Teaminsiahts DateRangeFilter::class.FilterDefinition\TeamInsights\Exists::class,Restrictream::class,RestrictUserGroupScope::classRectrictlicerActive:tclacelregular filtersAsk anvthina (84L)< CodeSWE-16W Windsurf Teams 71:60 UTF-8f 4 spaces...
|
35136
|
NULL
|
NULL
|
NULL
|
|
35139
|
1315
|
4
|
2026-05-13T12:14:06.883479+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674446883_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More(all-Jiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala Cala• Support Daily • 1 m left100% <78•Wed 13 May 15:14:06Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
-6363969275488041375
|
NULL
|
click
|
ocr
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More(all-Jiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala Cala• Support Daily • 1 m left100% <78•Wed 13 May 15:14:06Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35141
|
1315
|
5
|
2026-05-13T12:14:20.071777+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674460071_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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}]...
|
4632306959447202944
|
-8344314095241406113
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error...
|
35139
|
NULL
|
NULL
|
NULL
|
|
35142
|
1316
|
5
|
2026-05-13T12:14:20.041977+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674460041_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.38464096,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"bounds":{"left":0.122340426,"top":0.0,"width":0.2855718,"height":1.0},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false}]...
|
-7285285044845922623
|
-7200408448544417441
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}...
|
35140
|
NULL
|
NULL
|
NULL
|
|
35143
|
1316
|
6
|
2026-05-13T12:14:21.630045+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674461630_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.38464096,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"bounds":{"left":0.122340426,"top":0.0,"width":0.2855718,"height":1.0},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"width":0.00731383,"height":0.018355945},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-5547984393176806690
|
-8344314095241406117
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35144
|
1315
|
6
|
2026-05-13T12:14:25.590579+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674465590_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
6177127136568989924
|
255948065095187873
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35145
|
1316
|
7
|
2026-05-13T12:14:25.569082+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674465569_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.38397607,"top":0.17478053,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
6177127136568989924
|
255948065095187873
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
35143
|
NULL
|
NULL
|
NULL
|
|
35146
|
1315
|
7
|
2026-05-13T12:14:40.319027+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674480319_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More(all-Jiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala Cala• Support Daily • 1 m left100% <78•Wed 13 May 15:14:40Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
3365413022552349965
|
NULL
|
click
|
ocr
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More(all-Jiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala Cala• Support Daily • 1 m left100% <78•Wed 13 May 15:14:40Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
35144
|
NULL
|
NULL
|
NULL
|
|
35147
|
1316
|
8
|
2026-05-13T12:14:40.304441+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674480304_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormFV faVsco.jsProjectINavigareCodeg9 JY-2089 PhostormFV faVsco.jsProjectINavigareCodeg9 JY-20891-improve-sms-text-rel© MailboxController.php© ActivityCommentRepositc©ActivityLogRepository.phiTextkelayservice.ong© ActivityMessageRepositol©ActivityMomentRepositor© ActivityProviderRepositor© ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.f© ActivityUploadSettingRepC AIPromptkepository.onc© AskAnythingRepository.pl 646© SsoController.phpE custom.logA console [STAGING]E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console [EU]Tx: AutovORDER BY t.name, calendar domain:©smsmessage.ong© SmsLength.phpA1 46 X11 A v 632(c) Coachingreedbackkeposc) crmTemolateRepositorv.rC) DeviceRerositorv.oho© ElasticActivityRepository.(c) EmailMessadeRenositorv.(C) GenericA PromotRenosito© GroupRepository.php© InboxEmailBatchReposito674CInboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.php© NotificationRepository.ph© ParticipantRepository.php© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p829© QuestionRepository.php(C) RoleChangeEventReposit© RoleRepository.phpc) SearchRenositorv.onv© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon(c) TeambomainsRenositorv(c) TeaminciahtcRenositorv.r© TeamRepository.php(C) ThemeRenositorv nhn@ TimeznnaRannsitorv nhnclass TeaminsightsRepositoryououc runction cetlashboardActzv1tvivermel633SaggregationData = $this-›searchService-›search($query, $this->model,queryName:| 'getDashboardActivity637SactivityData = Collection: :make(Iarray_get($aggregationData,array_get($aggregationData,key: 'voice_activities.over_time.buckets'),'text_activities.over_time.buckets'),->collapse()->reduce(static function (array $carry, array $bucketData): array {..},return lollection::make sactivitybata648649ouounc tunction oetlashboardcoachznouver.melUser SuserFilterDefinitionCollection $filterSet,?carbonImmutable SdatelimeRangeStartsat.?carbonimmutable SdatelimeRangeEndsat)strind shistooramintervall ="dav'.): Collection {...}652653655657659public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Co•66€public function getDashboardCoachingBreakdownCoachingFocusF1lLedByUserRole(FilterDefinitionCollection SfiltenSet): Collection {...}6644665zusagesprivate function getCompositeAggregationBy(BoolQuery $boolQuery,AbstractAggregation $sourceAggregation,tarray scustomAggregations = null.?AbstractAggregation $aggregationParent = null,?callable $compositeAggregationExtractor = null,?AbstractAggregation $immediateAggregationParent = null): LazyCollection f...+"668669— 670select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 74049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uvid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;select * from &lated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,187201select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;672vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 7976343610 usagesprivate function qetCompositeAggregationByUser(So jiminny040 A1 A40 V 65 ^Support Daily - 1m leftU AskJiminnyReportActivityServiceTest~100% L2Wed 13 May 15:14:40CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity Dereturn sthis->response->witharrav'filters' = $filterSet->render(),+0 ..'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),Context set: CONTEXT_TEAM_INSIGHTS_ACTIVITY = 'team-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244O phpprivate function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection:-makeriterverntcion\reamensignes varerangeritter.class,FilterDefinition Teaminsiahts Exists::class.Kestrictuserdroupscope..class,FilterDefinition Activitvchannel::classFilterDefinition\TeamInsights\ActivityDurationRange::class,FilterDefinition\TeamInsights\ActivityRecorded: :class, // KEY FILTERFulterDerinition Activitvivoe::class.2. Cilter Annlication Order3.1 Security Filters (Always Applied)RestrictTeam - Ensures user can only see their team's activitiesPectrictActivitvChannel /PoctrictActiustvGhannal.nhn×21-20)••phpAsk anvthina (84L)« Code SWF-1.6WN Windsurf Toams 590-20UTF.8f 4 spaces...
|
NULL
|
3401914128791363132
|
NULL
|
click
|
ocr
|
NULL
|
PhostormFV faVsco.jsProjectINavigareCodeg9 JY-2089 PhostormFV faVsco.jsProjectINavigareCodeg9 JY-20891-improve-sms-text-rel© MailboxController.php© ActivityCommentRepositc©ActivityLogRepository.phiTextkelayservice.ong© ActivityMessageRepositol©ActivityMomentRepositor© ActivityProviderRepositor© ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.f© ActivityUploadSettingRepC AIPromptkepository.onc© AskAnythingRepository.pl 646© SsoController.phpE custom.logA console [STAGING]E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console [EU]Tx: AutovORDER BY t.name, calendar domain:©smsmessage.ong© SmsLength.phpA1 46 X11 A v 632(c) Coachingreedbackkeposc) crmTemolateRepositorv.rC) DeviceRerositorv.oho© ElasticActivityRepository.(c) EmailMessadeRenositorv.(C) GenericA PromotRenosito© GroupRepository.php© InboxEmailBatchReposito674CInboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.php© NotificationRepository.ph© ParticipantRepository.php© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p829© QuestionRepository.php(C) RoleChangeEventReposit© RoleRepository.phpc) SearchRenositorv.onv© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon(c) TeambomainsRenositorv(c) TeaminciahtcRenositorv.r© TeamRepository.php(C) ThemeRenositorv nhn@ TimeznnaRannsitorv nhnclass TeaminsightsRepositoryououc runction cetlashboardActzv1tvivermel633SaggregationData = $this-›searchService-›search($query, $this->model,queryName:| 'getDashboardActivity637SactivityData = Collection: :make(Iarray_get($aggregationData,array_get($aggregationData,key: 'voice_activities.over_time.buckets'),'text_activities.over_time.buckets'),->collapse()->reduce(static function (array $carry, array $bucketData): array {..},return lollection::make sactivitybata648649ouounc tunction oetlashboardcoachznouver.melUser SuserFilterDefinitionCollection $filterSet,?carbonImmutable SdatelimeRangeStartsat.?carbonimmutable SdatelimeRangeEndsat)strind shistooramintervall ="dav'.): Collection {...}652653655657659public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Co•66€public function getDashboardCoachingBreakdownCoachingFocusF1lLedByUserRole(FilterDefinitionCollection SfiltenSet): Collection {...}6644665zusagesprivate function getCompositeAggregationBy(BoolQuery $boolQuery,AbstractAggregation $sourceAggregation,tarray scustomAggregations = null.?AbstractAggregation $aggregationParent = null,?callable $compositeAggregationExtractor = null,?AbstractAggregation $immediateAggregationParent = null): LazyCollection f...+"668669— 670select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 74049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uvid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;select * from &lated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,187201select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;672vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 7976343610 usagesprivate function qetCompositeAggregationByUser(So jiminny040 A1 A40 V 65 ^Support Daily - 1m leftU AskJiminnyReportActivityServiceTest~100% L2Wed 13 May 15:14:40CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity Dereturn sthis->response->witharrav'filters' = $filterSet->render(),+0 ..'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),Context set: CONTEXT_TEAM_INSIGHTS_ACTIVITY = 'team-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244O phpprivate function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection:-makeriterverntcion\reamensignes varerangeritter.class,FilterDefinition Teaminsiahts Exists::class.Kestrictuserdroupscope..class,FilterDefinition Activitvchannel::classFilterDefinition\TeamInsights\ActivityDurationRange::class,FilterDefinition\TeamInsights\ActivityRecorded: :class, // KEY FILTERFulterDerinition Activitvivoe::class.2. Cilter Annlication Order3.1 Security Filters (Always Applied)RestrictTeam - Ensures user can only see their team's activitiesPectrictActivitvChannel /PoctrictActiustvGhannal.nhn×21-20)••phpAsk anvthina (84L)« Code SWF-1.6WN Windsurf Toams 590-20UTF.8f 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35148
|
1315
|
8
|
2026-05-13T12:14:43.856662+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674483856_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
4706803030989287118
|
2218881650218382925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35149
|
1316
|
9
|
2026-05-13T12:14:43.856640+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674483856_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.38464096,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
4706803030989287118
|
2218881650218382925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
35147
|
NULL
|
NULL
|
NULL
|
|
35150
|
1315
|
9
|
2026-05-13T12:15:20.731169+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674520731_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
4706803030989287118
|
2218881650218382925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
35148
|
NULL
|
NULL
|
NULL
|
|
35151
|
1316
|
10
|
2026-05-13T12:15:20.738990+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674520738_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.38464096,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","depth":4,"bounds":{"left":0.122340426,"top":0.11731844,"width":0.29986703,"height":0.88268155},"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Http\\Controllers\\API\\TeamInsights;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Http\\JsonResponse;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Collection;\nuse Jiminny\\Component\\ActivitySearch;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Contracts\\ActivitySearch\\ContextAwareFilterDefinitionInterface;\nuse Jiminny\\Http\\Controllers\\API\\BaseController;\nuse Jiminny\\Http\\Responses\\Api\\Response;\nuse Jiminny\\Models;\nuse Jiminny\\Models\\PlaybackTheme\\Topic;\nuse Jiminny\\Models\\User;\nuse Jiminny\\Repositories\\TeamInsightsRepository;\nuse Jiminny\\VO\\Repository\\OnDemandActivitySearch\\Criteria;\n\nclass DashboardController extends BaseController\n{\n public function __construct(\n Response $response,\n private readonly ActivitySearch\\Service\\ActivitySearch $activitySearch,\n private readonly TeamInsightsRepository $repository,\n ) {\n parent::__construct($response);\n\n }\n\n public function fetch(Request $request): JsonResponse\n {\n $user = $this->getUserFromRequest($request);\n\n $criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),\n $user\n );\n\n $request->validate(\n $filterSet->getValidationRules()->all()\n );\n\n $dateTimeRangeStartsAt = $request->has('start_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))\n : null;\n $dateTimeRangeEndsAt = $request->has('end_date')\n ? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))\n : null;\n\n return $this->response->withArray([\n 'filters' => $filterSet->render(),\n 'widgets' => [\n 'activity-over-time' => $this->getActivityOverTime($user, $filterSet),\n 'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),\n 'coaching-over-time' => $this->getCoachingOverTime(\n $user,\n $criteria,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt,\n ),\n 'engagement-stats' => $this->getEngagementStats($filterSet),\n 'common-topics' => $this->getCommonTopics($filterSet),\n ],\n ]);\n }\n\n private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array\n {\n $availableActivityChannels = Collection::make([\n Models\\Activity::TYPE_CONFERENCE,\n Models\\Activity::TYPE_SOFTPHONE,\n Models\\Activity::TYPE_SOFTPHONE_INBOUND,\n Models\\Activity::TYPE_SMS_OUTBOUND,\n ]);\n\n $activityChannels = $availableActivityChannels\n ->flip()\n ->map(static function (): int {\n return 0;\n });\n\n $data = $this->repository->getDashboardActivityOverTime($user, $filterSet)\n ->map(static function (array $data) use ($activityChannels): array {\n return $activityChannels\n ->map(static function (int $defaultValue, string $activityChannel) use ($data): int {\n return $data[$activityChannel] ?? $defaultValue;\n })\n ->values()\n ->all();\n });\n\n return [\n 'labels' => $activityChannels->keys()->all(),\n 'points' => $data->all(),\n ];\n }\n\n private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array\n {\n $listens = $this->repository\n ->getDashboardCoachingBreakdownListensByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n )\n );\n\n $coachingFocusFilled = $this->repository\n ->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(\n ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,\n ),\n $user\n )\n );\n\n $data = $listens->mergeRecursive($coachingFocusFilled);\n\n $coachingHimself = $data\n ->map(static function (array $bucket, string $roomOwnerId): int {\n return Collection::make($bucket)\n ->filter(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->sum('count');\n })\n ->sum();\n\n $managerUserRoles = Collection::make(User::MANAGER_ROLES);\n\n $coachingByTeamMembers = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->reject(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n $coachingByManager = $data\n ->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {\n return Collection::make($bucket)\n ->reject(static function (array $userPlays) use ($roomOwnerId): bool {\n return $userPlays['userId'] === $roomOwnerId;\n })\n ->filter(static function (array $userPlays) use ($managerUserRoles): bool {\n return $managerUserRoles\n ->intersect($userPlays['userRoles'])\n ->isNotEmpty();\n })\n ->sum('count');\n })\n ->sum();\n\n return [\n 'self' => $coachingHimself,\n 'team' => $coachingByTeamMembers,\n 'manager' => $coachingByManager,\n ];\n }\n\n private function getCoachingOverTime(\n User $user,\n Criteria $criteria,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n ): array {\n $filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(\n $criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),\n $user\n );\n\n $data = $this->repository->getDashboardCoachingOverTime(\n $user,\n $filterSet,\n $dateTimeRangeStartsAt,\n $dateTimeRangeEndsAt\n )\n ->map(static function (int $value): array {\n return [\n $value,\n ];\n });\n\n return [\n 'labels' => [\n 'coaching-over-time',\n ],\n 'points' => $data->all(),\n ];\n }\n\n private function getEngagementStats(FilterDefinitionCollection $filterSet): array\n {\n return $this->repository->getDashboardEngagementStats($filterSet)->all();\n }\n\n private function getCommonTopics(FilterDefinitionCollection $filterSet): array\n {\n $topics = $this->repository->getCommonTopics($filterSet, 10);\n\n if ($topics->isEmpty()) {\n return [];\n }\n\n // possible improvement: fetch topics from elasticsearch instead\n $map = Topic::query()\n ->whereIn(\n 'uuid',\n $topics->keys()\n ->map(static function (string $id): string {\n return Topic::toOptimized($id);\n })\n ->all()\n )\n ->with('playbackTheme')\n ->get()\n ->keyBy('id_string');\n\n return $topics\n ->filter(static fn (float $count, string $key): bool => $map->has($key))\n ->map(static function (float $count, string $key) use ($map): array {\n /** @var Topic $topic */\n $topic = $map[$key];\n $theme = $topic->getPlaybackTheme();\n\n return [\n 'title' => $topic->getTitle(),\n 'count' => $count,\n 'theme' => [\n 'title' => $theme->getTitle(),\n 'color' => $theme->getColor(),\n ],\n ];\n })\n ->values()\n ->all();\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
4706803030989287118
|
2218881650218382925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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\Http\Controllers\API\TeamInsights;
use Carbon\CarbonImmutable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Jiminny\Component\ActivitySearch;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Contracts\ActivitySearch\ContextAwareFilterDefinitionInterface;
use Jiminny\Http\Controllers\API\BaseController;
use Jiminny\Http\Responses\Api\Response;
use Jiminny\Models;
use Jiminny\Models\PlaybackTheme\Topic;
use Jiminny\Models\User;
use Jiminny\Repositories\TeamInsightsRepository;
use Jiminny\VO\Repository\OnDemandActivitySearch\Criteria;
class DashboardController extends BaseController
{
public function __construct(
Response $response,
private readonly ActivitySearch\Service\ActivitySearch $activitySearch,
private readonly TeamInsightsRepository $repository,
) {
parent::__construct($response);
}
public function fetch(Request $request): JsonResponse
{
$user = $this->getUserFromRequest($request);
$criteria = Criteria::createFromRequest($request->all(), $user->getTimezone());
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),
$user
);
$request->validate(
$filterSet->getValidationRules()->all()
);
$dateTimeRangeStartsAt = $request->has('start_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('start_date'))
: null;
$dateTimeRangeEndsAt = $request->has('end_date')
? CarbonImmutable::createFromFormat('Y-m-d H:i:s', $request->input('end_date'))
: null;
return $this->response->withArray([
'filters' => $filterSet->render(),
'widgets' => [
'activity-over-time' => $this->getActivityOverTime($user, $filterSet),
'coaching-breakdown' => $this->getCoachingBreakdownByUserRole($user, $criteria),
'coaching-over-time' => $this->getCoachingOverTime(
$user,
$criteria,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt,
),
'engagement-stats' => $this->getEngagementStats($filterSet),
'common-topics' => $this->getCommonTopics($filterSet),
],
]);
}
private function getActivityOverTime(User $user, FilterDefinitionCollection $filterSet): array
{
$availableActivityChannels = Collection::make([
Models\Activity::TYPE_CONFERENCE,
Models\Activity::TYPE_SOFTPHONE,
Models\Activity::TYPE_SOFTPHONE_INBOUND,
Models\Activity::TYPE_SMS_OUTBOUND,
]);
$activityChannels = $availableActivityChannels
->flip()
->map(static function (): int {
return 0;
});
$data = $this->repository->getDashboardActivityOverTime($user, $filterSet)
->map(static function (array $data) use ($activityChannels): array {
return $activityChannels
->map(static function (int $defaultValue, string $activityChannel) use ($data): int {
return $data[$activityChannel] ?? $defaultValue;
})
->values()
->all();
});
return [
'labels' => $activityChannels->keys()->all(),
'points' => $data->all(),
];
}
private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): array
{
$listens = $this->repository
->getDashboardCoachingBreakdownListensByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
)
);
$coachingFocusFilled = $this->repository
->getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
$this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(
ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_COACHING_FOCUS_FILLED,
),
$user
)
);
$data = $listens->mergeRecursive($coachingFocusFilled);
$coachingHimself = $data
->map(static function (array $bucket, string $roomOwnerId): int {
return Collection::make($bucket)
->filter(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->sum('count');
})
->sum();
$managerUserRoles = Collection::make(User::MANAGER_ROLES);
$coachingByTeamMembers = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->reject(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
$coachingByManager = $data
->map(static function (array $bucket, string $roomOwnerId) use ($managerUserRoles): int {
return Collection::make($bucket)
->reject(static function (array $userPlays) use ($roomOwnerId): bool {
return $userPlays['userId'] === $roomOwnerId;
})
->filter(static function (array $userPlays) use ($managerUserRoles): bool {
return $managerUserRoles
->intersect($userPlays['userRoles'])
->isNotEmpty();
})
->sum('count');
})
->sum();
return [
'self' => $coachingHimself,
'team' => $coachingByTeamMembers,
'manager' => $coachingByManager,
];
}
private function getCoachingOverTime(
User $user,
Criteria $criteria,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
): array {
$filterSet = $this->activitySearch->getTeamInsightsPageFilterSet(
$criteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_PLAYBACK),
$user
);
$data = $this->repository->getDashboardCoachingOverTime(
$user,
$filterSet,
$dateTimeRangeStartsAt,
$dateTimeRangeEndsAt
)
->map(static function (int $value): array {
return [
$value,
];
});
return [
'labels' => [
'coaching-over-time',
],
'points' => $data->all(),
];
}
private function getEngagementStats(FilterDefinitionCollection $filterSet): array
{
return $this->repository->getDashboardEngagementStats($filterSet)->all();
}
private function getCommonTopics(FilterDefinitionCollection $filterSet): array
{
$topics = $this->repository->getCommonTopics($filterSet, 10);
if ($topics->isEmpty()) {
return [];
}
// possible improvement: fetch topics from elasticsearch instead
$map = Topic::query()
->whereIn(
'uuid',
$topics->keys()
->map(static function (string $id): string {
return Topic::toOptimized($id);
})
->all()
)
->with('playbackTheme')
->get()
->keyBy('id_string');
return $topics
->filter(static fn (float $count, string $key): bool => $map->has($key))
->map(static function (float $count, string $key) use ($map): array {
/** @var Topic $topic */
$topic = $map[$key];
$theme = $topic->getPlaybackTheme();
return [
'title' => $topic->getTitle(),
'count' => $count,
'theme' => [
'title' => $theme->getTitle(),
'color' => $theme->getColor(),
],
];
})
->values()
->all();
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35152
|
1316
|
11
|
2026-05-13T12:15:25.162324+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674525162_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.3636968,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.37300533,"top":0.17478053,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"11","depth":4,"bounds":{"left":0.38297874,"top":0.17478053,"width":0.008976064,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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}]...
|
-8887292901320558836
|
255948069381766561
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
35151
|
NULL
|
NULL
|
NULL
|
|
35153
|
1315
|
10
|
2026-05-13T12:15:25.138211+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674525138_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"11","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}]...
|
-162509423965148781
|
-7051496640360641598
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:25Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
35148
|
NULL
|
NULL
|
NULL
|
|
35154
|
1315
|
11
|
2026-05-13T12:15:26.794748+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674526794_m1.jpg...
|
PhpStorm
|
faVsco.js – TextRelay.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:26Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
-4509238414457679012
|
NULL
|
click
|
ocr
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:26Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35155
|
1316
|
12
|
2026-05-13T12:15:26.794752+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674526794_m2.jpg...
|
PhpStorm
|
faVsco.js – TextRelay.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhpStormEV favsco.jsProjectVIewINavigarecodeLarave PhpStormEV favsco.jsProjectVIewINavigarecodeLaravelg9 JY-20891-improve-sms-text-relaysRefactorloOlWindow©ActivityCommentRepositc©ActivityLogRepository-phy© ActivityMessageRepositol©ActivityMomentRepositor©Textmessagingservice.phg© ActivityProviderRepositor©ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.-F51@sclass |TextRelay extends Model© ActivityUploadSettingRep©AiPromptRepository.php53@AskAnythingRepository.pl54use Enums:use RequiresUUID;(c) Automateaкeporiskeposic) Coachingreedbackkedos© Crm TemplateFilterRepostc) crmTemolateRepositorv.r© CrmTemplateRunRepositcC) DeviceRerositorv.oho© ElasticActivityRepository.l(c) EmailMessadeRenositorv.© GenericAiPromptReposito62© GroupRepository.php© InboxEmailBatchReposito65InboxRepository.php© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.php6870© NotificationRepository.ph© ParticipantRepository.php© ParticipantSpeechReposit73 0© ParticipantStatsRepositor© PlaybookCategoryReposit75 C© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p© QuestionRepository.php© RoleChangeEventRepositi© RoleRepository.php@ SearchRepositorv.ohr© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.phpC) SubscriotionSetRebositon87 ₫©TaskRepository.php(C) TeamA ContextRenositon© TeamDomainsRepository.© TeaminsightsRepository.p©TeamRepository.php910(C) ThemeRenositorv nhn@ TimeznnaRannsitorv nhnpublic const STATUS PROCESSING = 'processing';public const STATUS EATLED = 'failed';public const STATUS_PROCESSEQ = 'processed';public const PROVIDER_GSUITE = 'gsuite':protected Senumstatuses = 1Self::STATUS_FAILED,self::STATUS_PROCESSED,protected SenunPreviders = lself::PROVIDER_GSUITE,protected $table = 'text_relays';protected $fillable = ['email_provider','email_provider_id','email_ sent_at',"reciplent'origin_activity_id','activity_id',"code',orotected Saobends ="no strino'.orotected Shidden = П"uuid'• sso.onp© MailboxController.phpA SF jiminny@localhost]# HS_local (jiminny@localhost]A console (PROD] X A console [EU]© SsoController.phpA console [STAGING)©smsmessage.ong© SmsLength.php| A19 23 A v 632633634639637ORDER BY t.name,select * from users u join calendars c 1<->1..n: on c.user_id = u.idwhere u.team_id = 882;select * from activities where id = 74049485; # team 563 crm 537select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389; # team 563 crm 537id = 58081273; # team563 crm 537select * from activities where id = 54520297: # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated reportswhere id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;automated_report_results where nedia tyRe = 'pdf' and status = 2and id IN (18,1872);select * fromSELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE Uvid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text_relays where created_at › '2026-05-01'# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like "%scott%' and id = 29510;SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436So jiminny040 A1 A40 V 65 ^sonnt keview • In 40m100% L2Wed 13 May 15:15:26U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity Dereturn sthis->response->w1tharrav.'filters' = $filterSet->render(),+0 ..'activity-over-time' => Sthis->getActivityOverTime($user, $filterSet),Context set: CONTEXT_TEAM_INSIGHTS_ACTIVITY = 'team-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244O phpprivate function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection:makeriterverintcion\reamensignes varerangeritrer.class,FilterDefinition Teaminsiahts Exists::class.Kestrictuserdroupscope..class,FilterDefinition Activitvchannel::classFilterDefinition\TeamInsights\ActivityDurationRange::class,FilterDefinition\TeamInsights\ActivityRecorded: :class, // KEY FILTERFulterDerinition Activitvivoe::class.2. Cilter Annlication Order3.1 Security Filters (Always Applied)RestrictTeam - Ensures user can only see their team's activitiesPectrictActivitvChannel /PoctrictActiustvGhannal.nhn×21-20)••phpAsk anvthina (84L)« Code SWF-1.6WN Windsurf Toams 51-7UTF.8f 4 spaces...
|
NULL
|
1686657028748437370
|
NULL
|
click
|
ocr
|
NULL
|
PhpStormEV favsco.jsProjectVIewINavigarecodeLarave PhpStormEV favsco.jsProjectVIewINavigarecodeLaravelg9 JY-20891-improve-sms-text-relaysRefactorloOlWindow©ActivityCommentRepositc©ActivityLogRepository-phy© ActivityMessageRepositol©ActivityMomentRepositor©Textmessagingservice.phg© ActivityProviderRepositor©ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.-F51@sclass |TextRelay extends Model© ActivityUploadSettingRep©AiPromptRepository.php53@AskAnythingRepository.pl54use Enums:use RequiresUUID;(c) Automateaкeporiskeposic) Coachingreedbackkedos© Crm TemplateFilterRepostc) crmTemolateRepositorv.r© CrmTemplateRunRepositcC) DeviceRerositorv.oho© ElasticActivityRepository.l(c) EmailMessadeRenositorv.© GenericAiPromptReposito62© GroupRepository.php© InboxEmailBatchReposito65InboxRepository.php© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.php6870© NotificationRepository.ph© ParticipantRepository.php© ParticipantSpeechReposit73 0© ParticipantStatsRepositor© PlaybookCategoryReposit75 C© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p© QuestionRepository.php© RoleChangeEventRepositi© RoleRepository.php@ SearchRepositorv.ohr© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.phpC) SubscriotionSetRebositon87 ₫©TaskRepository.php(C) TeamA ContextRenositon© TeamDomainsRepository.© TeaminsightsRepository.p©TeamRepository.php910(C) ThemeRenositorv nhn@ TimeznnaRannsitorv nhnpublic const STATUS PROCESSING = 'processing';public const STATUS EATLED = 'failed';public const STATUS_PROCESSEQ = 'processed';public const PROVIDER_GSUITE = 'gsuite':protected Senumstatuses = 1Self::STATUS_FAILED,self::STATUS_PROCESSED,protected SenunPreviders = lself::PROVIDER_GSUITE,protected $table = 'text_relays';protected $fillable = ['email_provider','email_provider_id','email_ sent_at',"reciplent'origin_activity_id','activity_id',"code',orotected Saobends ="no strino'.orotected Shidden = П"uuid'• sso.onp© MailboxController.phpA SF jiminny@localhost]# HS_local (jiminny@localhost]A console (PROD] X A console [EU]© SsoController.phpA console [STAGING)©smsmessage.ong© SmsLength.php| A19 23 A v 632633634639637ORDER BY t.name,select * from users u join calendars c 1<->1..n: on c.user_id = u.idwhere u.team_id = 882;select * from activities where id = 74049485; # team 563 crm 537select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389; # team 563 crm 537id = 58081273; # team563 crm 537select * from activities where id = 54520297: # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated reportswhere id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;automated_report_results where nedia tyRe = 'pdf' and status = 2and id IN (18,1872);select * fromSELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE Uvid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text_relays where created_at › '2026-05-01'# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like "%scott%' and id = 29510;SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436So jiminny040 A1 A40 V 65 ^sonnt keview • In 40m100% L2Wed 13 May 15:15:26U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity Dereturn sthis->response->w1tharrav.'filters' = $filterSet->render(),+0 ..'activity-over-time' => Sthis->getActivityOverTime($user, $filterSet),Context set: CONTEXT_TEAM_INSIGHTS_ACTIVITY = 'team-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244O phpprivate function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection:makeriterverintcion\reamensignes varerangeritrer.class,FilterDefinition Teaminsiahts Exists::class.Kestrictuserdroupscope..class,FilterDefinition Activitvchannel::classFilterDefinition\TeamInsights\ActivityDurationRange::class,FilterDefinition\TeamInsights\ActivityRecorded: :class, // KEY FILTERFulterDerinition Activitvivoe::class.2. Cilter Annlication Order3.1 Security Filters (Always Applied)RestrictTeam - Ensures user can only see their team's activitiesPectrictActivitvChannel /PoctrictActiustvGhannal.nhn×21-20)••phpAsk anvthina (84L)« Code SWF-1.6WN Windsurf Toams 51-7UTF.8f 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35156
|
1315
|
12
|
2026-05-13T12:15:34.869293+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674534869_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
7581618884890279806
|
-8204352174202572862
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
FirefoxFileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:34Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
35154
|
NULL
|
NULL
|
NULL
|
|
35157
|
1316
|
13
|
2026-05-13T12:15:34.869298+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674534869_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
7581618884890279806
|
-8204352174202572862
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
PhostormProledeyINavigareCodeg9 JY-20891-improve-sms-text-r© coachingreedoc conversationsec) leaminsicnisAuThemeTopicsCoTopicsinDealsCc› D Themesv → UserAutomatedRep© UserAutomatedfv DV2(C) Activitvv2contrC) ASKAnvininacon(C) DealsV2Controll© OnDemandV2CcC) PlavlistControllePlaylistShareCorPlaylistTrackCor© TranscriptionSur© UploadControlleOeelelalne micelninielActivityController.pc Alurmnotescontrobasecontroller.onp'ealalealtalainra• DealLevelrromorse24 G33 23YC) OraanizationMemb.© OrganizationSyncCC) PartnerController.n© PhoneNumberContiYa DiauhackControllerPlaylistController.pt") CrimControllor nhn© MailboxController.php• sso.onpossocontroller.ongSmsMessage.png© SmsLength.phpclass Dashboardcontroller extends Basecontroller5|X1 A y 632633634public function __construct(Kesponse sresponseprivate readonly ActivitySearch\Service\ActivitySearch $activitySearch,privace readonly leaminsighcskeposicory sreposicory) 4..7GET /api/v1/teapubuac function fetchRequest Srequest: JsonResponse642Suser = Sthis->getUserFromRequest(Srequest):Scriteria = Criteria:: createFromRequest Srequest-›allo. Suser->qettimezoneoo:$filterSet = $this->activitySearch->getTeamInsigh|tsPageFilterSet(Scriteria->setContext( context: ContextAwareFilterDefinitioninterface::CONTEXT_TEAM_INSIGHTS_ACTIVIT647SusenSrequest->validate(SfilterSet->getValidationRules()->all()652$dateTimeRangeStartsAt = $request->has( key: 'start_date')? CarbonImmutable: :createFromFormat ( format: 'Y-m-d H:i:S', $request-›input( key: 'start_date')).nuLl$dateTimeRangeEndsAt = $request-›has ( key: 'end_date')? CarbonImmutable: :createFromFormat( format:) 'Y-m-d H:i:s', $request->input( key: 'end_date')).nuLl655657659666return $this->response->withArray(['filters' => $filterSet->render(),'widgets' =>'activity-over-time' => Sthis->qetactiv1tvovertimesuser, Stilterset).'coaching-breakdown' => Sthis->qetCoachingBreakdownBvUserRole(Suser. Scriteria).'coaching-over-time' => Sthis->qetcoachinqoverT1mesuser.Scriteria,SdateTimeRangeStartsAt.SdateTimeRangeEndsAt664665667669— 672 vengagement-stats' => $this->getEngagementStats($filterSet),'common-tonics' => Sthis->aetCommontonics(SfilterSet).laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console (EU]A console [STAGING]Tx: AutovORDER BY t.name, calendar domain:So jiminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere U.team_ 1d = 882^select * from activities where id = 74049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uvid_to_bin(^8827f672-202d-4162-9d04-73ff5f0566a9') = uvidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate Zimits:select * from &and id IN (18,187201select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);ted_report_results where nedia tyRe = 'paf' and status = 2SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 32412;select * from users where team_id = 2 and email like "%scott%' and id = 29510;SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt keview • In 40m100% L2Wed 13 May 15:15:34U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php: 33-680 phpoublic function fetchRequest Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(SrequestScriteria = criteria:: createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validate SfilterSet->aetValidat ionRules→>al100:return Sthis->response->withArray(l→ sultterser-renderl,'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(Suser. sfilterSet).Context set: CONTEXT TEAM INSIGHTS ACTIVITY = 'team-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection::make/Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiohts.Exists::class.RestrictUserGroupScope: : class,RestrictActivityChannel::class.RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6W Windsurf Teamc28.58 UTF.9f 4 spaces...
|
35155
|
NULL
|
NULL
|
NULL
|
|
35158
|
1315
|
13
|
2026-05-13T12:15:39.124853+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674539124_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
FirefoxFileEditViewHistoryBookmarksToolsWindowHelp FirefoxFileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:38Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
5381841783538770368
|
NULL
|
click
|
ocr
|
NULL
|
FirefoxFileEditViewHistoryBookmarksToolsWindowHelp FirefoxFileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:38Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35159
|
1316
|
14
|
2026-05-13T12:15:39.134859+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674539134_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
-3346245719057788321
|
-7196539678208059965
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
PhostormINavigareCodeFV faVsco.js vg9 JY-20891-improve-sms-text-reProledey© MailboxController.php© CoachingFeedb:© ConversationsCTextkelayservice.ong© Sso.phpossocontroller.ongleDhCalelerleleelnitC Engagementcor©smsMessage.png© SmsLength.phpc) leaminsicnisAuThemeTopicsCoTopicsinDealsCcclass Dashboardcontroller extends Basecontroulerououc tunction ferchreguest Srequest: sonresponseD Themesv → UserAutomatedRep© UserAutomatedfenoagemenc-staus = schis-›oeccnoadementscacs stilcersec).common-copncs = sch1s->qeccommoniop1csstzlcersec).v DV2(C) Activitvv2contrC) AskAnvthinacon© AskJiminnyRepo(C) DealsV2Controll© OnDemandV2CcC) PlavlistControllePlaylistShareCorYe) DlavlistTrackeor© TranscriptionSur© UploadControlleOeelelalne micelninielActivityController.p© AiCrmNotesControlbasecontroller.onp© ClientTokenControl• DealLevelrromorse5|X1 A v 632634C) MetadataControllenc) NumberAllocatorcd© OrganizationLicensYC) OraanizationMembilC) OraanizationPoleseii© OrganizationSyncC8 DartnerController nl 101© PhoneNumberContiYa DiauhackController© PlaylistController.pt 172") CrimControllor nhn1 usageprivate function getActivityoverlime(User suser, FilterDefinitionCollection SfilterSet): arraySavailableActivitvChannels = Collection:makediModels\Activity::TYPE_CONFERENCE,Models Activitv:: TYPE SOFTPHONE.Models \Activity::TYPE_SOFTPHONE_INBOUND,Models Activitv •TYps SMS NlltRollNni$activityChannels = $availableActivityChannels->flip()->map(static function (): int {return 0;F);$data = $this->repository->getDashboardActivity0verTime($user, $filterSet)->map(static function (array $data) use ($activityChannels): array {return sactivitychannels->map(static function (int $defaultValue, string $activityChannel) use ($data): int {return sdatalsactzv1tychannel ?? Sdetaultvaluer->valueso→>aloF);'labels' => SactivitvChannels->kevs()->al1@"points' => Sdata->allolprivate function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): arrayf….;llicaheAannotcachinanvonTimoelays to new branch origin/JY-20891-improve-sms-text-relays // Create pull request (33 minutes ago)E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] xA console (EU)A console [STAGING] Tx: AutovORDER BY t.name, calendar domain:So jiminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 537select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uvid_to_bin(^8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * from &ated_report_results where gedie type = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 32412;select * from users where team_id = 2 and email like "%scott%' and id = 29510;672vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt keview • In 40m100% L2Wed 13 May 15:15:38U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php: 33-680 phpoublic function fetchRequest Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(Srequest:Scriteria = Criteria::createrromRequest(Srequest→>all, Suser->gettimezone):Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validateSfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l→ sultterser renderl),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT TEAM INSIGHTS ACTIVITY = 'team-insichts-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection::make/Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiants Exists::class.RestrictUserGroupScope: : class,RestrictActivityChannel::class.RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6WN Windsurf Toams 71.22 UTF.9f 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35160
|
1315
|
14
|
2026-05-13T12:15:49.885207+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674549885_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:49Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
-4804116211032417520
|
NULL
|
click
|
ocr
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:49Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
35158
|
NULL
|
NULL
|
NULL
|
|
35161
|
1316
|
15
|
2026-05-13T12:15:49.887145+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674549887_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891- PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891-improve-sms-text-reProledey© ActivityCommentRepositc©ActivityLogRepository.ph|Textkelayservice.ong© ActivityMessageRepositol© ActivityMomentRepositor: © TextMessagingService.php© ActivityProviderRepositor© ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.f© ActivityUploadSettingRepC AIPromptkepository.ong© AskAnythingRepository.pl(c) Automateaкeporiskeposic) Coachingreedbackkedosc) crmTemolateRepositorv.rC) DeviceRerositorv.oho© ElasticActivityRepository.(c) EmailMessadeRenositorv.© GenericAiPromptReposito© GroupRepository.php© InboxEmailBatchRepositoCInboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.php© NotificationRepository.ph© ParticipantRepository.php© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p(C) RolechangeEventReposit© RoleRepository.php(c) SearchRenositorv.ono© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon611© TeamDomainsRepository.612(c) TeaminciahtcRenositorv.r© TeamRepository.php(C) ThemeRenositorv nhnclass TeamInsightsRepositorypublic function getcoachingActivitlesuveri1mebraLldowncint $page,int $limit = 25): Collection {...}public function getEngagementActivitiesDrillDown(User Sconsumer,FilterDefinitionCollection $filterSet,string selasticsearchcocumn,int $page,int $limit = 25,): Collection {.}643public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): 646• public function getDashboardActivityOverTimeCUser suserFilterDefinitionCollection $filterSet,string shistoqraminterval =day): Collection {stmezoneuttser = suser->oet.zmezoneurtserr653ShoolQuerv = SfilterSet->aetBoolQuervaSfilterSet->extractElasticSearchQueries()657Sauery = new Quervo)659660->setSourced os: false)->addAggregation(inew Filter(name: 'voice_activities',664(clone $boolQuery)-665->addFilter(666(new BoolQuery())->addShould((new Term())->setTerm( key: 'type.keyword',value: Activity: : TYPE_T 668->addShould((new Term())->setTerm( key: 'type.keyword',Activity::TYPE_S 669->addShould((new Term())->setTerm( key: 'type.keyword',value: Activity:: TYPE,- 670->addFilter(new Exists( field: 'actual_start_time')672v->addAggregation(uched.IV.20801_imnrove.cmc-teyt_rolavs ta.new hranch.oriain/.IV.20801_imnrove.cmc-teyt-rolavs //CGreate null reauect (22 minutes.aaol(new DateHistogram( name:) 'over_time', field: 'actual_end_time', ShistogramInterval))© MailboxController.php• sso.onp© SsoController.phpE custom.logA console [STAGING]E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console (EU]©smsmessage.ongTx: AutovORDER BY t.name, calendar domain:So jiminny© SmsLength.php040 A1 A40 V 65 ^A1 46 X11 A 4 632633select * trom users u jo1n calendars c 1<->I..n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;select * from &mated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,18/201select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt keview • In 40m100% L2Wed 13 May 15:15:49U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php: 33-680 phpoublic function fetch Request Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(SrequestScriteria = criteria::createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validate SfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l→ sultterser renderl),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT TEAM INSIGHTS ACTIVITY = 'team-insichts-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection:make(Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiohts.Exists::class.RestrictUserGroupScope: : class,RestrictActivityChannel::class.RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6UTF-8f 4 spaces...
|
NULL
|
4900938166904724442
|
NULL
|
click
|
ocr
|
NULL
|
PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891- PhostormFV faVsco.js~VIewINavigareCodeg9 JY-20891-improve-sms-text-reProledey© ActivityCommentRepositc©ActivityLogRepository.ph|Textkelayservice.ong© ActivityMessageRepositol© ActivityMomentRepositor: © TextMessagingService.php© ActivityProviderRepositor© ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.f© ActivityUploadSettingRepC AIPromptkepository.ong© AskAnythingRepository.pl(c) Automateaкeporiskeposic) Coachingreedbackkedosc) crmTemolateRepositorv.rC) DeviceRerositorv.oho© ElasticActivityRepository.(c) EmailMessadeRenositorv.© GenericAiPromptReposito© GroupRepository.php© InboxEmailBatchRepositoCInboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.php© NotificationRepository.ph© ParticipantRepository.php© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p(C) RolechangeEventReposit© RoleRepository.php(c) SearchRenositorv.ono© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon611© TeamDomainsRepository.612(c) TeaminciahtcRenositorv.r© TeamRepository.php(C) ThemeRenositorv nhnclass TeamInsightsRepositorypublic function getcoachingActivitlesuveri1mebraLldowncint $page,int $limit = 25): Collection {...}public function getEngagementActivitiesDrillDown(User Sconsumer,FilterDefinitionCollection $filterSet,string selasticsearchcocumn,int $page,int $limit = 25,): Collection {.}643public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): 646• public function getDashboardActivityOverTimeCUser suserFilterDefinitionCollection $filterSet,string shistoqraminterval =day): Collection {stmezoneuttser = suser->oet.zmezoneurtserr653ShoolQuerv = SfilterSet->aetBoolQuervaSfilterSet->extractElasticSearchQueries()657Sauery = new Quervo)659660->setSourced os: false)->addAggregation(inew Filter(name: 'voice_activities',664(clone $boolQuery)-665->addFilter(666(new BoolQuery())->addShould((new Term())->setTerm( key: 'type.keyword',value: Activity: : TYPE_T 668->addShould((new Term())->setTerm( key: 'type.keyword',Activity::TYPE_S 669->addShould((new Term())->setTerm( key: 'type.keyword',value: Activity:: TYPE,- 670->addFilter(new Exists( field: 'actual_start_time')672v->addAggregation(uched.IV.20801_imnrove.cmc-teyt_rolavs ta.new hranch.oriain/.IV.20801_imnrove.cmc-teyt-rolavs //CGreate null reauect (22 minutes.aaol(new DateHistogram( name:) 'over_time', field: 'actual_end_time', ShistogramInterval))© MailboxController.php• sso.onp© SsoController.phpE custom.logA console [STAGING]E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console (EU]©smsmessage.ongTx: AutovORDER BY t.name, calendar domain:So jiminny© SmsLength.php040 A1 A40 V 65 ^A1 46 X11 A 4 632633select * trom users u jo1n calendars c 1<->I..n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;select * from &mated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,18/201select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt keview • In 40m100% L2Wed 13 May 15:15:49U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php: 33-680 phpoublic function fetch Request Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(SrequestScriteria = criteria::createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validate SfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l→ sultterser renderl),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT TEAM INSIGHTS ACTIVITY = 'team-insichts-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection:make(Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiohts.Exists::class.RestrictUserGroupScope: : class,RestrictActivityChannel::class.RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6UTF-8f 4 spaces...
|
35159
|
NULL
|
NULL
|
NULL
|
|
35162
|
1315
|
15
|
2026-05-13T12:15:54.243352+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674554243_m1.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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}]...
|
-8820308511646877981
|
-7196540777719685949
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-;Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•MorelallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 45 m100% <78•Wed 13 May 15:15:54Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35163
|
1316
|
16
|
2026-05-13T12:15:54.213966+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674554213_m2.jpg...
|
PhpStorm
|
faVsco.js – DashboardController.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormFV faVsco.js vINavigareCodeg9 JY-20891-imp PhostormFV faVsco.js vINavigareCodeg9 JY-20891-improve-sms-text-reProledey© MailboxController.php© coachingreedo© ConversationsCTextkelayservice.ong© Sso.phpleDhCalelerleleelnitC Engagementcorc) leaminsicnisAuThemeTopicsCoTopicsinDealsCc› D Themesv D UserAutomatedRep© UserAutomatedfv DV2(C) Activitvv2contreC) AskAnvthinacon(C) DealsV2Controll© OnDemandV2CcC) PlavlistControlle© PlaylistShareCorYe) DlavlistTrackeor© TranscriptionSur© UploadControlle© ActionltemsControl0 ActivitvController.g© AiCrmNotesControlbasecontroller.onp© ClientTokenControlc cimcontroller.ono• DealLevelrromorsec) DealRiskcontroller.c) Instantmeetinaconc) MeetinascontrollerC) MetadataControllenC) MomentController.rc) NumberAllocatorce© OrganizationLicensYC) OraanizationMembilC) OraanizationRetentossocontroller.ongSmsMessage.png© SmsLength.phpclass Dashboardcontroller extends BasecontrollerC) OraanizationPolesC 10d© OrganizationSyncC 101C) PartnerController.n© PhoneNumberConti 102Ca DiavhackController 170.© PlaylistController.pt€ ScimController.php 173ououc tunction ferchreguest Srequest: sonresponse5|X1 A v 632633'engagement-stats' => $this-›getEngagementStats($filterSet),'common-topics' => $this->getCommonTopics(SfilterSet).private function getActivity0verTime(User $user, FilterDefinitionCollection $filterSet): arraySavailableActivityChannels = Collection: :make([Models\Activity: : TYPE_CONFERENCE,Nodels acuivity..lYre_surirhune,Models\Activity::TYPE_SOFTPHONE_INBOUND,Models\Activity::TYPE_SMS_OUTBOUND,1):SactivityChannels = $availableActivityChannels->flip()->map static tunction O: 1nt %return 0:}):Sdata = Sthis->repository->qetDashboardActiviltv0verTime(Suser. $filterSet)->map(static function (array $data) use (SactivityChannels): array €return Sactivitvchannels->map(static function (int $defaultValue, string $activityChannel) use ($data): int {return sdatalSactivitvchanne. SdefaultValue:->valueso.all0.return['Labels' => $activityChannels->keys()-›all(),Inaintel => Sdata-sal10)private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): arrayf...private function getCoachingOverTime(slavc to new hranch oriain/.IV.20801_imnrove-cmc-teyt-relavs /| Create null reauect (22 minutes aao)E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console [EU]A console [STAGING] Tx: AutovORDER BY t.name, calendar domain:So jiminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uvid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * from &ated_report_results where gedie type = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 32412;select * from users where team_id = 2 and email like "%scott%' and id = 29510;672SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt keview • In 40m100% L2Wed 13 May 15:15:54U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php: 33-680 phpoublic function fetch Request Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(Srequest:Scriteria = criteria:: createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validate SfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l→ sultterser renderl),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT TEAM INSIGHTS ACTIVITY = 'team-insichts-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection::make/Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiants Exists::class.RestrictUserGroupScope: : class,RestrictActivityChannel::class.RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6W Windsurf TeamcUTF-8f 4 spaces...
|
NULL
|
1698039176161872467
|
NULL
|
click
|
ocr
|
NULL
|
PhostormFV faVsco.js vINavigareCodeg9 JY-20891-imp PhostormFV faVsco.js vINavigareCodeg9 JY-20891-improve-sms-text-reProledey© MailboxController.php© coachingreedo© ConversationsCTextkelayservice.ong© Sso.phpleDhCalelerleleelnitC Engagementcorc) leaminsicnisAuThemeTopicsCoTopicsinDealsCc› D Themesv D UserAutomatedRep© UserAutomatedfv DV2(C) Activitvv2contreC) AskAnvthinacon(C) DealsV2Controll© OnDemandV2CcC) PlavlistControlle© PlaylistShareCorYe) DlavlistTrackeor© TranscriptionSur© UploadControlle© ActionltemsControl0 ActivitvController.g© AiCrmNotesControlbasecontroller.onp© ClientTokenControlc cimcontroller.ono• DealLevelrromorsec) DealRiskcontroller.c) Instantmeetinaconc) MeetinascontrollerC) MetadataControllenC) MomentController.rc) NumberAllocatorce© OrganizationLicensYC) OraanizationMembilC) OraanizationRetentossocontroller.ongSmsMessage.png© SmsLength.phpclass Dashboardcontroller extends BasecontrollerC) OraanizationPolesC 10d© OrganizationSyncC 101C) PartnerController.n© PhoneNumberConti 102Ca DiavhackController 170.© PlaylistController.pt€ ScimController.php 173ououc tunction ferchreguest Srequest: sonresponse5|X1 A v 632633'engagement-stats' => $this-›getEngagementStats($filterSet),'common-topics' => $this->getCommonTopics(SfilterSet).private function getActivity0verTime(User $user, FilterDefinitionCollection $filterSet): arraySavailableActivityChannels = Collection: :make([Models\Activity: : TYPE_CONFERENCE,Nodels acuivity..lYre_surirhune,Models\Activity::TYPE_SOFTPHONE_INBOUND,Models\Activity::TYPE_SMS_OUTBOUND,1):SactivityChannels = $availableActivityChannels->flip()->map static tunction O: 1nt %return 0:}):Sdata = Sthis->repository->qetDashboardActiviltv0verTime(Suser. $filterSet)->map(static function (array $data) use (SactivityChannels): array €return Sactivitvchannels->map(static function (int $defaultValue, string $activityChannel) use ($data): int {return sdatalSactivitvchanne. SdefaultValue:->valueso.all0.return['Labels' => $activityChannels->keys()-›all(),Inaintel => Sdata-sal10)private function getCoachingBreakdownByUserRole(User $user, Criteria $criteria): arrayf...private function getCoachingOverTime(slavc to new hranch oriain/.IV.20801_imnrove-cmc-teyt-relavs /| Create null reauect (22 minutes aao)E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console [EU]A console [STAGING] Tx: AutovORDER BY t.name, calendar domain:So jiminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uvid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * from &ated_report_results where gedie type = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text nelavs where created at > 12026-05-014# and id IN (32415, 32416);and id = 32412;select * from users where team_id = 2 and email like "%scott%' and id = 29510;672SELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt keview • In 40m100% L2Wed 13 May 15:15:54U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController-php: 33-680 phpoublic function fetch Request Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(Srequest:Scriteria = criteria:: createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validate SfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l→ sultterser renderl),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT TEAM INSIGHTS ACTIVITY = 'team-insichts-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection::make/Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiants Exists::class.RestrictUserGroupScope: : class,RestrictActivityChannel::class.RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6W Windsurf TeamcUTF-8f 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35164
|
1315
|
16
|
2026-05-13T12:16:09.571165+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674569571_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"11","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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-8887292901320558836
|
255948069381766561
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
35162
|
NULL
|
NULL
|
NULL
|
|
35165
|
1316
|
17
|
2026-05-13T12:16:09.587903+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674569587_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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.3636968,"top":0.17478053,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.37300533,"top":0.17478053,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"11","depth":4,"bounds":{"left":0.38297874,"top":0.17478053,"width":0.008976064,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"}]...
|
-8887292901320558836
|
255948069381766561
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
...
|
35163
|
NULL
|
NULL
|
NULL
|
|
35166
|
1315
|
17
|
2026-05-13T12:16:11.571909+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674571571_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-:Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More> 0lallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 44 m100% <78•Wed 13 May 15:16:11Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
-7898430271248641231
|
NULL
|
click
|
ocr
|
NULL
|
Firefox FileEditViewHistoryBookmarksToolsWindowHel Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-:Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More> 0lallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 44 m100% <78•Wed 13 May 15:16:11Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35167
|
1316
|
18
|
2026-05-13T12:16:11.575370+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674571575_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
PhostormFV faVsco.jsINavigarecodeg9 JY-20891-impro PhostormFV faVsco.jsINavigarecodeg9 JY-20891-improve-sms-text-rProledey(C) ActivitvCommentRenositcl©ActivityLogRepository.ph|© ActivityMessageRepositol©ActivityMomentRepositor© ActivityProviderRepositor© ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.f© ActivityUploadSettingRepC AIPromptkepository.ong© AskAnythingRepository.plC) DeviceRerositorv.ohoC) EasticActivitvReoositorv.(c) EmailMessadeRenositorv.© GroupRepository.php© InboxEmailBatchRepositoCInboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.phpNotificationRepository.ph© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p(C) RolechangeEventReposit© RoleRepository.php(c) SearchRenositorv.ono© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon© TeamDomainsRepository.(c) TeaminciahtcRenositorv.r641©TeamRepository.php(C) ThemeRenositorv nhn© MailboxController.phplaravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console [EU]• sso.onpossocontroller.ongA console [STAGING]Tx: AutovORDER BY t.name, calendar domain:So jiminny©smsmessage.ong© SmsLength.php040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;class Teamins1qhtsrepos1torypublic function getbashboardActivityovertimelCnew FilterdA1 46 X11 A v 632633clone shooLouerv)->addFilter(Cnew BoolQuervobl->addShould((new Term())->setTerm( key:"type.keyword',->addShould((new Term®))->setTerm( key: 'type.keyword',->addShould((new Term())->setTerm( key: 'type.keyword'.Activity::TYPE_C,639Activity:: TYPE_S,640Activity::TYPE_S,641->addFilter(new Exists( field: 'actual_start_time')->addAggregation((new DateHistogram( name: 'over_time',field: 'actual_end_time', $histogramInterval))->secrormat format ouuuu-Mm-dd")->setTimezone($timezone0ffset)->setMinimumDocumentCount( count: 0)->addAggregation((new AggregationTerms( name:) 'by_channel'))->setField( field: 'type. keyword")->setSize( size:) self::AGG_TERMS_MAX_SIZE)649=652->addAagregationd(new Filter('text activities'(clone $boolQuery)->addFilterdinew Termo)->setTermd kev: "*vne kevword'. value: Activity:. PE SMS OUTROUND)I—663664-665666->addAggregation((new DateHistogram( name: 'over_time',field: 'created_at', $histogramInterval))'8uuuu-MM-dd')->setTimezone($timezone0ffset)-ScotMinimumlocumon+Count/count•101->addAggregation((new AggregationTerms( name: 'by _channel'))->setField( field:) 'type.keyword')_Scotcizol cize• colf..A6G TEPMS MAy ST7:669— 670select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * fromand id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);ated_report_results where gedie type = 'pdf' and status = 2SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text pelavs where created at 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like "%scott%' and id = 29510;672vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436lavs Il Create null reauect (22 minutes aao)sonnt Keview • In 44m100% L2Wed 13 May 15:16:11U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController.php: 33-680 phpoublic function fetchRequest Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(Srequest:Scriteria = criteria:: createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validateSfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l= $filterSet->render(),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT_TEAM_INSIGHTS_ACTIVITY = 'tean-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection::make/Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiants Exists::class.waatwwacteehneRestrictUserGroupScope: : class,RestrictActivitvchannel::class,RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6WN Windsurf Toams 586-21 UTF.8f 4 spaces...
|
NULL
|
4013535874907454944
|
NULL
|
click
|
ocr
|
NULL
|
PhostormFV faVsco.jsINavigarecodeg9 JY-20891-impro PhostormFV faVsco.jsINavigarecodeg9 JY-20891-improve-sms-text-rProledey(C) ActivitvCommentRenositcl©ActivityLogRepository.ph|© ActivityMessageRepositol©ActivityMomentRepositor© ActivityProviderRepositor© ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.f© ActivityUploadSettingRepC AIPromptkepository.ong© AskAnythingRepository.plC) DeviceRerositorv.ohoC) EasticActivitvReoositorv.(c) EmailMessadeRenositorv.© GroupRepository.php© InboxEmailBatchRepositoCInboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.phpNotificationRepository.ph© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p(C) RolechangeEventReposit© RoleRepository.php(c) SearchRenositorv.ono© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon© TeamDomainsRepository.(c) TeaminciahtcRenositorv.r641©TeamRepository.php(C) ThemeRenositorv nhn© MailboxController.phplaravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console [EU]• sso.onpossocontroller.ongA console [STAGING]Tx: AutovORDER BY t.name, calendar domain:So jiminny©smsmessage.ong© SmsLength.php040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;class Teamins1qhtsrepos1torypublic function getbashboardActivityovertimelCnew FilterdA1 46 X11 A v 632633clone shooLouerv)->addFilter(Cnew BoolQuervobl->addShould((new Term())->setTerm( key:"type.keyword',->addShould((new Term®))->setTerm( key: 'type.keyword',->addShould((new Term())->setTerm( key: 'type.keyword'.Activity::TYPE_C,639Activity:: TYPE_S,640Activity::TYPE_S,641->addFilter(new Exists( field: 'actual_start_time')->addAggregation((new DateHistogram( name: 'over_time',field: 'actual_end_time', $histogramInterval))->secrormat format ouuuu-Mm-dd")->setTimezone($timezone0ffset)->setMinimumDocumentCount( count: 0)->addAggregation((new AggregationTerms( name:) 'by_channel'))->setField( field: 'type. keyword")->setSize( size:) self::AGG_TERMS_MAX_SIZE)649=652->addAagregationd(new Filter('text activities'(clone $boolQuery)->addFilterdinew Termo)->setTermd kev: "*vne kevword'. value: Activity:. PE SMS OUTROUND)I—663664-665666->addAggregation((new DateHistogram( name: 'over_time',field: 'created_at', $histogramInterval))'8uuuu-MM-dd')->setTimezone($timezone0ffset)-ScotMinimumlocumon+Count/count•101->addAggregation((new AggregationTerms( name: 'by _channel'))->setField( field:) 'type.keyword')_Scotcizol cize• colf..A6G TEPMS MAy ST7:669— 670select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uuid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate limits:select * fromand id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);ated_report_results where gedie type = 'pdf' and status = 2SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text pelavs where created at 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like "%scott%' and id = 29510;672vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436lavs Il Create null reauect (22 minutes aao)sonnt Keview • In 44m100% L2Wed 13 May 15:16:11U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Complete Dashboard Activity Flow1. API Request Entry PointFile: DashboardController.php: 33-680 phpoublic function fetchRequest Sreauest): sonResoonseSuser = Sthis→>getUserFromRequest(Srequest:Scriteria = criteria:: createrromRequest(Srequest→>all, Suser->gettimezone)=Scriteria->setContext(ContextAwareFilterDefinitionInterface::CONTEXT_TEAM_INSIGHTS_ACTIVITY),suserSrequest->validateSfilterSet->getValidationRules→>al100:return Sthis->response->withArray(l= $filterSet->render(),'widgets' ='act ivitv-over-time' = sthis->aetActivitvOverTime(suser. sfilterSet).Context set: CONTEXT_TEAM_INSIGHTS_ACTIVITY = 'tean-insights-activity'2. Filter Set CreationFile: ActivitySearch.php:132-244private function getTeamInsightsPageFilters(bool SisExport = false): FilterDefinitionCollectionreturn FilterDefinitionCollection::make/Collection: :make(FilterDefinition\TeamInsights\DateRangeFilter::class,Filterderinition Teaminsiants Exists::class.waatwwacteehneRestrictUserGroupScope: : class,RestrictActivitvchannel::class,RectrictPublicActivitiecOnlv:.class.Ask anvthina (84L)« Code SWF-1.6WN Windsurf Toams 586-21 UTF.8f 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35168
|
1315
|
18
|
2026-05-13T12:16:13.670047+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674573670_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Show Replace Field
Search History
CONTEXT_TEAM_INSIGHTS_ACTIVITY
New Line
Match Case
Words
Regex
Replace History
Replace
New Line
Preserve case
0 results
Previous Occurrence
Next Occurrence
Filter Search Results
Open in Window, Multiple Cursors
Click to highlight
Close
Sync Changes
Hide This Notification
Code changed:
Hide
1
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"Show Replace Field","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Search History","depth":3,"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"CONTEXT_TEAM_INSIGHTS_ACTIVITY","depth":4,"on_screen":true,"value":"CONTEXT_TEAM_INSIGHTS_ACTIVITY","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"New Line","depth":3,"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Match Case","depth":3,"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Words","depth":3,"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Regex","depth":3,"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Replace History","depth":3,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.024444444},"on_screen":false,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextField","text":"Replace","depth":4,"on_screen":false,"role_description":"text field","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"New Line","depth":3,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.024444444},"on_screen":false,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Preserve case","depth":3,"bounds":{"left":0.0,"top":0.0,"width":0.015277778,"height":0.024444444},"on_screen":false,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"0 results","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Occurrence","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Occurrence","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Filter Search Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open in Window, Multiple Cursors","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXLink","text":"Click to highlight","depth":4,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close","depth":4,"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":"AXStaticText","text":"6","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"11","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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
7956840701792918477
|
-8967423967473009248
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Show Replace Field
Search History
CONTEXT_TEAM_INSIGHTS_ACTIVITY
New Line
Match Case
Words
Regex
Replace History
Replace
New Line
Preserve case
0 results
Previous Occurrence
Next Occurrence
Filter Search Results
Open in Window, Multiple Cursors
Click to highlight
Close
Sync Changes
Hide This Notification
Code changed:
Hide
1
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
...
|
35166
|
NULL
|
NULL
|
NULL
|
|
35169
|
1316
|
19
|
2026-05-13T12:16:17.342973+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674577342_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Show Replace Field
Search History
CONTEXT_TEAM_INSIGHTS_ACTIVITY
New Line
Match Case
Words
Regex
Replace History
Replace
New Line
Preserve case
0 results
Previous Occurrence
Next Occurrence
Filter Search Results
Open in Window, Multiple Cursors
Click to highlight
Close
Sync Changes
Hide This Notification
Code changed:
Hide
1
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"Show Replace Field","depth":4,"bounds":{"left":0.10472074,"top":0.17956904,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Search History","depth":3,"bounds":{"left":0.11735372,"top":0.17877094,"width":0.00731383,"height":0.017557861},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"CONTEXT_TEAM_INSIGHTS_ACTIVITY","depth":4,"bounds":{"left":0.12832446,"top":0.17877094,"width":0.078457445,"height":0.015961692},"on_screen":true,"value":"CONTEXT_TEAM_INSIGHTS_ACTIVITY","role_description":"text entry area","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"New Line","depth":3,"bounds":{"left":0.21575798,"top":0.17877094,"width":0.00731383,"height":0.017557861},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Match Case","depth":3,"bounds":{"left":0.22573139,"top":0.17877094,"width":0.00731383,"height":0.017557861},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Words","depth":3,"bounds":{"left":0.234375,"top":0.17877094,"width":0.00731383,"height":0.017557861},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Regex","depth":3,"bounds":{"left":0.24301861,"top":0.17877094,"width":0.00731383,"height":0.017557861},"on_screen":true,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Replace History","depth":3,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextField","text":"Replace","depth":4,"on_screen":false,"role_description":"text field","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"New Line","depth":3,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXCheckBox","text":"Preserve case","depth":3,"bounds":{"left":0.27027926,"top":1.0,"width":0.00731383,"height":0.0},"on_screen":false,"role_description":"checkbox","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"0 results","depth":4,"bounds":{"left":0.25664893,"top":0.17797287,"width":0.025598405,"height":0.017557861},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Occurrence","depth":4,"bounds":{"left":0.28224733,"top":0.17717478,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Next Occurrence","depth":4,"bounds":{"left":0.29089096,"top":0.17717478,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Filter Search Results","depth":4,"bounds":{"left":0.2995346,"top":0.17717478,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open in Window, Multiple Cursors","depth":4,"bounds":{"left":0.3081782,"top":0.17717478,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXLink","text":"Click to highlight","depth":4,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Close","depth":4,"bounds":{"left":0.3949468,"top":0.17717478,"width":0.008643617,"height":0.01915403},"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.3636968,"top":0.20830008,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"6","depth":4,"bounds":{"left":0.37300533,"top":0.20830008,"width":0.007978723,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"11","depth":4,"bounds":{"left":0.38297874,"top":0.20830008,"width":0.008976064,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.20670392,"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.40093085,"top":0.20670392,"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\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Repositories;\n\nuse Carbon\\Carbon;\nuse Carbon\\CarbonImmutable;\nuse Elastica\\Aggregation\\AbstractAggregation;\nuse Elastica\\Aggregation\\AvgBucket;\nuse Elastica\\Aggregation\\Composite;\nuse Elastica\\Aggregation\\DateHistogram;\nuse Elastica\\Aggregation\\DateRange;\nuse Elastica\\Aggregation\\Filter;\nuse Elastica\\Aggregation\\Nested;\nuse Elastica\\Aggregation\\Sum;\nuse Elastica\\Aggregation\\Terms as AggregationTerms;\nuse Elastica\\Aggregation\\ValueCount;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Elastica\\Query\\BoolQuery;\nuse Elastica\\Query\\Exists;\nuse Elastica\\Query\\Range;\nuse Elastica\\Query\\Term;\nuse Elastica\\Query\\Terms;\nuse Elastica\\Result;\nuse Elastica\\ResultSet;\nuse Generator;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionCollection;\nuse Jiminny\\Component\\ActivitySearch\\FilterDefinitionQuery;\nuse Jiminny\\Component\\ElasticSearch\\Service\\Search;\nuse Jiminny\\Component\\Math\\BitwiseOperations;\nuse Jiminny\\Exceptions\\OutOfBoundsException;\nuse Jiminny\\Models\\Activity;\nuse Jiminny\\Models\\Activity\\Comment;\nuse Jiminny\\Models\\CoachingFeedback;\nuse Jiminny\\Models\\User;\n\nclass TeamInsightsRepository\n{\n use BitwiseOperations;\n\n public const array CONVERSATION_DRILLDOWNS = [\n self::CONVERSATION_DRILLDOWN_SCHEDULED,\n self::CONVERSATION_DRILLDOWN_ATTEMPTED,\n self::CONVERSATION_DRILLDOWN_CONNECTED,\n self::CONVERSATION_DRILLDOWN_LOGGED,\n ];\n\n public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';\n public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';\n public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';\n public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';\n public const array DRILL_DOWN_MAP = [\n 'id_string' => 'id',\n 'title' => 'title',\n 'user.id_string' => null, // needed for indirect mapping\n 'user.name' => 'organizer.name',\n 'user.job.name' => 'organizer.job.name',\n 'user.photo_url' => 'organizer.photoUrl',\n 'type' => 'type',\n\n 'lead.name' => 'prospect.lead.name',\n 'lead.company' => 'prospect.lead.company',\n\n 'contact.name' => 'prospect.contact.name',\n 'contact.account.name' => 'prospect.contact.account.name',\n\n 'account.name' => 'prospect.account.account.name',\n\n 'participants.user.id_string' => null, // this would return an array and needs manual mapping\n 'participants.country_code' => null, // this would return an array and needs manual mapping\n 'participants.phone_number' => null, // this would return an array and needs manual mapping\n\n 'favorite_count' => 'stats.favorites',\n 'share_count' => 'stats.shares',\n 'comment_count' => 'stats.comments',\n 'play_count' => 'stats.plays',\n\n 'stats.talk_time_ratio' => 'stats.talkTimeRatio',\n 'stats.talking_speed' => 'stats.talkingSpeed',\n 'stats.user_questions' => 'stats.userQuestionsCount',\n 'stats.longest_user_monologue' => 'stats.longestUserMonologue',\n 'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',\n 'stats.patience_time' => 'stats.patienceTime',\n\n 'plays.user.id_string' => null, // this would return an array and needs manual mapping\n 'average_score' => 'averageScore',\n 'ai_call_score.score' => 'aiCallScore',\n 'category.name' => 'category.name',\n 'opportunity.value' => 'opportunity.value',\n 'opportunity.currency_code' => 'opportunity.currency_code',\n 'opportunity.stage.label' => 'opportunity.stage.label',\n 'duration' => 'duration',\n 'actual_end_time' => 'actualEndTime',\n 'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping\n 'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping\n ];\n\n public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;\n public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;\n\n private const int AGG_TERMS_MAX_SIZE = 9999;\n private const int AGG_COMPOSITE_MAX_SIZE = 10000;\n\n private const int AGGREGATE_VALUE_AVG = 0;\n private const int AGGREGATE_VALUE_MAX = 1;\n private const int AGGREGATE_VALUE_SUM = 2;\n\n public function __construct(\n private readonly Search $searchService,\n private readonly Activity $model,\n ) {\n }\n\n /**\n * Ensure prospect.name is present and non-empty by applying a type-based fallback\n * from the original dot-notated data structure.\n *\n * - type lead => prospect.lead.name\n * - type contact => prospect.contact.name\n * - type account => prospect.account.account.name or prospect.account.name\n */\n private static function ensureProspectNameFallback(array $data, array $originalDotData): array\n {\n if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])\n || ! array_key_exists('type', $data['prospect'])\n ) {\n return $data;\n }\n\n $existingName = $data['prospect']['name'] ?? null;\n $needsFallback = ! is_string($existingName) || trim($existingName) === '';\n\n if (! $needsFallback) {\n return $data;\n }\n\n $prospectName = null;\n switch ($data['prospect']['type']) {\n case 'lead':\n $prospectName = $originalDotData['prospect.lead.name'] ?? null;\n\n break;\n case 'contact':\n $prospectName = $originalDotData['prospect.contact.name'] ?? null;\n\n break;\n case 'account':\n // Some indices nest account name under account.account.name\n $prospectName = $originalDotData['prospect.account.account.name']\n ?? $originalDotData['prospect.account.name']\n ?? null;\n\n break;\n }\n\n // Normalize whitespace-only fallback names to null (mirror $existingName check)\n if (is_string($prospectName)) {\n $prospectName = trim($prospectName);\n if ($prospectName === '') {\n $prospectName = null;\n }\n }\n\n // set the name key no matter if empty\n $data['prospect']['name'] = $prospectName;\n\n return $data;\n }\n\n public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query($boolQuery))\n ->setSize(1000)\n ->setSource([\n 'includes' => $include,\n ])\n ->setSort([\n 'scheduled_start_time' => 'asc',\n ]);\n\n return LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getResults();\n })\n ->map(static function (Result $result): array {\n $hit = $result->getHit();\n\n return $hit['_source'];\n });\n }\n\n private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection\n {\n if ($page <= 0) {\n throw new OutOfBoundsException('The page number can only be greater or equal to one');\n }\n\n $map = Collection::make(self::DRILL_DOWN_MAP);\n\n $query = (new Query($boolQuery))\n ->setSort(['scheduled_start_time'])\n ->setSource($map->keys()->all());\n\n if ($limit === 0) {\n $query->setSize(1000);\n $documents = LazyCollection::make(function () use ($query): Generator {\n $scroll = $this->searchService->scroll($query, $this->model);\n\n foreach ($scroll as $resultSet) {\n yield $resultSet;\n }\n })\n ->flatMap(static function (ResultSet $resultSet): array {\n return $resultSet->getDocuments();\n });\n } else {\n $query\n ->setSize($limit)\n ->setFrom(($page - 1) * $limit);\n\n $documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();\n }\n\n return Collection::make($documents)\n ->map(static function (Document $document) use ($map): array {\n $documentDataRaw = $document->getData();\n $documentData = array_dot($documentDataRaw);\n\n $data = [];\n foreach ($map as $fromKey => $toKey) {\n if ($toKey === null) {\n continue;\n }\n\n array_set($data, $toKey, $documentData[$fromKey] ?? null);\n }\n $roomOwnerId = $documentData['user.id_string'];\n\n $data['played'] = Collection::make($documentDataRaw['plays'] ?? [])\n ->map(static function (array $data): string {\n return $data['user']['id_string'];\n })\n ->all();\n\n $data['from'] = [\n 'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])\n ->filter(static function (array $data) use ($roomOwnerId): bool {\n return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;\n })\n ->map(static function (array $data): ?string {\n return $data['phone_number'];\n })\n ->first(),\n ];\n\n $data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])\n ->filter(static function (array $track): bool {\n return $track['telephony_provider_id'] !== null;\n })\n ->isNotEmpty();\n\n $data['coaches'] = Collection::make(\n is_array($documentDataRaw)\n && array_key_exists('coachingFeedbacks', $documentDataRaw)\n && is_array($documentDataRaw['coachingFeedbacks'])\n ? $documentDataRaw['coachingFeedbacks']\n : [],\n );\n\n return $data;\n })\n ->map(static function (array $data) use ($consumer): array {\n $dotData = array_dot($data);\n // Keep a copy of the original dot data so we can derive names after reshaping\n $originalDotData = $dotData;\n\n // map prospect to lead/contact/account\n if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.lead');\n $data['prospect']['type'] = 'lead';\n } elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {\n $data['prospect'] = array_get($data, 'prospect.contact');\n $data['prospect']['type'] = 'contact';\n } elseif (\n array_key_exists('prospect.account.account.name', $dotData)\n && $dotData['prospect.account.account.name'] !== null\n ) {\n $data['prospect'] = array_get($data, 'prospect.account');\n $data['prospect']['type'] = 'account';\n } else {\n unset($data['prospect']);\n }\n\n // Ensure prospect.name is present; if missing or empty, fill using type-based fallback\n $data = self::ensureProspectNameFallback($data, $originalDotData);\n\n $dotData = array_dot($data);\n $nationalPhoneNumber = $dotData['from.national_phone_number'];\n unset($data['from']);\n\n $data['title'] = getActivityTitleAttribute(\n $dotData['organizer.name'],\n $dotData['type'],\n $dotData['title'],\n $dotData['prospect.name'] ?? null,\n $nationalPhoneNumber\n );\n\n if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {\n unset($data['category']['name']);\n }\n\n if (array_key_exists('category', $data) && empty($data['category'])) {\n unset($data['category']);\n }\n\n // Include opportunity if either a value OR a stage label exists.\n $hasOpportunityValue = array_key_exists('opportunity.value', $dotData)\n && $dotData['opportunity.value'] !== null;\n $hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)\n && $dotData['opportunity.stage.label'] !== null;\n\n if ($hasOpportunityValue || $hasOpportunityStage) {\n $data['opportunity'] = [];\n\n if ($hasOpportunityValue) {\n $data['opportunity']['formattedValue'] = formatOpportunityValue(\n (float) $dotData['opportunity.value'],\n $dotData['opportunity.currency_code'],\n );\n }\n\n if ($hasOpportunityStage) {\n $data['opportunity']['stage'] = [\n 'label' => $dotData['opportunity.stage.label'],\n ];\n }\n } else {\n unset($data['opportunity']);\n }\n\n if (array_key_exists('played', $data) && is_array($data['played'])) {\n $data['played'] = in_array($consumer->id_string, $data['played'], true);\n }\n\n if (array_key_exists('duration', $data) && $data['duration'] !== null) {\n $data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);\n }\n unset($data['duration']);\n\n return $data;\n })\n // Convert database times to ISO 8601 or frontend will apply timezone conversions\n ->map(static function (array $data): array {\n if (isset($data['actualEndTime'])) {\n $data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();\n }\n\n return $data;\n });\n }\n\n public function getConversationsPerActivityChannelDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $activityChannel,\n string $drillDownType,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet\n ->getBoolQuery($filterSet->extractElasticSearchQueries())\n ->addMust((new Term())->setTerm('type.keyword', $activityChannel));\n\n switch ($drillDownType) {\n case self::CONVERSATION_DRILLDOWN_SCHEDULED:\n case self::CONVERSATION_DRILLDOWN_ATTEMPTED:\n $boolQuery->addMust(new Exists('scheduled_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_CONNECTED:\n $boolQuery->addMust(new Exists('actual_start_time'));\n\n break;\n case self::CONVERSATION_DRILLDOWN_LOGGED:\n $boolQuery->addMust(new Exists('crm_provider_id'));\n\n break;\n default:\n throw new OutOfBoundsException('Unsupported drill down type');\n }\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n int $flags,\n int $page,\n int $limit = 25,\n ): Collection {\n $extraFilterDefinitionQueries = [];\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))\n ->setPath('comments', 'comments');\n }\n\n if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {\n $extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))\n ->setPath('comments', 'comments');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getCoachingActivitiesOverTimeDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n User $coachee,\n ?string $sectionId,\n int $page,\n int $limit = 25\n ): Collection {\n $extraFilterSetQueries = [\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))\n ->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),\n ];\n\n if (is_string($sectionId)) {\n $extraFilterSetQueries[] = FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))\n ->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');\n }\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries($extraFilterSetQueries)\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getEngagementActivitiesDrillDown(\n User $consumer,\n FilterDefinitionCollection $filterSet,\n string $elasticsearchColumn,\n int $page,\n int $limit = 25,\n ): Collection {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Exists('stats.' . $elasticsearchColumn))\n ->setPath('stats', 'stats'),\n ])\n );\n\n return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);\n }\n\n public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Sum('total_duration'))->setField('duration')\n )\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n ->addAggregation(\n (new Filter('volume_connected', new Exists('actual_start_time')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n ->addAggregation(\n (new Filter('logged_to_crm', new Exists('crm_provider_id')))\n ->addAggregation(\n new ValueCount('volume', 'id_string.keyword')\n )\n )\n )\n ->addAggregation(\n new AvgBucket('avg_duration', 'by_user>total_duration')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_all', 'by_user>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')\n )\n ->addAggregation(\n new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')\n )\n )\n );\n\n $results = $this->searchService\n ->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')\n ->getAggregations();\n\n $connectableActivityChannels = [\n Activity::TYPE_SOFTPHONE,\n Activity::TYPE_SOFTPHONE_INBOUND,\n Activity::TYPE_CONFERENCE,\n ];\n\n return Collection::make(array_get($results, 'activities.channel.buckets', []))\n ->map(static function (array $bucket) use ($connectableActivityChannels): array {\n $channel = $bucket['key'];\n\n $avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);\n $avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);\n $avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);\n $avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);\n\n return [\n 'channel' => $channel,\n 'stats' => [\n 'avg_volume' => $avgVolume,\n 'avg_volume_logged' => $avgVolumeLogged,\n 'avg_volume_connected' => $avgVolumeConnected,\n 'avg_duration' => $avgDuration,\n ],\n 'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))\n ->keyBy('key')\n ->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {\n $data = [\n 'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),\n 'volume' => (int) $userBucket['doc_count'],\n 'duration' => (float) array_get($userBucket, 'total_duration.value', 0),\n ];\n\n if (in_array($channel, $connectableActivityChannels, true)) {\n $data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');\n }\n\n return $data;\n })\n ->all(),\n ];\n });\n }\n\n public function getDashboardActivityOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n string $histogramInterval = 'day'\n ): Collection {\n $timezoneOffset = $user->getTimezoneOffset();\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter(\n 'voice_activities',\n (clone $boolQuery)\n ->addFilter(\n (new BoolQuery())\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))\n ->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))\n )\n ->addFilter(\n new Exists('actual_start_time')\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'actual_end_time', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n ->addAggregation(\n (new Filter(\n 'text_activities',\n (clone $boolQuery)\n ->addFilter(\n (new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)\n )\n ))\n ->addAggregation(\n (new DateHistogram('over_time', 'created_at', $histogramInterval))\n ->setFormat('8uuuu-MM-dd')\n ->setTimezone($timezoneOffset)\n ->setMinimumDocumentCount(0)\n ->addAggregation(\n (new AggregationTerms('by_channel'))\n ->setField('type.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();\n\n $activityData = Collection::make([\n array_get($aggregationData, 'voice_activities.over_time.buckets'),\n array_get($aggregationData, 'text_activities.over_time.buckets'),\n ])\n ->collapse()\n ->reduce(\n static function (array $carry, array $bucketData): array {\n $byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))\n ->keyBy('key')\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n\n $date = $bucketData['key_as_string'];\n\n if (array_key_exists($date, $carry)) {\n $byChannel = $byChannel->merge($carry[$date]);\n }\n\n $carry[$date] = $byChannel->all();\n\n return $carry;\n },\n []\n );\n\n return Collection::make($activityData);\n }\n\n public function getDashboardCoachingOverTime(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('plays.created_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))\n ->keyBy($resultSetKey)\n ->map(static function (array $bucketData): int {\n return $bucketData['doc_count'];\n });\n }\n\n public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('played_by', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('plays.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('plays.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))\n ->map(static function (array $playbackBucket): array {\n $userId = $playbackBucket['key'];\n $count = $playbackBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(\n FilterDefinitionCollection $filterSet\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $query = (new Query($boolQuery))\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new Nested('commented_by', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n (new AggregationTerms('role'))\n ->setField('comments.user.roles.name')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n )\n )\n )\n );\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')\n ->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'by_user.buckets'))\n ->keyBy('key')\n ->map(static function (array $roomOwnerBucket): array {\n return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))\n ->map(static function (array $commentBucket): array {\n $userId = $commentBucket['key'];\n $count = $commentBucket['doc_count'];\n\n $userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))\n ->keyBy('key')\n ->keys();\n\n return [\n 'count' => $count,\n 'userId' => $userId,\n 'userRoles' => $userRoles->all(),\n ];\n })\n ->all();\n });\n }\n\n private function getCompositeAggregationBy(\n BoolQuery $boolQuery,\n AbstractAggregation $sourceAggregation,\n ?array $customAggregations = null,\n ?AbstractAggregation $aggregationParent = null,\n ?callable $compositeAggregationExtractor = null,\n ?AbstractAggregation $immediateAggregationParent = null\n ): LazyCollection {\n if ($compositeAggregationExtractor === null) {\n $compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('composite')['buckets'];\n }\n\n return LazyCollection::make(\n function () use (\n $sourceAggregation,\n $customAggregations,\n $aggregationParent,\n $immediateAggregationParent,\n $boolQuery,\n $compositeAggregationExtractor,\n ): Generator {\n $compositeAggregation = (new Composite('composite'))\n ->setSize(self::AGG_COMPOSITE_MAX_SIZE)\n ->addSource($sourceAggregation);\n\n if (is_array($customAggregations)) {\n foreach ($customAggregations as $customAggregation) {\n $compositeAggregation->addAggregation($customAggregation);\n }\n }\n\n $aggregation = $compositeAggregation;\n\n if ($aggregationParent instanceof AbstractAggregation) {\n $aggregation = $aggregationParent;\n\n if ($immediateAggregationParent instanceof AbstractAggregation) {\n $immediateAggregationParent->addAggregation($compositeAggregation);\n } else {\n $aggregationParent->addAggregation($compositeAggregation);\n }\n }\n\n while (true) {\n $query = (new Query($boolQuery))\n ->setSource(false)\n ->addAggregation($aggregation);\n\n $aggregationData = $this->searchService\n ->search($query, $this->model, 'getCompositeAggregationBy');\n\n foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {\n yield $bucket;\n }\n\n $cursor = array_get($aggregationData, 'composite.after_key', null);\n\n if (! is_array($cursor)) {\n break;\n }\n\n $compositeAggregation->addAfter($cursor);\n }\n },\n );\n }\n\n private function getCompositeAggregationByUser(\n BoolQuery $boolQuery,\n ?array $customAggregations = null,\n ?callable $callback = null,\n ): LazyCollection {\n if ($callback === null) {\n $callback = static fn (array $bucket): int => $bucket['doc_count'];\n }\n\n $sourceAggregation = (new AggregationTerms('by_user'))\n ->setField('user.id_string.keyword');\n\n return $this\n ->getCompositeAggregationBy(\n boolQuery: $boolQuery,\n sourceAggregation: $sourceAggregation,\n customAggregations: $customAggregations,\n )\n ->mapWithKeys(static fn (array $bucket): array => [\n $bucket['key']['by_user'] => $bucket,\n ])\n ->map($callback);\n }\n\n private function getCompositeAggregationByCoachingFeedbackCoach(\n BoolQuery $boolQuery,\n ?array $customAggregations = null\n ): LazyCollection {\n return $this\n ->getCompositeAggregationBy(\n $boolQuery,\n (new AggregationTerms('by_feedback_id'))\n ->setField('coachingFeedbacks.id_string'),\n $customAggregations,\n new Nested('coachingFeedbacks', 'coachingFeedbacks'),\n static fn (ResultSet $aggregationData): array => $aggregationData\n ->getAggregation('coachingFeedbacks')['composite']['buckets']\n );\n }\n\n /**\n * @param Collection|string[] $statsOfInterest\n *\n * @return Collection|AbstractAggregation[]\n */\n private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection\n {\n $getAggregation = static function (string $propertyName): Filter {\n $totalAmountProperties = [\n 'talk_time_ratio',\n 'longest_user_monologue',\n 'longest_customer_monologue',\n 'talking_speed',\n 'user_questions',\n ];\n\n $propertyPath = 'stats.' . $propertyName;\n\n $filterQuery = (new BoolQuery())\n ->addMust(new Exists($propertyPath));\n\n if (in_array($propertyName, $totalAmountProperties, true)) {\n $filterQuery->addMust(\n new Range(\n $propertyPath,\n [\n 'gt' => 0,\n ]\n )\n );\n }\n\n return (new Filter($propertyName, $filterQuery))\n ->addAggregation(\n (new Sum('data'))->setField($propertyPath)\n );\n };\n\n return Collection::make()\n ->push(\n $statsOfInterest\n ->reduce(\n static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {\n return $carry->addAggregation($getAggregation($propertyName));\n },\n new Nested('stats', 'stats')\n )\n );\n }\n\n public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection\n {\n $statsOfInterest = Collection::make([\n 'talkTimeRatio' => 'talk_time_ratio',\n 'longestMonologue' => 'longest_user_monologue',\n 'longestCustomerStory' => 'longest_customer_monologue',\n 'talkingSpeed' => 'talking_speed',\n 'patience' => 'patience_time',\n 'questionRate' => 'user_questions',\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n )\n ->collect();\n\n return $statsOfInterest\n ->map(static function (string $propertyName) use ($aggregationData): ?float {\n [$count, $value] = $aggregationData->reduce(\n static function (array $accumulator, array $bucket) use ($propertyName): array {\n $accumulator[0] += (int) $bucket[$propertyName]['count'];\n $accumulator[1] += (float) $bucket[$propertyName]['value'];\n\n return $accumulator;\n },\n [0, 0]\n );\n\n if ($count === 0) {\n return null;\n }\n\n return (float) ($value / $count);\n });\n }\n\n public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coach.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('feedbacks', 'coachingFeedbacks'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('coachingFeedbacks.coachee.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->addAggregation(\n new ValueCount('volume', 'coachingFeedbacks.id_string'),\n )\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingFeedbacksOverTimeAggregation(\n User $user,\n FilterDefinitionCollection $filterSet,\n ?CarbonImmutable $dateTimeRangeStartsAt,\n ?CarbonImmutable $dateTimeRangeEndsAt,\n string $histogramInterval = 'day',\n ): LazyCollection {\n $timezone = $user->getTimezone();\n $timezoneOffset = $user->getTimezoneOffset();\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))\n ->setPath('coachingFeedbacks', 'coachingFeedbacks'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;\n\n if ($hasDateRange) {\n $resultSetKey = 'from_as_string';\n\n $dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();\n $dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();\n\n $dateRangeAggregation = (new DateRange('over_time'))\n ->setField('coachingFeedbacks.updated_at')\n ->setFormat('8uuuu-MM-dd')\n ->setParam('time_zone', $timezoneOffset);\n\n if ($histogramInterval === 'day') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addDay();\n };\n } elseif ($histogramInterval === 'hour') {\n $increment = static function (CarbonImmutable $dateTime): CarbonImmutable {\n return $dateTime->addHour();\n };\n } else {\n throw new OutOfBoundsException('Unknown date time interval');\n }\n\n $periodStartsAt = $dateTimeRangeStartsAt;\n\n while (true) {\n $periodEndsAt = $increment($periodStartsAt);\n\n $dateRangeAggregation->addRange(\n $periodStartsAt->format('Y-m-d'),\n $periodEndsAt->format('Y-m-d')\n );\n\n if ($periodEndsAt >= $dateTimeRangeEndsAt) {\n break;\n }\n\n $periodStartsAt = clone $periodEndsAt;\n }\n } else {\n $resultSetKey = 'key_as_string';\n\n $dateRangeAggregation = (new DateHistogram(\n name: 'over_time',\n field: 'coachingFeedbacks.updated_at',\n interval: $histogramInterval,\n ))\n ->setTimezone($timezoneOffset)\n ->setFormat('8uuuu-MM-dd')\n ->setMinimumDocumentCount(0);\n }\n\n $aggregationResult = $this\n ->getCompositeAggregationByCoachingFeedbackCoach(\n $boolQuery,\n [\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation($dateRangeAggregation),\n ]\n )\n ->filter(static fn (array $bucket): bool => $bucket['filtered']['doc_count'] > 0)\n ->reduce(\n static function (array $carry, array $bucket) use ($resultSetKey): array {\n $feedbackId = $bucket['key']['by_feedback_id'];\n $date = null;\n\n foreach (array_get($bucket, 'filtered.over_time.buckets') as $dateTime) {\n if ($dateTime['doc_count'] > 0) {\n $date = $dateTime[$resultSetKey];\n\n break;\n }\n }\n\n if ($date === null) {\n return $carry;\n }\n\n $carry[$feedbackId] = $date;\n\n return $carry;\n },\n []\n );\n\n $query = (new Query($boolQuery))\n ->setSource([\n 'id_string',\n 'coachingFeedbacks.id_string',\n 'coachingFeedbacks.coach.id_string',\n 'coachingFeedbacks.coachee.id_string',\n 'coachingFeedbacks.framework.id_string',\n 'coachingFeedbacks.framework.name',\n 'coachingFeedbacks.sectionFeedbacks.section.id_string',\n 'coachingFeedbacks.sectionFeedbacks.section.name',\n 'coachingFeedbacks.sectionFeedbacks.score',\n ]);\n\n return $this->searchService->scrollOverDocuments($query, $this->model)\n ->flatMap(static function (Document $document) use ($aggregationResult): array {\n $data = $document->toArray();\n $activityId = $data['_source']['id_string'];\n\n return Collection::make($data['_source']['coachingFeedbacks'])\n ->filter(\n static fn (array $feedback): bool\n => array_key_exists($feedback['id_string'], $aggregationResult),\n )\n ->flatMap(static function (array $feedback) use ($activityId, $aggregationResult): array {\n if (! array_key_exists('sectionFeedbacks', $feedback)) {\n return [];\n }\n\n $feedbackId = $feedback['id_string'];\n $framework = $feedback['framework'];\n $sectionFeedbacks = $feedback['sectionFeedbacks'];\n\n $coachId = $feedback['coach']['id_string'];\n $coacheeId = $feedback['coachee']['id_string'];\n\n return Collection::make($sectionFeedbacks)\n ->map(static fn (array $section): array => [\n 'activityId' => $activityId,\n 'feedbackUUID' => $feedbackId,\n 'activityTypeName' => $framework['name'],\n 'activityTypeId' => $framework['id_string'],\n 'sectionId' => $section['section']['id_string'],\n 'sectionName' => $section['section']['name'],\n 'score' => $section['score'],\n\n 'date' => $aggregationResult[$feedbackId],\n 'coachId' => $coachId,\n 'coacheeId' => $coacheeId,\n ])\n ->toArray();\n })\n ->toArray();\n })\n ->filter(static fn (array $bucket): bool => ! empty($bucket));\n }\n\n public function getCoachingListensPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playback', 'plays'))\n ->addAggregation(\n (new Filter('filtered', $filterDefinitionQueries->getNestedQuery('plays')))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setField('plays.user.id_string.keyword')\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playback.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingSharesPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('shares')\n ->addMustNot(new Exists('shares.parent_share_id'));\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('shares', 'shares'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('shares.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'shares.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsReceivedUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n new Filter('filtered', $filterDefinitionQueries->getNestedQuery('comments'))\n ),\n ],\n static function (array $bucket): int {\n return array_get($bucket, 'comments.filtered.doc_count');\n }\n )\n ->collect()\n ->toArray();\n }\n\n /**\n * @param int[] $commentTypes\n */\n public function getCoachingCommentsFilledUserAggregation(\n FilterDefinitionCollection $filterSet,\n array $commentTypes\n ): array {\n if (empty($commentTypes)) {\n throw new OutOfBoundsException('At least one comment type must be specified');\n }\n\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries([\n FilterDefinitionQuery::instance()\n ->setQuery(new Terms('comments.type', $commentTypes))\n ->setPath('comments', 'comments'),\n ]);\n\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');\n\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n return $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('comments', 'comments'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('comments.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'comments.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n }\n\n public function getCoachingPlaylistContributionsPerUserAggregation(\n FilterDefinitionCollection $filterSet,\n ): Collection {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('playlists');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('playlists', 'playlists'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('playlists.pivot.user.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'playlists.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n public function getCoachingLiveCoachingPerUserAggregation(FilterDefinitionCollection $filterSet): Collection\n {\n $filterDefinitionQueries = $filterSet->extractElasticSearchQueries();\n $currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('participants');\n $boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);\n\n $data = $this\n ->getCompositeAggregationByUser(\n $boolQuery,\n [\n (new Nested('participants', 'participants'))\n ->addAggregation(\n (new Filter('filtered', $currentPriorityQuery))\n ->addAggregation(\n (new AggregationTerms('by_user'))\n ->setField('participants.user.id_string.keyword')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n )\n ),\n ],\n static function (array $bucket): array {\n return array_get($bucket, 'participants.filtered.by_user.buckets', []);\n }\n )\n ->reduce(\n static function (array $carry, array $buckets): array {\n foreach ($buckets as $bucket) {\n $userId = $bucket['key'];\n\n if (! array_key_exists($userId, $carry)) {\n $carry[$userId] = 0;\n }\n\n $carry[$userId] += $bucket['doc_count'];\n }\n\n return $carry;\n },\n []\n );\n\n return Collection::make($data);\n }\n\n private function getEngagementActivityStatsAggregationResults(\n FilterDefinitionCollection $filterSet,\n string $propertyName,\n ): Collection {\n $statsOfInterest = Collection::make([\n $propertyName,\n ]);\n\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $aggregationData = $this->getCompositeAggregationByUser(\n $boolQuery,\n $this->getEngagementStatsAggregation($statsOfInterest)->toArray(),\n static function (array $bucket): array {\n $statsBucket = $bucket['stats'];\n unset($statsBucket['doc_count']);\n\n return Collection::make($statsBucket)\n ->map(static function (array $stat): array {\n return [\n 'count' => $stat['doc_count'],\n 'value' => $stat['data']['value'],\n ];\n })\n ->toArray();\n }\n );\n\n return $aggregationData\n ->map(static function (array $bucket) use ($propertyName): float {\n $value = $bucket[$propertyName]['value'];\n $count = $bucket[$propertyName]['count'];\n\n if ($count === 0) {\n return 0;\n }\n\n return $value / $count;\n })\n ->collect();\n }\n\n public function getEngagementTalkTimeRatioPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talk_time_ratio');\n }\n\n public function getEngagementLongestMonologuePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_user_monologue');\n }\n\n public function getEngagementLongestCustomerStoryPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'longest_customer_monologue');\n }\n\n public function getEngagementTalkingSpeedPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'talking_speed');\n }\n\n public function getEngagementInteractivityPerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'interactions');\n }\n\n public function getEngagementPatiencePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'patience_time');\n }\n\n public function getEngagementQuestionRatePerUser(FilterDefinitionCollection $filterSet): Collection\n {\n return $this->getEngagementActivityStatsAggregationResults($filterSet, 'user_questions');\n }\n\n public function getCommonTopics(FilterDefinitionCollection $filterSet, int $size): Collection\n {\n $boolQuery = $filterSet->getBoolQuery(\n $filterSet->extractElasticSearchQueries()\n );\n\n $query = (new Query())\n ->setSize(0)\n ->setSource(false)\n ->addAggregation(\n (new Filter('activities', $boolQuery))\n ->addAggregation(\n (new Nested('playback_topic', 'topic_triggers.playback_topic_trigger.playback_topic'))\n ->addAggregation(\n (new AggregationTerms('by_topic'))\n ->setField('topic_triggers.playback_topic_trigger.playback_topic.id_string')\n ->setSize(self::AGG_TERMS_MAX_SIZE)\n ->setOrder('_count', 'desc')\n ->setSize($size)\n )\n )\n );\n\n $aggregationData = $this->searchService->search($query, $this->model, 'getCommonTopics')->getAggregations();\n\n return Collection::make(array_get($aggregationData, 'activities.playback_topic.by_topic.buckets', []))\n ->keyBy('key')\n ->map(static function (array $topicBucket): float {\n return $topicBucket['doc_count'];\n });\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
7956840701792918477
|
-8967423967473009248
|
visual_change
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Show Replace Field
Search History
CONTEXT_TEAM_INSIGHTS_ACTIVITY
New Line
Match Case
Words
Regex
Replace History
Replace
New Line
Preserve case
0 results
Previous Occurrence
Next Occurrence
Filter Search Results
Open in Window, Multiple Cursors
Click to highlight
Close
Sync Changes
Hide This Notification
Code changed:
Hide
1
6
11
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Repositories;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Aggregation\AvgBucket;
use Elastica\Aggregation\Composite;
use Elastica\Aggregation\DateHistogram;
use Elastica\Aggregation\DateRange;
use Elastica\Aggregation\Filter;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\Sum;
use Elastica\Aggregation\Terms as AggregationTerms;
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\BoolQuery;
use Elastica\Query\Exists;
use Elastica\Query\Range;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Result;
use Elastica\ResultSet;
use Generator;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionCollection;
use Jiminny\Component\ActivitySearch\FilterDefinitionQuery;
use Jiminny\Component\ElasticSearch\Service\Search;
use Jiminny\Component\Math\BitwiseOperations;
use Jiminny\Exceptions\OutOfBoundsException;
use Jiminny\Models\Activity;
use Jiminny\Models\Activity\Comment;
use Jiminny\Models\CoachingFeedback;
use Jiminny\Models\User;
class TeamInsightsRepository
{
use BitwiseOperations;
public const array CONVERSATION_DRILLDOWNS = [
self::CONVERSATION_DRILLDOWN_SCHEDULED,
self::CONVERSATION_DRILLDOWN_ATTEMPTED,
self::CONVERSATION_DRILLDOWN_CONNECTED,
self::CONVERSATION_DRILLDOWN_LOGGED,
];
public const string CONVERSATION_DRILLDOWN_CONNECTED = 'connected';
public const string CONVERSATION_DRILLDOWN_SCHEDULED = 'scheduled';
public const string CONVERSATION_DRILLDOWN_ATTEMPTED = 'attempted';
public const string CONVERSATION_DRILLDOWN_LOGGED = 'logged';
public const array DRILL_DOWN_MAP = [
'id_string' => 'id',
'title' => 'title',
'user.id_string' => null, // needed for indirect mapping
'user.name' => 'organizer.name',
'user.job.name' => 'organizer.job.name',
'user.photo_url' => 'organizer.photoUrl',
'type' => 'type',
'lead.name' => 'prospect.lead.name',
'lead.company' => 'prospect.lead.company',
'contact.name' => 'prospect.contact.name',
'contact.account.name' => 'prospect.contact.account.name',
'account.name' => 'prospect.account.account.name',
'participants.user.id_string' => null, // this would return an array and needs manual mapping
'participants.country_code' => null, // this would return an array and needs manual mapping
'participants.phone_number' => null, // this would return an array and needs manual mapping
'favorite_count' => 'stats.favorites',
'share_count' => 'stats.shares',
'comment_count' => 'stats.comments',
'play_count' => 'stats.plays',
'stats.talk_time_ratio' => 'stats.talkTimeRatio',
'stats.talking_speed' => 'stats.talkingSpeed',
'stats.user_questions' => 'stats.userQuestionsCount',
'stats.longest_user_monologue' => 'stats.longestUserMonologue',
'stats.longest_customer_monologue' => 'stats.longestCustomerMonologue',
'stats.patience_time' => 'stats.patienceTime',
'plays.user.id_string' => null, // this would return an array and needs manual mapping
'average_score' => 'averageScore',
'ai_call_score.score' => 'aiCallScore',
'category.name' => 'category.name',
'opportunity.value' => 'opportunity.value',
'opportunity.currency_code' => 'opportunity.currency_code',
'opportunity.stage.label' => 'opportunity.stage.label',
'duration' => 'duration',
'actual_end_time' => 'actualEndTime',
'tracks.telephony_provider_id' => null, // this would return an array and needs manual mapping
'coachingFeedbacks.coach.name' => null, // this would return an array and needs manual mapping
];
public const int FLAG_DRILLDOWN_COMMENT_POSITIVE = 1;
public const int FLAG_DRILLDOWN_COMMENT_NEGATIVE = 2;
private const int AGG_TERMS_MAX_SIZE = 9999;
private const int AGG_COMPOSITE_MAX_SIZE = 10000;
private const int AGGREGATE_VALUE_AVG = 0;
private const int AGGREGATE_VALUE_MAX = 1;
private const int AGGREGATE_VALUE_SUM = 2;
public function __construct(
private readonly Search $searchService,
private readonly Activity $model,
) {
}
/**
* Ensure prospect.name is present and non-empty by applying a type-based fallback
* from the original dot-notated data structure.
*
* - type lead => prospect.lead.name
* - type contact => prospect.contact.name
* - type account => prospect.account.account.name or prospect.account.name
*/
private static function ensureProspectNameFallback(array $data, array $originalDotData): array
{
if (! array_key_exists('prospect', $data) || ! is_array($data['prospect'])
|| ! array_key_exists('type', $data['prospect'])
) {
return $data;
}
$existingName = $data['prospect']['name'] ?? null;
$needsFallback = ! is_string($existingName) || trim($existingName) === '';
if (! $needsFallback) {
return $data;
}
$prospectName = null;
switch ($data['prospect']['type']) {
case 'lead':
$prospectName = $originalDotData['prospect.lead.name'] ?? null;
break;
case 'contact':
$prospectName = $originalDotData['prospect.contact.name'] ?? null;
break;
case 'account':
// Some indices nest account name under account.account.name
$prospectName = $originalDotData['prospect.account.account.name']
?? $originalDotData['prospect.account.name']
?? null;
break;
}
// Normalize whitespace-only fallback names to null (mirror $existingName check)
if (is_string($prospectName)) {
$prospectName = trim($prospectName);
if ($prospectName === '') {
$prospectName = null;
}
}
// set the name key no matter if empty
$data['prospect']['name'] = $prospectName;
return $data;
}
public function exportConversationsPerUser(FilterDefinitionCollection $filterSet, array $include): LazyCollection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query($boolQuery))
->setSize(1000)
->setSource([
'includes' => $include,
])
->setSort([
'scheduled_start_time' => 'asc',
]);
return LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getResults();
})
->map(static function (Result $result): array {
$hit = $result->getHit();
return $hit['_source'];
});
}
private function queryDrillDownResults(User $consumer, BoolQuery $boolQuery, int $page, int $limit = 25): Collection
{
if ($page <= 0) {
throw new OutOfBoundsException('The page number can only be greater or equal to one');
}
$map = Collection::make(self::DRILL_DOWN_MAP);
$query = (new Query($boolQuery))
->setSort(['scheduled_start_time'])
->setSource($map->keys()->all());
if ($limit === 0) {
$query->setSize(1000);
$documents = LazyCollection::make(function () use ($query): Generator {
$scroll = $this->searchService->scroll($query, $this->model);
foreach ($scroll as $resultSet) {
yield $resultSet;
}
})
->flatMap(static function (ResultSet $resultSet): array {
return $resultSet->getDocuments();
});
} else {
$query
->setSize($limit)
->setFrom(($page - 1) * $limit);
$documents = $this->searchService->search($query, $this->model, 'queryDrillDownResults')->getDocuments();
}
return Collection::make($documents)
->map(static function (Document $document) use ($map): array {
$documentDataRaw = $document->getData();
$documentData = array_dot($documentDataRaw);
$data = [];
foreach ($map as $fromKey => $toKey) {
if ($toKey === null) {
continue;
}
array_set($data, $toKey, $documentData[$fromKey] ?? null);
}
$roomOwnerId = $documentData['user.id_string'];
$data['played'] = Collection::make($documentDataRaw['plays'] ?? [])
->map(static function (array $data): string {
return $data['user']['id_string'];
})
->all();
$data['from'] = [
'national_phone_number' => Collection::make($documentDataRaw['participants'] ?? [])
->filter(static function (array $data) use ($roomOwnerId): bool {
return array_key_exists('user', $data) && $data['user']['id_string'] === $roomOwnerId;
})
->map(static function (array $data): ?string {
return $data['phone_number'];
})
->first(),
];
$data['isRecorded'] = Collection::make($documentDataRaw['tracks'] ?? [])
->filter(static function (array $track): bool {
return $track['telephony_provider_id'] !== null;
})
->isNotEmpty();
$data['coaches'] = Collection::make(
is_array($documentDataRaw)
&& array_key_exists('coachingFeedbacks', $documentDataRaw)
&& is_array($documentDataRaw['coachingFeedbacks'])
? $documentDataRaw['coachingFeedbacks']
: [],
);
return $data;
})
->map(static function (array $data) use ($consumer): array {
$dotData = array_dot($data);
// Keep a copy of the original dot data so we can derive names after reshaping
$originalDotData = $dotData;
// map prospect to lead/contact/account
if (array_key_exists('prospect.lead.name', $dotData) && $dotData['prospect.lead.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.lead');
$data['prospect']['type'] = 'lead';
} elseif (array_key_exists('prospect.contact.name', $dotData) && $dotData['prospect.contact.name'] !== null) {
$data['prospect'] = array_get($data, 'prospect.contact');
$data['prospect']['type'] = 'contact';
} elseif (
array_key_exists('prospect.account.account.name', $dotData)
&& $dotData['prospect.account.account.name'] !== null
) {
$data['prospect'] = array_get($data, 'prospect.account');
$data['prospect']['type'] = 'account';
} else {
unset($data['prospect']);
}
// Ensure prospect.name is present; if missing or empty, fill using type-based fallback
$data = self::ensureProspectNameFallback($data, $originalDotData);
$dotData = array_dot($data);
$nationalPhoneNumber = $dotData['from.national_phone_number'];
unset($data['from']);
$data['title'] = getActivityTitleAttribute(
$dotData['organizer.name'],
$dotData['type'],
$dotData['title'],
$dotData['prospect.name'] ?? null,
$nationalPhoneNumber
);
if (array_key_exists('category.name', $dotData) && $dotData['category.name'] === null) {
unset($data['category']['name']);
}
if (array_key_exists('category', $data) && empty($data['category'])) {
unset($data['category']);
}
// Include opportunity if either a value OR a stage label exists.
$hasOpportunityValue = array_key_exists('opportunity.value', $dotData)
&& $dotData['opportunity.value'] !== null;
$hasOpportunityStage = array_key_exists('opportunity.stage.label', $dotData)
&& $dotData['opportunity.stage.label'] !== null;
if ($hasOpportunityValue || $hasOpportunityStage) {
$data['opportunity'] = [];
if ($hasOpportunityValue) {
$data['opportunity']['formattedValue'] = formatOpportunityValue(
(float) $dotData['opportunity.value'],
$dotData['opportunity.currency_code'],
);
}
if ($hasOpportunityStage) {
$data['opportunity']['stage'] = [
'label' => $dotData['opportunity.stage.label'],
];
}
} else {
unset($data['opportunity']);
}
if (array_key_exists('played', $data) && is_array($data['played'])) {
$data['played'] = in_array($consumer->id_string, $data['played'], true);
}
if (array_key_exists('duration', $data) && $data['duration'] !== null) {
$data['durationForHumans'] = secondsToHuman((int) $dotData['duration']);
}
unset($data['duration']);
return $data;
})
// Convert database times to ISO 8601 or frontend will apply timezone conversions
->map(static function (array $data): array {
if (isset($data['actualEndTime'])) {
$data['actualEndTime'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['actualEndTime'])->toIso8601String();
}
return $data;
});
}
public function getConversationsPerActivityChannelDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $activityChannel,
string $drillDownType,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet
->getBoolQuery($filterSet->extractElasticSearchQueries())
->addMust((new Term())->setTerm('type.keyword', $activityChannel));
switch ($drillDownType) {
case self::CONVERSATION_DRILLDOWN_SCHEDULED:
case self::CONVERSATION_DRILLDOWN_ATTEMPTED:
$boolQuery->addMust(new Exists('scheduled_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_CONNECTED:
$boolQuery->addMust(new Exists('actual_start_time'));
break;
case self::CONVERSATION_DRILLDOWN_LOGGED:
$boolQuery->addMust(new Exists('crm_provider_id'));
break;
default:
throw new OutOfBoundsException('Unsupported drill down type');
}
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
int $flags,
int $page,
int $limit = 25,
): Collection {
$extraFilterDefinitionQueries = [];
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_NEGATIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_GAME_CHANGER]))
->setPath('comments', 'comments');
}
if ($this->isBitwiseFlagEnabled($flags, self::FLAG_DRILLDOWN_COMMENT_POSITIVE)) {
$extraFilterDefinitionQueries[] = FilterDefinitionQuery::instance()
->setQuery(new Terms('comments.type', [Comment::TYPE_POSITIVE]))
->setPath('comments', 'comments');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterDefinitionQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getCoachingActivitiesOverTimeDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
User $coachee,
?string $sectionId,
int $page,
int $limit = 25
): Collection {
$extraFilterSetQueries = [
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coachee.id_string', $coachee->id_string))
->setPath('coachingFeedbacks.coachee', 'coachingFeedbacks'),
];
if (is_string($sectionId)) {
$extraFilterSetQueries[] = FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.sectionFeedbacks.section.id_string', $sectionId))
->setPath('coachingFeedbacks.sectionFeedbacks.section', 'coachingFeedbacks.sectionFeedbacks');
}
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries($extraFilterSetQueries)
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getEngagementActivitiesDrillDown(
User $consumer,
FilterDefinitionCollection $filterSet,
string $elasticsearchColumn,
int $page,
int $limit = 25,
): Collection {
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery(new Exists('stats.' . $elasticsearchColumn))
->setPath('stats', 'stats'),
])
);
return $this->queryDrillDownResults($consumer, $boolQuery, $page, $limit);
}
public function getConversationsActivityChannelPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Sum('total_duration'))->setField('duration')
)
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
->addAggregation(
(new Filter('volume_connected', new Exists('actual_start_time')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
->addAggregation(
(new Filter('logged_to_crm', new Exists('crm_provider_id')))
->addAggregation(
new ValueCount('volume', 'id_string.keyword')
)
)
)
->addAggregation(
new AvgBucket('avg_duration', 'by_user>total_duration')
)
->addAggregation(
new AvgBucket('avg_volume_all', 'by_user>volume')
)
->addAggregation(
new AvgBucket('avg_volume_logged', 'by_user>logged_to_crm>volume')
)
->addAggregation(
new AvgBucket('avg_volume_connected', 'by_user>volume_connected>volume')
)
)
);
$results = $this->searchService
->search($query, $this->model, 'getConversationsActivityChannelPerUserAggregation')
->getAggregations();
$connectableActivityChannels = [
Activity::TYPE_SOFTPHONE,
Activity::TYPE_SOFTPHONE_INBOUND,
Activity::TYPE_CONFERENCE,
];
return Collection::make(array_get($results, 'activities.channel.buckets', []))
->map(static function (array $bucket) use ($connectableActivityChannels): array {
$channel = $bucket['key'];
$avgVolume = (float) array_get($bucket, 'avg_volume_all.value', 0);
$avgVolumeLogged = (float) array_get($bucket, 'avg_volume_logged.value', 0);
$avgVolumeConnected = (float) array_get($bucket, 'avg_volume_connected.value', 0);
$avgDuration = (float) array_get($bucket, 'avg_duration.value', 0);
return [
'channel' => $channel,
'stats' => [
'avg_volume' => $avgVolume,
'avg_volume_logged' => $avgVolumeLogged,
'avg_volume_connected' => $avgVolumeConnected,
'avg_duration' => $avgDuration,
],
'per_user' => Collection::make(array_get($bucket, 'by_user.buckets', []))
->keyBy('key')
->map(static function (array $userBucket) use ($channel, $connectableActivityChannels): array {
$data = [
'volume_logged' => (int) array_get($userBucket, 'logged_to_crm.doc_count', 0),
'volume' => (int) $userBucket['doc_count'],
'duration' => (float) array_get($userBucket, 'total_duration.value', 0),
];
if (in_array($channel, $connectableActivityChannels, true)) {
$data['volume_connected'] = (int) array_get($userBucket, 'volume_connected.doc_count');
}
return $data;
})
->all(),
];
});
}
public function getDashboardActivityOverTime(
User $user,
FilterDefinitionCollection $filterSet,
string $histogramInterval = 'day'
): Collection {
$timezoneOffset = $user->getTimezoneOffset();
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter(
'voice_activities',
(clone $boolQuery)
->addFilter(
(new BoolQuery())
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_CONFERENCE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE))
->addShould((new Term())->setTerm('type.keyword', Activity::TYPE_SOFTPHONE_INBOUND))
)
->addFilter(
new Exists('actual_start_time')
)
))
->addAggregation(
(new DateHistogram('over_time', 'actual_end_time', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
->addAggregation(
(new Filter(
'text_activities',
(clone $boolQuery)
->addFilter(
(new Term())->setTerm('type.keyword', Activity::TYPE_SMS_OUTBOUND)
)
))
->addAggregation(
(new DateHistogram('over_time', 'created_at', $histogramInterval))
->setFormat('8uuuu-MM-dd')
->setTimezone($timezoneOffset)
->setMinimumDocumentCount(0)
->addAggregation(
(new AggregationTerms('by_channel'))
->setField('type.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardActivityOverTime')->getAggregations();
$activityData = Collection::make([
array_get($aggregationData, 'voice_activities.over_time.buckets'),
array_get($aggregationData, 'text_activities.over_time.buckets'),
])
->collapse()
->reduce(
static function (array $carry, array $bucketData): array {
$byChannel = Collection::make(array_get($bucketData, 'by_channel.buckets'))
->keyBy('key')
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
$date = $bucketData['key_as_string'];
if (array_key_exists($date, $carry)) {
$byChannel = $byChannel->merge($carry[$date]);
}
$carry[$date] = $byChannel->all();
return $carry;
},
[]
);
return Collection::make($activityData);
}
public function getDashboardCoachingOverTime(
User $user,
FilterDefinitionCollection $filterSet,
?CarbonImmutable $dateTimeRangeStartsAt,
?CarbonImmutable $dateTimeRangeEndsAt,
string $histogramInterval = 'day',
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$timezone = $user->getTimezone();
$timezoneOffset = $user->getTimezoneOffset();
$hasDateRange = $dateTimeRangeStartsAt !== null && $dateTimeRangeEndsAt !== null;
if ($hasDateRange) {
$resultSetKey = 'from_as_string';
$dateTimeRangeStartsAt = $dateTimeRangeStartsAt->setTimezone($timezone)->toImmutable();
$dateTimeRangeEndsAt = $dateTimeRangeEndsAt->setTimezone($timezone)->toImmutable();
$dateRangeAggregation = (new DateRange('over_time'))
->setField('plays.created_at')
->setFormat('8uuuu-MM-dd')
->setParam('time_zone', $timezoneOffset);
if ($histogramInterval === 'day') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addDay();
};
} elseif ($histogramInterval === 'hour') {
$increment = static function (CarbonImmutable $dateTime): CarbonImmutable {
return $dateTime->addHour();
};
} else {
throw new OutOfBoundsException('Unknown date time interval');
}
$periodStartsAt = $dateTimeRangeStartsAt;
while (true) {
$periodEndsAt = $increment($periodStartsAt);
$dateRangeAggregation->addRange(
$periodStartsAt->format('Y-m-d'),
$periodEndsAt->format('Y-m-d')
);
if ($periodEndsAt >= $dateTimeRangeEndsAt) {
break;
}
$periodStartsAt = clone $periodEndsAt;
}
} else {
$resultSetKey = 'key_as_string';
$dateRangeAggregation = (new DateHistogram('over_time', 'plays.created_at', $histogramInterval))
->setTimezone($timezoneOffset)
->setFormat('8uuuu-MM-dd')
->setMinimumDocumentCount(0);
}
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new Nested('playback', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation($dateRangeAggregation)
)
)
);
$aggregationData = $this->searchService->search($query, $this->model, 'getDashboardCoachingOverTime')->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.playback.filtered.over_time.buckets'))
->keyBy($resultSetKey)
->map(static function (array $bucketData): int {
return $bucketData['doc_count'];
});
}
public function getDashboardCoachingBreakdownListensByUserRole(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('plays');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query())
->setSize(0)
->setSource(false)
->addAggregation(
(new Filter('activities', $boolQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('played_by', 'plays'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('plays.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('plays.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownListensByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'activities.by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'played_by.filtered.user.buckets'))
->map(static function (array $playbackBucket): array {
$userId = $playbackBucket['key'];
$count = $playbackBucket['doc_count'];
$userRoles = Collection::make(array_get($playbackBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
public function getDashboardCoachingBreakdownCoachingFocusFilledByUserRole(
FilterDefinitionCollection $filterSet
): Collection {
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries();
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('comments');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$query = (new Query($boolQuery))
->setSize(0)
->setSource(false)
->addAggregation(
(new AggregationTerms('by_user'))
->setField('user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new Nested('commented_by', 'comments'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('user'))
->setField('comments.user.id_string.keyword')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
(new AggregationTerms('role'))
->setField('comments.user.roles.name')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
)
)
)
);
$aggregationData = $this->searchService
->search($query, $this->model, 'getDashboardCoachingBreakdownCoachingFocusByUserRole')
->getAggregations();
return Collection::make(array_get($aggregationData, 'by_user.buckets'))
->keyBy('key')
->map(static function (array $roomOwnerBucket): array {
return Collection::make(array_get($roomOwnerBucket, 'commented_by.filtered.user.buckets'))
->map(static function (array $commentBucket): array {
$userId = $commentBucket['key'];
$count = $commentBucket['doc_count'];
$userRoles = Collection::make(array_get($commentBucket, 'role.buckets'))
->keyBy('key')
->keys();
return [
'count' => $count,
'userId' => $userId,
'userRoles' => $userRoles->all(),
];
})
->all();
});
}
private function getCompositeAggregationBy(
BoolQuery $boolQuery,
AbstractAggregation $sourceAggregation,
?array $customAggregations = null,
?AbstractAggregation $aggregationParent = null,
?callable $compositeAggregationExtractor = null,
?AbstractAggregation $immediateAggregationParent = null
): LazyCollection {
if ($compositeAggregationExtractor === null) {
$compositeAggregationExtractor = static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('composite')['buckets'];
}
return LazyCollection::make(
function () use (
$sourceAggregation,
$customAggregations,
$aggregationParent,
$immediateAggregationParent,
$boolQuery,
$compositeAggregationExtractor,
): Generator {
$compositeAggregation = (new Composite('composite'))
->setSize(self::AGG_COMPOSITE_MAX_SIZE)
->addSource($sourceAggregation);
if (is_array($customAggregations)) {
foreach ($customAggregations as $customAggregation) {
$compositeAggregation->addAggregation($customAggregation);
}
}
$aggregation = $compositeAggregation;
if ($aggregationParent instanceof AbstractAggregation) {
$aggregation = $aggregationParent;
if ($immediateAggregationParent instanceof AbstractAggregation) {
$immediateAggregationParent->addAggregation($compositeAggregation);
} else {
$aggregationParent->addAggregation($compositeAggregation);
}
}
while (true) {
$query = (new Query($boolQuery))
->setSource(false)
->addAggregation($aggregation);
$aggregationData = $this->searchService
->search($query, $this->model, 'getCompositeAggregationBy');
foreach ($compositeAggregationExtractor($aggregationData) as $bucket) {
yield $bucket;
}
$cursor = array_get($aggregationData, 'composite.after_key', null);
if (! is_array($cursor)) {
break;
}
$compositeAggregation->addAfter($cursor);
}
},
);
}
private function getCompositeAggregationByUser(
BoolQuery $boolQuery,
?array $customAggregations = null,
?callable $callback = null,
): LazyCollection {
if ($callback === null) {
$callback = static fn (array $bucket): int => $bucket['doc_count'];
}
$sourceAggregation = (new AggregationTerms('by_user'))
->setField('user.id_string.keyword');
return $this
->getCompositeAggregationBy(
boolQuery: $boolQuery,
sourceAggregation: $sourceAggregation,
customAggregations: $customAggregations,
)
->mapWithKeys(static fn (array $bucket): array => [
$bucket['key']['by_user'] => $bucket,
])
->map($callback);
}
private function getCompositeAggregationByCoachingFeedbackCoach(
BoolQuery $boolQuery,
?array $customAggregations = null
): LazyCollection {
return $this
->getCompositeAggregationBy(
$boolQuery,
(new AggregationTerms('by_feedback_id'))
->setField('coachingFeedbacks.id_string'),
$customAggregations,
new Nested('coachingFeedbacks', 'coachingFeedbacks'),
static fn (ResultSet $aggregationData): array => $aggregationData
->getAggregation('coachingFeedbacks')['composite']['buckets']
);
}
/**
* @param Collection|string[] $statsOfInterest
*
* @return Collection|AbstractAggregation[]
*/
private function getEngagementStatsAggregation(Collection $statsOfInterest): Collection
{
$getAggregation = static function (string $propertyName): Filter {
$totalAmountProperties = [
'talk_time_ratio',
'longest_user_monologue',
'longest_customer_monologue',
'talking_speed',
'user_questions',
];
$propertyPath = 'stats.' . $propertyName;
$filterQuery = (new BoolQuery())
->addMust(new Exists($propertyPath));
if (in_array($propertyName, $totalAmountProperties, true)) {
$filterQuery->addMust(
new Range(
$propertyPath,
[
'gt' => 0,
]
)
);
}
return (new Filter($propertyName, $filterQuery))
->addAggregation(
(new Sum('data'))->setField($propertyPath)
);
};
return Collection::make()
->push(
$statsOfInterest
->reduce(
static function (Nested $carry, string $propertyName) use ($getAggregation): Nested {
return $carry->addAggregation($getAggregation($propertyName));
},
new Nested('stats', 'stats')
)
);
}
public function getDashboardEngagementStats(FilterDefinitionCollection $filterSet): Collection
{
$statsOfInterest = Collection::make([
'talkTimeRatio' => 'talk_time_ratio',
'longestMonologue' => 'longest_user_monologue',
'longestCustomerStory' => 'longest_customer_monologue',
'talkingSpeed' => 'talking_speed',
'patience' => 'patience_time',
'questionRate' => 'user_questions',
]);
$boolQuery = $filterSet->getBoolQuery(
$filterSet->extractElasticSearchQueries()
);
$aggregationData = $this
->getCompositeAggregationByUser(
$boolQuery,
$this->getEngagementStatsAggregation($statsOfInterest)->toArray(),
static function (array $bucket): array {
$statsBucket = $bucket['stats'];
unset($statsBucket['doc_count']);
return Collection::make($statsBucket)
->map(static function (array $stat): array {
return [
'count' => $stat['doc_count'],
'value' => $stat['data']['value'],
];
})
->toArray();
}
)
->collect();
return $statsOfInterest
->map(static function (string $propertyName) use ($aggregationData): ?float {
[$count, $value] = $aggregationData->reduce(
static function (array $accumulator, array $bucket) use ($propertyName): array {
$accumulator[0] += (int) $bucket[$propertyName]['count'];
$accumulator[1] += (float) $bucket[$propertyName]['value'];
return $accumulator;
},
[0, 0]
);
if ($count === 0) {
return null;
}
return (float) ($value / $count);
});
}
public function getCoachingFeedbacksFilledPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coach.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
)
),
],
static function (array $bucket): array {
return array_get($bucket, 'feedbacks.filtered.by_user.buckets', []);
}
)
->reduce(
static function (array $carry, array $buckets): array {
foreach ($buckets as $bucket) {
$userId = $bucket['key'];
if (! array_key_exists($userId, $carry)) {
$carry[$userId] = 0;
}
$carry[$userId] += $bucket['doc_count'];
}
return $carry;
},
[]
);
return Collection::make($data);
}
public function getCoachingFeedbacksReceivedPerUserAggregation(FilterDefinitionCollection $filterSet): Collection
{
$filterDefinitionQueries = $filterSet->extractElasticSearchQueries([
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.visibility', CoachingFeedback::VISIBLE_TO_ALL))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
FilterDefinitionQuery::instance()
->setQuery((new Term())->setTerm('coachingFeedbacks.coach.status', User::STATUS_ACTIVE))
->setPath('coachingFeedbacks', 'coachingFeedbacks'),
]);
$currentPriorityQuery = $filterDefinitionQueries->getNestedQuery('coachingFeedbacks');
$boolQuery = $filterSet->getBoolQuery($filterDefinitionQueries);
$data = $this
->getCompositeAggregationByUser(
$boolQuery,
[
(new Nested('feedbacks', 'coachingFeedbacks'))
->addAggregation(
(new Filter('filtered', $currentPriorityQuery))
->addAggregation(
(new AggregationTerms('by_user'))
->setField('coachingFeedbacks.coachee.id_string')
->setSize(self::AGG_TERMS_MAX_SIZE)
->addAggregation(
new ValueCount('volume', 'coachingFeedbacks.id_string'),
...
|
35167
|
NULL
|
NULL
|
NULL
|
|
35170
|
1315
|
19
|
2026-05-13T12:16:30.957789+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674590957_m1.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1362947798257697316
|
-2575675244731720149
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
Firefox FileEditViewHistoryBookmarksToolsWindowHelp• 0APPapp/Console/Commands/Activities/SetupIntegration/TwilioSetS3RecordingCredentialsCommand.bapp/Console/Kernel.phpapp/Jobs/ImportRemoteTrackJob.phpapp/Services/Activity/Twilio/S3RecordingCredentialsService.phptests/Feature/Jobs/ImportRemoteTrackJobTest.phptests/Unit/Component/Encoding/Job/AnalyzeTrackChannelsJobTest.phptests/Unit/Component/FFMpeg/Services/GetSpeechIntervalsTest.phptests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTest.php10 files changed, 823 insertions(+), 23 deletions(-)create mode 100644 app/Console/Commands/Activities/SetupIntegration/TwilioSetS3Recordingcreate mode 100644 app/Services/Activity/Twilio/S3RecordingCredentialsService.phpcreate mode 100644 tests/Unit/Services/Activity/Twilio/S3RecordingCredentialsServiceTestlukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20891-improve-:Switched to a new branch 'JY-20891-improve-sms-text-relays'lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.plPHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminskicontributors.Running analysis on 7 cores with 10 files per process.Parallel runner is an experimental feature and may be unstable, use it at your own risk.Loaded configdefault from-php-cs-fixer.dist.php"5665/5665100%1) app/Jobs/Mailbox/EmailTextRelay.php (no_unused_imports)begin diff/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php+++/home/jiminny/app/Jobs/Mailbox/EmailTextRelay.php-16,7 +16,6 @@use Jiminny\Mail\Activities|SmsRelayFailed;use Jiminny\Models\Activity;use Jiminny Models \TextRelay;Jiminny\Models\User;useJiminny\Repositories\UserRepository;use Jiminny\Rules\SmsMessage;use Jiminny\Services\Mail\TextRelayService;end diffFixed 1 of 5665 files in 52.535 seconds, 67.00 MBmemory usedWhat's next:Try Docker Debug for seamless, persistent debugging tools in any containeror image →Learn more at https://docs.docker.com/go/debug-cli/lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20891-improve-sms-text-relays)HomeDMsActivityFilesLater..•More> 0lallJiminny ...# contusion-clinic# curiosity_lab# engineering# general# jiminny-bg# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the_people_of jimi...• Direct messages. Nikolay Ivanovd. James GrahamStoyan Tanev®. Galya Dimitrova ORe Steliyan Georgiev&. Petko Kashinskie. Aneliya Angelova8. Stefka StoyanovaB. Vasil VasilevLukas Kovalik y...i: AppsToastJira CloudConala CalaSprint Review - in 44 m100% <78•Wed 13 May 15:16:30Describe what you are looking for# releases8 226 0MessagesC FilesBookmarks+3 new messagesNewCircleCI AP.-Deployment Successful!Project: appWhen:05/13/202611:57:10Tag:View JobGitHub APP3:10 PM6 new commits pushed to master by Vasil-Jiminny851bf1a7 - Remove ignored records that causelocal phpstan errors. No functional changes.d08f0260 - Merge branch 'master' intoremove-phpstan-errorsb2d676c3 - Merge branch 'master' intoremove-phpstan-errors1ff6f70f - Merge branch 'master' intoremove-phpstan-errors62a7fe62 - Merge branch 'master' intoremove-phpstan-errorsShow morejiminny/app Added by GitHubVasil Vasilev 3:11 PMStopped. The PR is internal dev optimisation, noneed to reach prod.Message #releases+..•...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35171
|
1316
|
20
|
2026-05-13T12:16:30.957396+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674590957_m2.jpg...
|
PhpStorm
|
faVsco.js – TeamInsightsRepository.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-1362947798257697316
|
-2575675244731720149
|
click
|
hybrid
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, menu
PhpStormFV faVsco.js~INavigarecode(C) ActivitvCommentRenosita©ActivityLogRepository-phy© ActivityMessageRepositol©ActivityMomentRepositor© ActivityProviderRepositor©ActivityRepository.php© ActivitySearchFilterReposActivityShareRepository.F© ActivityUploadSettingRepC AIPromptkepository.onc© AskAnythingRepository.plC) DeviceRerositorv.oho© ElasticActivityRepository.(c) EmailMessadeRenositorv.(C) GenericA PromotRenosito© GroupRepository.php© InboxEmailBatchRepositoC InboxRepositorv.oho© InvitationRepository.php© JobRepository.php© LanguageRepository.php© MomentRepository.phpNotificationRepository.ph© ParticipantSpeechReposit© ParticipantStatsRepositor© PlaybookCategoryReposit© PlaybookRepository.phpPlaylistActivityRepository.© PlaylistRepository.phpPlaylistShareRepository.p© QuestionRepository.php© RoleChangeEventRepositi© RoleRepository.phpc) SearchRenositorv.onv© SnapshotRepository.phpC) SocialAccountRevositorv.© StageRepository.php(C) SubscriotionSetRevositon©TaskRepository.php(C) TeamA ContextRenositon© TeamDomainsRepository.(c) TeaminciahtcRenositorvr©TeamRepository.php(C) ThemeRenositorv nhn655675677679© MailboxController.php© SsoController.php©smsmessage.ong© SmsLength.phpQ- CONTEXT_TEAM.INSIGHTS ACTIVITY X 5 Cc w .*TU8:class leamenszencskepos.corypublic function getDashboardActivity0verTime(-›setSize( size: self::AGG_TERMS_MAX_SIZE)A16Y1 A->addAggregation(new rilterIclone sbooluuery)->addFilter((new lermo->setlerm key: "type.keyword",value: Activity::TYPE_SMS_OUTBOUND)(new DateHistogram( name: 'over time' field: 'created at'. ShistogramInterval))at: 'Suuuu-MM-dd")->settimezone (Stimezonelffset).->addAdaredation(new AggregationTerms( name:'by_channel'))->setFieldd field'type.keyword')-›setSize( size: self::AGG_TERMS_MAX_SIZE)SaggregationData = $this-›searchService-›search($query, $this-›model, queryName: 'getDashboardActivitySactivityData = Collection: :make([array_get($aggregationData,array get saggregaclonvaca.key: 'voice_activities.over_time.buckets'),key:|'text_activities.over_time.buckets'),->collapse()->reoucestatic function (array $carry, array $bucketData): array f...7,return Collection::make(SactivityData):oublic function aetDashboardCoachina0vertimedE custom.logA console [STAGING]E laravel.logA SF jiminny@localhost]A HS_Jocal [jiminny@localhost]A console (PROD] X A console (EU]644645646648649650652-653654655656657665-666667=668669—0/0Tx: AutovORDER BY t.name, calendar domain:So jiminny040 A1 A40 V 65 ^select * trom users u jo1n calendars c 1<->I.n. on c.user 1d = U.1dwhere u.team_id = 882;select * from activities where id = 14049485: # team 563 crm 53select * from activities where id = 73272382; # team 563 crm 537select * from activities where id = 64400389: # team 563 crm 537select * from activities where id = 58081273; # team 563 crm 537select * from activities where id = 54520297; # team 563 crm 537select * from participants where activity_id = 58081273;select * from activities where crm_configuration_id = 537 and provider = 'aircall'and account_id = 19003658 order by updated_at desc;select * from contacts where crm_configuration_id = 537 and id = 35957759;select * from accounts where crm_configuration_id = 537 and id = 19003658;select * from automated_report_results where id = 1976;select * from automated_reports where id = 583;select * from activity_searches where id = 87714;select * from activity_search_filters where activity_search_id = 87714;SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuidor uvid_to_bin(*47842446-af51-4bcb-854f-CC6560290101') = uuid;SELECT * FROM crm_configurations WHERE provider = 'hubspot';select * from rate_limits;select * from alated_report_results where nedia,tyRe = 'pdf' and status = 2and id IN (18,1872):select * from automated_reports where id = 54;SELECT * FROM users WHERE id IN (24623,29443,29613);SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;select * from text pelavs where created at 12026-05-014# and id IN (32415, 32416);and id = 72412.select * from users where team_id = 2 and email like '%scott%' and id = 29510;672vSELECT * FROM activities WHERE uvid_to_bin('67cebfc2-ed56-44a2-8C68-7a0286ed8618') = uuid; # 79763436sonnt Keview • In 44m100% L28• Wed 13 May 15:16:30U AskJiminnyReportActivityServiceTest~CascadeTrial Owner Role SeleRetactoring User EmaDashboard Activity De+0 ..Give me the whole flowComplete Dashboard Activity Flow1.AP Request Entrv PointFile: DashboardController.php:33-68• phppubuic tunction Terchtkequest srequest): JsonkesponseSuser = $this->getUserFromRequest (Srequest);Scriteria = Criteria::createFromRequest(Srequest-sallo. Suser->aetTimezone@)•Srequest→>val1date(Stilterser→>getva Lidaclonku les()→>auuo;return sthis->response->withArray([= StilterSet->renderon'activity-over-time' = Sthis->getActivityOverTime($user, $filterSet),Context set: CONTEXT_TEAM_ INSIGHTS_ACTIVITY = 'tean-insights-activity'2. Filter Set CreationFile: ActivitySearch.php: 132-244private function getteaminsightsPageFilters(bool SisExport = false): Filterdefinitioncollectionreturn FilterDefinitionCollection::make(Collection: :make(lFilterDefinition Teaminsiahts DateRangeFilter::class.FilterDefinition TeamInsiahts|Exists:.class.Ask anvthina (84L)« Code SWF-1.6f 4 spaces...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35172
|
1315
|
20
|
2026-05-13T12:16:46.831493+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674606831_m1.jpg...
|
PhpStorm
|
faVsco.js – Search.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"10","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\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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}]...
|
-3137241213432059524
|
-9033998894274884739
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide...
|
35170
|
NULL
|
NULL
|
NULL
|
|
35173
|
1316
|
21
|
2026-05-13T12:16:46.832916+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674606832_m2.jpg...
|
PhpStorm
|
faVsco.js – Search.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"10","depth":4,"bounds":{"left":0.38231382,"top":0.17478053,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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}]...
|
6081792187638624635
|
2218600139808192077
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project...
|
35171
|
NULL
|
NULL
|
NULL
|
|
35174
|
1315
|
21
|
2026-05-13T12:16:50.528634+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674610528_m1.jpg...
|
PhpStorm
|
faVsco.js – Search.php
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
EventSubscriber, folder
FilterDefinition, folder
DealInsights, folder
Security, folder
TeamInsights, folder
ActivityActualDate.php
ActivityChannel.php
ActivityDurationRange.php
ActivityFilter.php
ActivityPlaylistIn.php
ActivityProviderIn.php
ActivityRecorded.php
ActivityRecordingStopped.php, final class
ActivityScheduledDate.php, final class
ActivityStatusIn.php, class
ActivityType.php, final class
ActivityUpdatedDate.php, final class
AiCallScoreFilter.php, final class
AutoScoreFilter.php, final class
ClosedDealsFilter.php, final class
CoachingFeedbackAverageScore.php, final class
CoachingFeedbackCoachUserIn.php, final class
CommentCountRange.php, final class
CrmFieldCollection.php, final class
CurrentStage.php, final class
Customer.php, final class
CustomerMonologueDuration.php, final class
CustomerQuestionCount.php, final class
DealAge.php, final class
DealCloseDate.php, final class
DealValue.php, final class
EngagingQuestionCount.php, final class
ExternalId.php, final class
HasPendingAiCrmNotes.php, final class
HasTopicTriggersFilterDefinition.php, final class
HasTranscription.php, final class
IndexedAtFrom.php, final class
InputTypeEnum.php, final class
InsightfulQuestionCount.php, final class
LanguageFilterDefinition.php, final class
LoggedToCrm.php, final class
NudgeRunId.php, final class
OnlyActiveUsers.php, final class
OrganiserGroupIn.php, class
OrganiserTeamIn.php, final class
OrganiserUserIn.php, class
OrganiserUserNotIn.php, final class
ParticipantUserIn.php, final class
PartnerFilterDefinition.php, final class
PatienceRange.php, final class
PlaybackTopicFilterDefinition.php, final class
ProviderFilterDefinition.php, final class
ShowInternalExternalActivitiesFilter.php, final class...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"10","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\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"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":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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},{"role":"AXStaticText","text":"app ~/jiminny/app, folder","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".cursor, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".github","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".sonarlint, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".vscode, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".windsurf, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"app, sources root","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Actions, folder","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InviteUserToTeamAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MarkUserAsOnboardableAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SyncRecordingFlagsAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateTeamMemberAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateUserRolesAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Component","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Acl","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActionItems","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Activity","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityAnalytics","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivitySearch","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"EventSubscriber, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"FilterDefinition, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealInsights, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Security, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TeamInsights, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityActualDate.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityChannel.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityDurationRange.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityFilter.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityPlaylistIn.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityProviderIn.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityRecorded.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityRecordingStopped.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityScheduledDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityStatusIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityType.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityUpdatedDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AiCallScoreFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AutoScoreFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ClosedDealsFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedbackAverageScore.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedbackCoachUserIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CommentCountRange.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CrmFieldCollection.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CurrentStage.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Customer.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CustomerMonologueDuration.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CustomerQuestionCount.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealAge.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealCloseDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealValue.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"EngagingQuestionCount.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ExternalId.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HasPendingAiCrmNotes.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HasTopicTriggersFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HasTranscription.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IndexedAtFrom.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InputTypeEnum.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InsightfulQuestionCount.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LanguageFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LoggedToCrm.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"NudgeRunId.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OnlyActiveUsers.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserGroupIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserTeamIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserUserIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserUserNotIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ParticipantUserIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PartnerFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PatienceRange.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PlaybackTopicFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ProviderFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ShowInternalExternalActivitiesFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"}]...
|
3028517611015581748
|
1065678636275086925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
EventSubscriber, folder
FilterDefinition, folder
DealInsights, folder
Security, folder
TeamInsights, folder
ActivityActualDate.php
ActivityChannel.php
ActivityDurationRange.php
ActivityFilter.php
ActivityPlaylistIn.php
ActivityProviderIn.php
ActivityRecorded.php
ActivityRecordingStopped.php, final class
ActivityScheduledDate.php, final class
ActivityStatusIn.php, class
ActivityType.php, final class
ActivityUpdatedDate.php, final class
AiCallScoreFilter.php, final class
AutoScoreFilter.php, final class
ClosedDealsFilter.php, final class
CoachingFeedbackAverageScore.php, final class
CoachingFeedbackCoachUserIn.php, final class
CommentCountRange.php, final class
CrmFieldCollection.php, final class
CurrentStage.php, final class
Customer.php, final class
CustomerMonologueDuration.php, final class
CustomerQuestionCount.php, final class
DealAge.php, final class
DealCloseDate.php, final class
DealValue.php, final class
EngagingQuestionCount.php, final class
ExternalId.php, final class
HasPendingAiCrmNotes.php, final class
HasTopicTriggersFilterDefinition.php, final class
HasTranscription.php, final class
IndexedAtFrom.php, final class
InputTypeEnum.php, final class
InsightfulQuestionCount.php, final class
LanguageFilterDefinition.php, final class
LoggedToCrm.php, final class
NudgeRunId.php, final class
OnlyActiveUsers.php, final class
OrganiserGroupIn.php, class
OrganiserTeamIn.php, final class
OrganiserUserIn.php, class
OrganiserUserNotIn.php, final class
ParticipantUserIn.php, final class
PartnerFilterDefinition.php, final class
PatienceRange.php, final class
PlaybackTopicFilterDefinition.php, final class
ProviderFilterDefinition.php, final class
ShowInternalExternalActivitiesFilter.php, final class...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
35175
|
1316
|
22
|
2026-05-13T12:16:50.528633+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-13/1778 /Users/lukas/.screenpipe/data/data/2026-05-13/1778674610528_m2.jpg...
|
PhpStorm
|
faVsco.js – Search.php
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
EventSubscriber, folder
FilterDefinition, folder
DealInsights, folder
Security, folder
TeamInsights, folder
ActivityActualDate.php
ActivityChannel.php
ActivityDurationRange.php
ActivityFilter.php
ActivityPlaylistIn.php
ActivityProviderIn.php
ActivityRecorded.php
ActivityRecordingStopped.php, final class
ActivityScheduledDate.php, final class
ActivityStatusIn.php, class
ActivityType.php, final class
ActivityUpdatedDate.php, final class
AiCallScoreFilter.php, final class
AutoScoreFilter.php, final class
ClosedDealsFilter.php, final class
CoachingFeedbackAverageScore.php, final class
CoachingFeedbackCoachUserIn.php, final class
CommentCountRange.php, final class
CrmFieldCollection.php, final class
CurrentStage.php, final class
Customer.php, final class
CustomerMonologueDuration.php, final class
CustomerQuestionCount.php, final class
DealAge.php, final class
DealCloseDate.php, final class
DealValue.php, final class
EngagingQuestionCount.php, final class
ExternalId.php, final class
HasPendingAiCrmNotes.php, final class
HasTopicTriggersFilterDefinition.php, final class
HasTranscription.php, final class
IndexedAtFrom.php, final class
InputTypeEnum.php, final class
InsightfulQuestionCount.php, final class
LanguageFilterDefinition.php, final class
LoggedToCrm.php, final class
NudgeRunId.php, final class
OnlyActiveUsers.php, final class
OrganiserGroupIn.php, class
OrganiserTeamIn.php, final class
OrganiserUserIn.php, class
OrganiserUserNotIn.php, final class
ParticipantUserIn.php, final class
PartnerFilterDefinition.php, final class
PatienceRange.php, final class
PlaybackTopicFilterDefinition.php, final class
ProviderFilterDefinition.php, final class
ShowInternalExternalActivitiesFilter.php, final class
SortBy.php, final class...
|
[{"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-20891-improve-sms-text-relays, menu","depth":5,"bounds":{"left":0.064494684,"top":0.019952115,"width":0.08843085,"height":0.025538707},"on_screen":true,"help_text":"Git Branch: JY-20891-improve-sms-text-relays","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":"10","depth":4,"bounds":{"left":0.38231382,"top":0.17478053,"width":0.009640957,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.39361703,"top":0.17318435,"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.40093085,"top":0.17318435,"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\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","depth":4,"on_screen":true,"value":"<?php\n\ndeclare(strict_types=1);\n\nnamespace Jiminny\\Component\\ElasticSearch\\Service;\n\nuse ChaseConey\\LaravelDatadogHelper\\Datadog;\nuse Elastica;\nuse Elastica\\Document;\nuse Elastica\\Query;\nuse Generator;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Support\\Collection;\nuse Illuminate\\Support\\Facades\\Log;\nuse Illuminate\\Support\\LazyCollection;\nuse Jiminny\\Component\\ElasticSearch\\Client;\nuse Jiminny\\Component\\ElasticSearch\\Contract\\Searchable;\nuse Jiminny\\Component\\ElasticSearch\\ModelFiller;\nuse Jiminny\\Models\\Activity;\n\n/**\n * Class Search\n *\n * @package Jiminny\\Component\\ElasticSearch\\Service\n */\nclass Search\n{\n /**\n * @var Client\n */\n private $client;\n\n /**\n * @var ModelFiller\\Elastica\n */\n private $modelFiller;\n\n public function __construct(Client $client, ModelFiller\\Elastica $modelFiller)\n {\n $this->client = $client;\n $this->modelFiller = $modelFiller;\n }\n\n public function updateDocument(Searchable $model): self\n {\n return $this->updateDocumentCollection($model, new Collection([$model]));\n }\n\n public function updateDocumentCollection(\n Searchable $model,\n Collection $collection,\n int $chunkSize = 10,\n ?callable $callback = null,\n ): self {\n if ($collection->count() === 0) {\n return $this;\n }\n\n $documentType = $this->client->createIndex($model->getIndex());\n\n $collection\n ->chunk($chunkSize)\n ->each(static function (Collection $collection) use ($documentType, $callback): void {\n $documents = $collection->map(static function (Searchable $model): Document {\n return new Document((string) $model->getId(), $model->getIndexableAttributes());\n });\n\n $documentType->addDocuments($documents->all());\n\n if ($callback !== null) {\n $callback($collection, $documents);\n }\n\n gc_collect_cycles();\n });\n\n return $this;\n }\n\n private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\\Search\n {\n if (request() && request()->has('debug')) {\n Log::info('Debug ES query: ', [\n 'debug' => request()->get('debug'),\n 'userId' => request()->user()?->id ?? 'anonymous',\n 'userUuid' => request()->user()?->getIdString() ?? 'anonymous',\n 'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),\n 'url' => request()->fullUrl(),\n ]);\n }\n\n return $this->client\n ->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)\n ->createSearch($query);\n }\n\n public function scroll(Query $query, Searchable|string $model): Elastica\\Scroll\n {\n return new Elastica\\Scroll($this->createSearch($query, $model));\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n *\n * @return LazyCollection<int, Document>\n */\n public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection\n {\n return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {\n foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {\n foreach ($resultSet->getDocuments() as $document) {\n yield $document;\n }\n }\n });\n }\n\n /**\n * @param Searchable|string $modelOrIndex usage of model is deprecated\n */\n public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\\ResultSet\n {\n Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);\n\n $before = microtime(true);\n\n $result = $this->createSearch($query, $modelOrIndex)->search();\n\n $after = microtime(true);\n\n Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);\n\n return $result;\n }\n\n /**\n * @TODO use LazyCollection\n *\n * @return Collection<int, Activity>\n */\n public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection\n {\n return $this\n ->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)\n ->collect();\n }\n\n /**\n * @return array{totalHits: int, results: Collection<int, Activity>}\n */\n public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array\n {\n $search = $this->search($query, $model, $queryName);\n\n /**\n * @TODO Use value-object instead.\n */\n return [\n 'totalHits' => $search->getTotalHits(),\n 'results' => $this\n ->hydrateCollection($search->getDocuments(), $model)\n ->collect(),\n ];\n }\n\n private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection\n {\n return LazyCollection::make($collection)\n ->map(function (Document $document) use ($model): Searchable {\n return $this->hydrateModel($document, $model);\n });\n }\n\n private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable\n {\n $attributes = $document->getData();\n $attributes['id'] = $document->getId();\n\n /** @var Searchable&Model */\n return $this->modelFiller->newFromBuilderRecursive($model, $attributes);\n }\n}","role_description":"text entry area","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Execute","depth":4,"bounds":{"left":0.40957448,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Explain Plan","depth":4,"bounds":{"left":0.41821808,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Browse Query History","depth":4,"bounds":{"left":0.42918882,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"View Parameters","depth":4,"bounds":{"left":0.43783244,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Open Query Execution Settings…","depth":4,"bounds":{"left":0.44647607,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"In-Editor Results","depth":4,"bounds":{"left":0.4574468,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Tx: Auto","depth":4,"bounds":{"left":0.46841756,"top":0.09896249,"width":0.024268618,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Cancel Running Statements","depth":4,"bounds":{"left":0.4950133,"top":0.09896249,"width":0.008643617,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":false,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Playground","depth":4,"bounds":{"left":0.50598407,"top":0.09896249,"width":0.029587766,"height":0.01915403},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"jiminny","depth":4,"bounds":{"left":0.7084442,"top":0.09896249,"width":0.02825798,"height":0.01915403},"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":"40","depth":4,"bounds":{"left":0.67785907,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":4,"bounds":{"left":0.69015956,"top":0.123703115,"width":0.00731383,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"40","depth":4,"bounds":{"left":0.6994681,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"65","depth":4,"bounds":{"left":0.7117686,"top":0.123703115,"width":0.010305851,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Previous Highlighted Error","depth":4,"bounds":{"left":0.7237367,"top":0.12210695,"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.73105055,"top":0.12210695,"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":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","depth":4,"on_screen":true,"value":"SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993\nSELECT * FROM users WHERE id = 25061;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 994;\nSELECT * FROM crm_profiles WHERE user_id = 25061;\n\nselect * from crm_configurations where id = 834;\nSELECT * FROM teams WHERE id = 882;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;\n\nSELECT * FROM contacts where crm_configuration_id = 834;\nSELECT * FROM opportunities WHERE team_id = 933\n# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');\nAND id IN (8482561,18352941,19042734,19232139,19445140,19472541);\nSELECT * FROM opportunity_contacts\nWHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 485; #\nSELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\nselect crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id\nwhere crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')\n# and l.converted_at IS NOT NULL\n;\n\n# ********************************************************************\nSELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')\nand opportunity_id IS NULL\norder by id desc;\n\nSELECT * FROM teams WHERE id = 604; # 598\nSELECT * FROM activities WHERE id = 74410828; # chelseaw@allvoices.co\nSELECT * FROM accounts WHERE id = 20068382;\nSELECT * FROM accounts WHERE id = 35186038;\n\nSELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 559 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;\nselect * from sidekick_settings where team_id = 781;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100\n\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 711;\nSELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL\nand is_internal = 0 and status = 'completed'\norder by id desc;\n\nSELECT * FROM crm_layout_entities\nWHERE crm_layout_id IN (2352, 2353);\n;\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 556 and sa.provider = 'hubspot';\n\nSELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;\nSELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;\nselect * from contacts\nwhere crm_configuration_id = 530\nand crm_provider_id = 872252;\n\nselect * from activities where crm_configuration_id = 530\nand user_id = 14343 and type like '%softphone%'\nand created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';\n\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya\nSELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);\n\n\nSELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t\nJOIN crm_configurations c ON t.id = c.team_id\nWHERE t.status = 'active';\n\nSELECT * FROM teams where id = 1091;\nSELECT * FROM crm_configurations where team_id = 1091;\nSELECT * FROM activity_providers where team_id = 1091;\nSELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT * FROM teams WHERE name LIKE '%Leadventure%';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1091 and sa.provider = 'salesforce';\n\nSELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812\nSELECT * FROM teams where id = 862;\nSELECT * FROM crm_configurations where team_id = 862;\nSELECT * FROM activity_providers where team_id = 862;\nSELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')\nand provider NOT IN ('hubspot', 'aircall')\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by id desc;\n\n\nSELECT t.id, crm.id, crm.provider, ap.* FROM teams t\njoin crm_configurations crm on t.id = crm.team_id\njoin activity_providers ap on t.id = ap.team_id\nwhere t.status = 'active' and ap.is_enabled = 1\nand crm.provider = 'hubspot'\nand ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',\n 'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');\n\nSELECT * FROM teams where id = 1068;\nSELECT * FROM crm_configurations where team_id = 1068;\nSELECT * FROM activity_providers where team_id = 1068;\n\nSELECT * FROM activities a\nwhere crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')\nand a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'\n )\n# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'\norder by a.id desc;\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1068 and sa.provider = 'hubspot';\n\n# ********************************************************************\n# ********************************************************************\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 933 and sa.provider = 'hubspot';\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262\nSELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 882 and sa.provider = 'hubspot';\nselect * from crm_layouts where crm_configuration_id = 834;\nselect * from crm_layout_entities where crm_layout_id = 2780;\nselect * from crm_fields where id IN (321153,321192,321193,321194);\n\nSELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1057 and sa.provider = 'hubspot';\n\nSELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8\n\nSELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20\n\nSELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last\n\nSELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10\n\nSELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2\n\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;\n\nSELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th\n# ********************************************************************\nSELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #\n\nSELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;\nselect * from users where team_id = 51; # 7783\nSELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130\nselect * from activity_searches where user_id = 7783;\nselect * from activity_search_filters where activity_search_id IN (32291, 32292);\n\nSELECT asf.activity_search_id, asf.id, asf.value\nFROM activity_search_filters asf\nWHERE asf.filter = 'group_id'\nAND asf.value IN (\n SELECT CONCAT(\n HEX(SUBSTR(uuid, 5, 4)), '-',\n HEX(SUBSTR(uuid, 3, 2)), '-',\n HEX(SUBSTR(uuid, 1, 2)), '-',\n HEX(SUBSTR(uuid, 9, 2)), '-',\n HEX(SUBSTR(uuid, 11))\n )\n FROM groups\n WHERE deleted_at IS NOT NULL\n);\n\nSELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th\n# ********************************************************************\nSELECT * FROM crm_configurations where provider = 'hubspot';\nSELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133\nSELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;\nSELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null\n# ********************************************************************\n\nselect * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';\nselect\n cp.*\n# DISTINCT t.id\n# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields\nFROM crm_profiles cp\nJOIN crm_configurations crm on crm.id = cp.crm_configuration_id\nJOIN users u on u.id = cp.user_id\nJOIN teams t ON t.id = crm.team_id\nWHERE crm.provider = 'salesforce' and t.status = 'active'\n and cp.archived_at IS NULL and u.deleted_at IS NULL\n and t.id NOT IN (1093)\n and t.id = 2\n and cp.contact_fields IS NULL;\n# and c.crm_provider_id = '003Uu00000ojD4NIAU';\n\nSELECT * FROM users WHERE id = 26484;\nSELECT * FROM crm_profiles WHERE user_id = 26484;\nSELECT * FROM social_accounts WHERE sociable_id = 26484;\nSELECT * FROM crm_configurations where provider = 'salesforce';\nselect * from users where id IN (10022, 10403);\nselect * from users where team_id IN (526);\nselect * from teams where id IN (526, 532);\nselect * from crm_configurations where id IN (500, 516);\nselect * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);\nselect * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 526 and sa.provider = 'salesforce';\nselect * from team_settings where team_id IN (526, 532);\n\nselect * from users where id IN (22824);\nselect * from crm_profiles where crm_configuration_id IN (1026);\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1093 and sa.provider = 'salesforce';\n\nselect * from teams where id = 1099;\nselect * from users where id = 29643\n\nselect * from activity_processing_states;\n\nSELECT * FROM teams where name LIKE '%Fare%'; # 233\nSELECT * FROM opportunities where crm_configuration_id = 215\n# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'\n;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1088 and sa.provider = 'hubspot';\n\nSELECT * FROM teams order by updated_at DESC\nSELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account\n\nselect * from crm_configurations where provider = 'pipedrive';\n\nselect * from teams where id = 957;\nselect * from crm_configurations where id = 957;\n\nSELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743\nSELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;\n\nselect * from users where team_id = 1; # 26726 - Gabriela Dureva\nSELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific\nselect * from activities where user_id = 26726 order by id desc;\nselect * from contacts where crm_configuration_id = 1\nand email IN ('charlotte.ward@prolific.com', 'frankie.bryant@prolific.com'); # 2094416, 2093620\nSELECT * FROM contacts WHERE id = 6284931;\n\nSELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id\nWHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;\n\nselect * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);\nselect * from crm_configurations where id = 1;\n\n43801692-1aeb-32ce-acba-5b80a479701a\n44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b\n405975c0-b3d0-7aaa-821f-09d59cae6dd1\n4caf848d-4bed-2299-b248-7788d41f9fca\n49bedc3f-f196-eef3-89c3-dea6a3b4aa63\n43420989-a09d-b8f8-9806-c8bbf7a02aac\n\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nSELECT * FROM activities WHERE id = 75461988;\n\nSELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;\n\nselect * from contacts where id = 17900517;\n\nselect * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id\nwhere crm.provider != 'salesforce';\n\nselect * from users where id = 21047;\nSELECT * FROM crm_configurations WHERE id = 892;\nSELECT * FROM teams WHERE id = 942;\nselect * from opportunities where team_id = 942 order by updated_at desc;\nselect * from contacts where team_id = 942 order by updated_at desc;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 942 and sa.provider = 'hubspot';\n\nSELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430\nSELECT * FROM crm_configurations WHERE id = 1;\nSELECT * FROM teams WHERE crm_id = 1;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1 and sa.provider = 'salesforce';\n\nselect id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1\nSELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430\n\nselect * from teams where id = 852;\nselect * from groups where id = 2286;\nselect * from sidekick_settings where team_id = 852;\nselect * from default_activity_types where team_id = 852;\n\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1 AND u.deleted_at IS NULL\nAND u.crm_required = 1\nAND u.team_id = 1\nORDER BY u.team_id;\n\nSELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (\n18481\n );\n\nSELECT cc.provider, cc.id, p.id, u.*\nFROM users u\nLEFT JOIN crm_profiles p ON u.id = p.user_id\nINNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'\nINNER JOIN crm_configurations cc ON t.crm_id = cc.id\nWHERE u.status = 1\n AND u.deleted_at IS NULL\n AND u.crm_required = 1\n# AND u.team_id = 1\n AND p.id IS NULL -- Move this condition to WHERE clause\nORDER BY u.team_id;\n\nSELECT * FROM opportunities WHERE id = 20002609;\nselect * from teams where id = 1122; # Velatir, 29953 - christian@velatir.com\nselect * from crm_configurations where id = 1060;\nselect * from crm_layouts where crm_configuration_id = 1060;\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 1122 and sa.provider = 'hubspot';\nselect * from opportunities where team_id = 1122 order by updated_at desc;\n\nselect * from crm_field_data where object_type = 'contact';\n\nSELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 248 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS\nSELECT * FROM users where id = 24115;\nSELECT * FROM accounts where id = 4002896;\nSELECT * FROM teams WHERE name LIKE '%adswerve%';\nSELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN (\"0069N000003GIQ9QAO\",\"0061r000019yGP9AAM\",\"0066900001S2KWlAAN\",\"0066900001TDpj2AAD\",\"0066900001b8uEwAAI\",\"0069N000001rQi0QAE\",\"006QF00000KD40mYAD\",\"006QF00000LzpRJYAZ\",\"0069N000002uomtQAA\",\"0069N000002xlMLQAY\",\"0066900001NV6ubAAD\",\"0061r00001HJp45AAD\",\"006QF00000uTlUoYAK\",\"006QF00000v0bZqYAI\");\nSELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203\n\nSELECT u.id, u.email, ac.name, a.* FROM activities a\nJOIN users u ON a.user_id = u.id\nJOIN accounts ac ON a.account_id = ac.id\nWHERE\nuuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or\nuuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or\nuuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;\n\nselect * from users where id = 5825;\nSELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;\n\nselect * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;\n19594, 862\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 862 and sa.provider = 'salesforce';\n\nselect * from automated_reports where id = 36;\nselect ar.frequency, r.*, ar.* from automated_report_results r\njoin automated_reports ar on r.report_id = ar.id\nwhere ar.frequency != 'one_off';\n\nselect s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;\nselect * from nudges n where n.activity_search_id\n\nselect * from teams where created_at > '2026-03-09';\nSELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065\nSELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;\n\nselect * from users where team_id = 1 and name like '%Lukas%'; # 7160\n\nSELECT * FROM teams WHERE id = 575;\nselect * from opportunities where team_id = 575;\nSELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,\nselect * from opportunities where team_id = 1126;\nSELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,\nselect * from opportunities where team_id = 1125;\nselect * from contacts c\nwhere c.team_id = 882;\n\nSELECT * FROM activities WHERE id = 76822967;\nSELECT * FROM crm_profiles WHERE user_id = 15440;\nSELECT * FROM crm_profiles WHERE crm_configuration_id = 555;\nSELECT * FROM crm_configurations WHERE id = 555;\nSELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 581 and sa.provider = 'salesforce';\n\nSELECT * FROM automated_report_results order by id desc;\n\nselect * from features;\nselect * from team_features where feature_id = 40;\n\nselect * from teams where id = 556;\n\nselect * from automated_reports;\nwhere id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , [\"pdf\",\"podcast\"]\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\nselect * from automated_report_results order by id desc;\nSELECT * FROM automated_report_results WHERE id = 1919;\n\nselect * from automated_report_results WHERE report_id = 54;\n\nselect * from opportunities where id = 7594349;\n\nSELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - jiminnyintegration@lesmills.com\nselect * from playbooks where team_id = 711; # event 226147\nSELECT * FROM playbook_categories WHERE playbook_id = 5515;\nSELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';\nSELECT * FROM crm_fields WHERE id = 226147;\nSELECT * FROM crm_field_values WHERE crm_field_id = 226147;\n\nSELECT * FROM crm_configurations WHERE id = 692;\nSELECT\n CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,\n u.email,\n sa.*,\n t.owner_id FROM social_accounts sa\nJOIN users u on u.id = sa.sociable_id\nJOIN teams t on t.id = u.team_id\nWHERE u.team_id = 711 and sa.provider = 'salesforce';\n\nSELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;\n\nselect * from leads;\n\nselect * from calendars;\n\nSELECT\n t.id AS team_id,\n t.name,\n LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain\nFROM teams t\nJOIN users u ON u.team_id = t.id\nJOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'\nLEFT JOIN team_domains td\n ON td.team_id = t.id\n AND td.deleted_at IS NULL\n AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))\nGROUP BY t.id, t.name, calendar_domain\nORDER BY t.name, calendar_domain;\n\nselect * from users u join calendars c on c.user_id = u.id\nwhere u.team_id = 882;\n\n\nselect * from activities where id = 74049485; # team 563 crm 537\nselect * from activities where id = 73272382; # team 563 crm 537\nselect * from activities where id = 64400389; # team 563 crm 537\nselect * from activities where id = 58081273; # team 563 crm 537\nselect * from activities where id = 54520297; # team 563 crm 537\nselect * from participants where activity_id = 58081273;\n\nselect * from activities where crm_configuration_id = 537 and provider = 'aircall'\nand account_id = 19003658 order by updated_at desc;\n\nselect * from contacts where crm_configuration_id = 537 and id = 35957759;\nselect * from accounts where crm_configuration_id = 537 and id = 19003658;\n\nselect * from automated_report_results where id = 1976;\nselect * from automated_reports where id = 583;\nselect * from activity_searches where id = 87714;\nselect * from activity_search_filters where activity_search_id = 87714;\n\nSELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid\nor uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;\n\nSELECT * FROM crm_configurations WHERE provider = 'hubspot';\nselect * from rate_limits;\n\nselect * from automated_report_results where media_type = 'pdf' and status = 2\nand id IN (18, 1872);\nselect * from automated_reports where id = 54;\nSELECT * FROM users WHERE id IN (24623,29443,29613);\n\nSELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;\n\nselect * from text_relays where created_at > '2026-05-01'\n# and id IN (32415, 32416);\nand id = 32412;\n\nselect * from users where team_id = 2 and email like '%scott%' and id = 29510;\n\nSELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436","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},{"role":"AXStaticText","text":"app ~/jiminny/app, folder","depth":6,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".circleci, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".cursor, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".github","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".sonarlint, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".vscode, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".windsurf, folder","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"app, sources root","depth":7,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Actions, folder","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InviteUserToTeamAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"MarkUserAsOnboardableAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SyncRecordingFlagsAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateTeamMemberAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"UpdateUserRolesAction.php, class","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Component","depth":8,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Acl","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActionItems","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Activity","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityAnalytics","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivitySearch","depth":9,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"EventSubscriber, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"FilterDefinition, folder","depth":10,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealInsights, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Security, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"TeamInsights, folder","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityActualDate.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityChannel.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityDurationRange.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityFilter.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityPlaylistIn.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityProviderIn.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityRecorded.php","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityRecordingStopped.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityScheduledDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityStatusIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityType.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ActivityUpdatedDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AiCallScoreFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"AutoScoreFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ClosedDealsFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedbackAverageScore.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CoachingFeedbackCoachUserIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CommentCountRange.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CrmFieldCollection.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CurrentStage.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Customer.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CustomerMonologueDuration.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"CustomerQuestionCount.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealAge.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealCloseDate.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"DealValue.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"EngagingQuestionCount.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ExternalId.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HasPendingAiCrmNotes.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HasTopicTriggersFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"HasTranscription.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IndexedAtFrom.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InputTypeEnum.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"InsightfulQuestionCount.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LanguageFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LoggedToCrm.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"NudgeRunId.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OnlyActiveUsers.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserGroupIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserTeamIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserUserIn.php, class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"OrganiserUserNotIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ParticipantUserIn.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PartnerFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PatienceRange.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PlaybackTopicFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ProviderFilterDefinition.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ShowInternalExternalActivitiesFilter.php, final class","depth":11,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SortBy.php, final class","depth":11,"on_screen":false,"role_description":"text"}]...
|
5263730141974970777
|
1065678636275086925
|
click
|
accessibility
|
NULL
|
Project: faVsco.js, menu
JY-20891-improve-sms-text Project: faVsco.js, menu
JY-20891-improve-sms-text-relays, 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
10
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Component\ElasticSearch\Service;
use ChaseConey\LaravelDatadogHelper\Datadog;
use Elastica;
use Elastica\Document;
use Elastica\Query;
use Generator;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\LazyCollection;
use Jiminny\Component\ElasticSearch\Client;
use Jiminny\Component\ElasticSearch\Contract\Searchable;
use Jiminny\Component\ElasticSearch\ModelFiller;
use Jiminny\Models\Activity;
/**
* Class Search
*
* @package Jiminny\Component\ElasticSearch\Service
*/
class Search
{
/**
* @var Client
*/
private $client;
/**
* @var ModelFiller\Elastica
*/
private $modelFiller;
public function __construct(Client $client, ModelFiller\Elastica $modelFiller)
{
$this->client = $client;
$this->modelFiller = $modelFiller;
}
public function updateDocument(Searchable $model): self
{
return $this->updateDocumentCollection($model, new Collection([$model]));
}
public function updateDocumentCollection(
Searchable $model,
Collection $collection,
int $chunkSize = 10,
?callable $callback = null,
): self {
if ($collection->count() === 0) {
return $this;
}
$documentType = $this->client->createIndex($model->getIndex());
$collection
->chunk($chunkSize)
->each(static function (Collection $collection) use ($documentType, $callback): void {
$documents = $collection->map(static function (Searchable $model): Document {
return new Document((string) $model->getId(), $model->getIndexableAttributes());
});
$documentType->addDocuments($documents->all());
if ($callback !== null) {
$callback($collection, $documents);
}
gc_collect_cycles();
});
return $this;
}
private function createSearch(Query $query, Searchable|string $modelOrIndex): Elastica\Search
{
if (request() && request()->has('debug')) {
Log::info('Debug ES query: ', [
'debug' => request()->get('debug'),
'userId' => request()->user()?->id ?? 'anonymous',
'userUuid' => request()->user()?->getIdString() ?? 'anonymous',
'query' => json_encode($query->toArray(), JSON_THROW_ON_ERROR),
'url' => request()->fullUrl(),
]);
}
return $this->client
->createIndex($modelOrIndex instanceof Searchable ? $modelOrIndex->getIndex() : $modelOrIndex)
->createSearch($query);
}
public function scroll(Query $query, Searchable|string $model): Elastica\Scroll
{
return new Elastica\Scroll($this->createSearch($query, $model));
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*
* @return LazyCollection<int, Document>
*/
public function scrollOverDocuments(Query $query, Searchable|string $modelOrIndex): LazyCollection
{
return LazyCollection::make(function () use ($query, $modelOrIndex): Generator {
foreach ($this->scroll($query, $modelOrIndex) as $resultSet) {
foreach ($resultSet->getDocuments() as $document) {
yield $document;
}
}
});
}
/**
* @param Searchable|string $modelOrIndex usage of model is deprecated
*/
public function search(Query $query, Searchable|string $modelOrIndex, ?string $queryName = null): Elastica\ResultSet
{
Datadog::increment('jiminny.es.search', 1, ['query' => $queryName ?? '']);
$before = microtime(true);
$result = $this->createSearch($query, $modelOrIndex)->search();
$after = microtime(true);
Datadog::timing('jiminny.es.search.time', (int) (($after - $before) * 1000), 1, ['query' => $queryName ?? '']);
return $result;
}
/**
* @TODO use LazyCollection
*
* @return Collection<int, Activity>
*/
public function getQueryDocuments(Query $query, Model&Searchable $model, ?string $queryName = null): Collection
{
return $this
->hydrateCollection($this->search($query, $model, $queryName)->getDocuments(), $model)
->collect();
}
/**
* @return array{totalHits: int, results: Collection<int, Activity>}
*/
public function getQueryDocumentsPaginated(Query $query, Model&Searchable $model, ?string $queryName = null): array
{
$search = $this->search($query, $model, $queryName);
/**
* @TODO Use value-object instead.
*/
return [
'totalHits' => $search->getTotalHits(),
'results' => $this
->hydrateCollection($search->getDocuments(), $model)
->collect(),
];
}
private function hydrateCollection(array $collection, Model&Searchable $model): LazyCollection
{
return LazyCollection::make($collection)
->map(function (Document $document) use ($model): Searchable {
return $this->hydrateModel($document, $model);
});
}
private function hydrateModel(Document $document, Model&Searchable $model): Model&Searchable
{
$attributes = $document->getData();
$attributes['id'] = $document->getId();
/** @var Searchable&Model */
return $this->modelFiller->newFromBuilderRecursive($model, $attributes);
}
}
Execute
Explain Plan
Browse Query History
View Parameters
Open Query Execution Settings…
In-Editor Results
Tx: Auto
Cancel Running Statements
Playground
jiminny
Sync Changes
Hide This Notification
Code changed:
Hide
40
1
40
65
Previous Highlighted Error
Next Highlighted Error
SELECT * FROM teams WHERE name LIKE '%litify%'; # 1069, 994, 24993
SELECT * FROM users WHERE id = 25061;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 994;
SELECT * FROM crm_profiles WHERE user_id = 25061;
select * from crm_configurations where id = 834;
SELECT * FROM teams WHERE id = 882;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations WHERE provider = 'hubspot' and crm_provider_id = 7270388;
SELECT * FROM contacts where crm_configuration_id = 834;
SELECT * FROM opportunities WHERE team_id = 933
# AND crm_provider_id IN ('20131586060','46017317898','52543911090','53451356564','54101251892','54323768459');
AND id IN (8482561,18352941,19042734,19232139,19445140,19472541);
SELECT * FROM opportunity_contacts
WHERE opportunity_id IN (8482561,18352941,19042734,19232139,19445140,19472541);
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 485; #
SELECT * FROM opportunities WHERE team_id = 933 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
select crm.provider, l.* from leads l join crm_configurations crm on l.crm_configuration_id = crm.id
where crm.provider NOT IN ('salesforce', 'integration-app', 'bullhorn', 'copper')
# and l.converted_at IS NOT NULL
;
# [PASSWORD_DOTS]
SELECT * FROM activities a WHERE type IN ('email-inbound', 'email-outbound')
and opportunity_id IS NULL
order by id desc;
SELECT * FROM teams WHERE id = 604; # 598
SELECT * FROM activities WHERE id = 74410828; # [EMAIL]
SELECT * FROM accounts WHERE id = 20068382;
SELECT * FROM accounts WHERE id = 35186038;
SELECT * FROM contacts WHERE team_id = 852 and updated_at > '2026-01-23 12:30:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 559 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('cb6342b6-a183-401c-b0af-ede92b2ae763') = uuid;
select * from sidekick_settings where team_id = 781;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 26651871; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 7562435;
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8420347; # opflit 2100
SELECT * FROM crm_layouts WHERE crm_configuration_id = 711;
SELECT * FROM activities where crm_configuration_id = 711 and crm_provider_id IS NULL
and is_internal = 0 and status = 'completed'
order by id desc;
SELECT * FROM crm_layout_entities
WHERE crm_layout_id IN (2352, 2353);
;
SELECT * FROM crm_configurations where provider = 'hubspot' and id = 530;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 556 and sa.provider = 'hubspot';
SELECT * FROM activities WHERE uuid_to_bin('c6ca4b22-7738-4563-a95d-b8a9598924ae') = uuid;
SELECT * FROM activities WHERE uuid_to_bin('442abb2b-28bd-4be8-9c25-19e9bf02766d') = uuid;
select * from contacts
where crm_configuration_id = 530
and crm_provider_id = 872252;
select * from activities where crm_configuration_id = 530
and user_id = 14343 and type like '%softphone%'
and created_at between '2026-01-28 15:00:00' and '2026-01-28 15:10:00';
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 25666868; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id = 8646335; # Teya
SELECT * FROM crm_configurations where provider = 'hubspot' and crm_provider_id IN (5933397);
SELECT t.name, t.id, t.owner_id, c.id, c.provider, c.crm_base_url FROM teams t
JOIN crm_configurations c ON t.id = c.team_id
WHERE t.status = 'active';
SELECT * FROM teams where id = 1091;
SELECT * FROM crm_configurations where team_id = 1091;
SELECT * FROM activity_providers where team_id = 1091;
SELECT * FROM activities where crm_configuration_id = 1024 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT * FROM teams WHERE name LIKE '%Leadventure%';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1091 and sa.provider = 'salesforce';
SELECT * FROM teams WHERE name LIKE '%Wilson%'; # 862, 812
SELECT * FROM teams where id = 862;
SELECT * FROM crm_configurations where team_id = 862;
SELECT * FROM activity_providers where team_id = 862;
SELECT * FROM activities where crm_configuration_id = 812 and type IN ('softphone', 'softphone-outbound')
and provider NOT IN ('hubspot', 'aircall')
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by id desc;
SELECT t.id, crm.id, crm.provider, ap.* FROM teams t
join crm_configurations crm on t.id = crm.team_id
join activity_providers ap on t.id = ap.team_id
where t.status = 'active' and ap.is_enabled = 1
and crm.provider = 'hubspot'
and ap.provider NOT IN ('hubspot', 'aircall', 'uploader', 'gong', 'twilio', 'zoom-bot', 'google-meet', 'ms-teams',
'outreach', 'close', 'ringcentral', 'dialpad', 'zoom-phone');
SELECT * FROM teams where id = 1068;
SELECT * FROM crm_configurations where team_id = 1068;
SELECT * FROM activity_providers where team_id = 1068;
SELECT * FROM activities a
where crm_configuration_id = 993 and type IN ('softphone', 'softphone-outbound')
and a.provider NOT IN ('hubspot', 'uploader', 'gong', 'twilio', 'google-meet', 'ms-teams','close'
)
# and telephony_provider_id = '019c1131-a22f-4792-b9ea-20adf6a02ed0'
order by a.id desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1068 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 882; # 933 - GoGlobal , portalId: 6017093
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 933 and updated_at > '2026-02-06 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 933 and sa.provider = 'hubspot';
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 834; # 882 - AnyVan , portalId: 5468262
SELECT * FROM contacts WHERE crm_configuration_id = 834 and updated_at > '2026-03-30 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and updated_at > '2026-03-04 08:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 882 and sa.provider = 'hubspot';
select * from crm_layouts where crm_configuration_id = 834;
select * from crm_layout_entities where crm_layout_id = 2780;
select * from crm_fields where id IN (321153,321192,321193,321194);
SELECT * FROM opportunities WHERE crm_configuration_id = 834 and id = 10993426;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 988; # 1057 - Teya (543ce4f4-168c-4571-91ea-5b35c253f06f) , portalId: 26651871
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1057 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1057 and sa.provider = 'hubspot';
SELECT * FROM crm_configurations where id = 533; # 559 - Connectd , portalId: 6710988
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 559 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 801; # 852 - Rise Vision , portalId: 2700250
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 852 and updated_at > '2026-02-04 00:00:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 962; # 1034 - evergrowth.io , portalId: 143180990
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1034 and updated_at > '2026-02-04 00:00:00' order by updated_at desc;
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 1037; # 1102 - Jibble , portalId: 6649755
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1102 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 8
SELECT * FROM crm_configurations where id = 1015; # 1049 - Travefy , portalId: 48904401
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1049 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 20
SELECT * FROM crm_configurations where id = 64; # 70 - SalaryFinance , portalId: 3404115
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 70 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 6th last
SELECT * FROM crm_configurations where id = 802; # 853 - Street Group , portalId: 7658438
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 853 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 10
SELECT * FROM crm_configurations where id = 872; # 921 - In Professional Development , portalId: 9238273
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 921 and updated_at > '2026-02-04 12:30:00' order by updated_at desc; # 2
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 550; # 576 - SeedLegals , portalId: 3028661
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 576 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 989; # 1058 - rtaoutdoor.com , portalId: 22371204
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1058 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 896; # 946 - Mintago , portalId: 6621281
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 946 and updated_at > '2026-02-05 14:00:00' order by updated_at desc;
SELECT * FROM crm_configurations where id = 617; # 641 - PCS , portalId: 5244937
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 641 and updated_at > '2026-02-05 14:00:00' order by updated_at desc; # 7th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where id = 649; # 670 - Eventeny , portalId: 4492849
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-18 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 670 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; #
SELECT * FROM crm_configurations where id = 48; # 51 - CleanCloud , portalId: 4373137
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-03-04 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 51 and updated_at > '2026-02-09 08:00:00' order by updated_at desc;
select * from users where team_id = 51; # 7783
SELECT * FROM groups WHERE uuid_to_bin('8a8d2cb6-8b55-4fa3-8b5c-5f0e3d8de59a') = uuid; # 1130
select * from activity_searches where user_id = 7783;
select * from activity_search_filters where activity_search_id IN (32291, 32292);
SELECT asf.activity_search_id, asf.id, asf.value
FROM activity_search_filters asf
WHERE asf.filter = 'group_id'
AND asf.value IN (
SELECT CONCAT(
HEX(SUBSTR(uuid, 5, 4)), '-',
HEX(SUBSTR(uuid, 3, 2)), '-',
HEX(SUBSTR(uuid, 1, 2)), '-',
HEX(SUBSTR(uuid, 9, 2)), '-',
HEX(SUBSTR(uuid, 11))
)
FROM groups
WHERE deleted_at IS NOT NULL
);
SELECT * FROM crm_configurations where id = 272; # 290 - Bonham & Brook , portalId: 5705856
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-05 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 290 and updated_at > '2026-02-09 08:00:00' order by updated_at desc; # 6th
# [PASSWORD_DOTS]
SELECT * FROM crm_configurations where provider = 'hubspot';
SELECT * FROM crm_configurations where id = 1056; # 1119 - Chromatic , portalId: 45602133
SELECT * FROM opportunities WHERE team_id = 1119 and remotely_created_at > '2026-02-01 00:00:00' order by updated_at desc;
SELECT * FROM opportunities WHERE team_id = 1119 and updated_at > '2026-02-09 09:00:00' order by updated_at desc; # null
# [PASSWORD_DOTS]
select * from contacts where crm_provider_id = '003Uu00000ojD4NIAU';
select
cp.*
# DISTINCT t.id
# cp.id, cp.user_id, t.id, cp.crm_configuration_id, cp.contact_fields
FROM crm_profiles cp
JOIN crm_configurations crm on crm.id = cp.crm_configuration_id
JOIN users u on u.id = cp.user_id
JOIN teams t ON t.id = crm.team_id
WHERE crm.provider = 'salesforce' and t.status = 'active'
and cp.archived_at IS NULL and u.deleted_at IS NULL
and t.id NOT IN (1093)
and t.id = 2
and cp.contact_fields IS NULL;
# and c.crm_provider_id = '003Uu00000ojD4NIAU';
SELECT * FROM users WHERE id = 26484;
SELECT * FROM crm_profiles WHERE user_id = 26484;
SELECT * FROM social_accounts WHERE sociable_id = 26484;
SELECT * FROM crm_configurations where provider = 'salesforce';
select * from users where id IN (10022, 10403);
select * from users where team_id IN (526);
select * from teams where id IN (526, 532);
select * from crm_configurations where id IN (500, 516);
select * from crm_profiles where crm_configuration_id IN (500, 516) and user_id IN (10022, 10403);
select * from contacts where crm_configuration_id IN (500, 516) and crm_provider_id = '003Uu00000ojD4NIAU';
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 526 and sa.provider = 'salesforce';
select * from team_settings where team_id IN (526, 532);
select * from users where id IN (22824);
select * from crm_profiles where crm_configuration_id IN (1026);
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1093 and sa.provider = 'salesforce';
select * from teams where id = 1099;
select * from users where id = 29643
select * from activity_processing_states;
SELECT * FROM teams where name LIKE '%Fare%'; # 233
SELECT * FROM opportunities where crm_configuration_id = 215
# and crm_provider_id = 'oppo_ogESZf2P50nDrd1nGPvKDXeA6sSaTN5v51Lp4ayVzKR'
;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1088 and sa.provider = 'hubspot';
SELECT * FROM teams order by updated_at DESC
SELECT * FROM crm_configurations WHERE id = 1019; # SimpleConsign 1088 - no social account
select * from crm_configurations where provider = 'pipedrive';
select * from teams where id = 957;
select * from crm_configurations where id = 957;
SELECT * FROM teams WHERE name LIKE '%Prolific%'; # 544, 518, 10743
SELECT * FROM opportunities where crm_configuration_id = 518 order by id desc;
select * from users where team_id = 1; # 26726 - Gabriela Dureva
SELECT * FROM opportunities where user_id = 26726; # 16834447 - Prolific
select * from activities where user_id = 26726 order by id desc;
select * from contacts where crm_configuration_id = 1
and email IN ('[EMAIL]', '[EMAIL]'); # 2094416, 2093620
SELECT * FROM contacts WHERE id = 6284931;
SELECT p.* FROM activities a JOIN participants p ON a.id = p.activity_id
WHERE a.user_id = 26726 and p.lead_id IN (2094416, 2093620) and a.created_at > '2026-01-01 00:00:00' order by p.email;
select * from activities where id IN (75509259,75509261,75509261,75511034,75026464,75517602,75517605);
select * from crm_configurations where id = 1;
43801692-1aeb-32ce-acba-5b80a479701a
44c3c9cf-6f5e-75f3-8179-bc9f75dd2b1b
405975c0-b3d0-7aaa-821f-09d59cae6dd1
4caf848d-4bed-2299-b248-7788d41f9fca
49bedc3f-f196-eef3-89c3-dea6a3b4aa63
43420989-a09d-b8f8-9806-c8bbf7a02aac
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
SELECT * FROM activities WHERE id = 75461988;
SELECT * FROM activities WHERE uuid_to_bin('d6c5052e-e972-49e9-8912-26f2f7d6c5f6') = uuid;
select * from contacts where id = 17900517;
select * from contact_roles cr join crm_configurations crm on cr.crm_configuration_id = crm.id
where crm.provider != 'salesforce';
select * from users where id = 21047;
SELECT * FROM crm_configurations WHERE id = 892;
SELECT * FROM teams WHERE id = 942;
select * from opportunities where team_id = 942 order by updated_at desc;
select * from contacts where team_id = 942 order by updated_at desc;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 942 and sa.provider = 'hubspot';
SELECT * FROM opportunities where team_id = 1 and crm_provider_id IN ('006Pq00000NeH6XIAV', '006Pq000007z8kdIAA'); # 10697889, 6621430
SELECT * FROM crm_configurations WHERE id = 1;
SELECT * FROM teams WHERE crm_id = 1;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1 and sa.provider = 'salesforce';
select id, user_id, opportunity_fields from crm_profiles where crm_configuration_id = 1
SELECT * FROM opportunities where team_id = 1 order by updated_at desc; # 10697889, 6621430
select * from teams where id = 852;
select * from groups where id = 2286;
select * from sidekick_settings where team_id = 852;
select * from default_activity_types where team_id = 852;
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id AND p.id IS NULL -- no profile
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active' -- team is active
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1 AND u.deleted_at IS NULL
AND u.crm_required = 1
AND u.team_id = 1
ORDER BY u.team_id;
SELECT * FROM crm_profiles cp where cp.crm_configuration_id = 1 and cp.user_id IN (
18481
);
SELECT cc.provider, cc.id, p.id, u.*
FROM users u
LEFT JOIN crm_profiles p ON u.id = p.user_id
INNER JOIN teams t ON u.team_id = t.id AND t.status = 'active'
INNER JOIN crm_configurations cc ON t.crm_id = cc.id
WHERE u.status = 1
AND u.deleted_at IS NULL
AND u.crm_required = 1
# AND u.team_id = 1
AND p.id IS NULL -- Move this condition to WHERE clause
ORDER BY u.team_id;
SELECT * FROM opportunities WHERE id = 20002609;
select * from teams where id = 1122; # Velatir, 29953 - [EMAIL]
select * from crm_configurations where id = 1060;
select * from crm_layouts where crm_configuration_id = 1060;
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3596;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 1122 and sa.provider = 'hubspot';
select * from opportunities where team_id = 1122 order by updated_at desc;
select * from crm_field_data where object_type = 'contact';
SELECT * FROM activities WHERE uuid_to_bin('374fc8ed-3315-4c9f-9b25-318b7fd2928f') = uuid; # 76584262
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 248 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles where user_id = 24115; # 005QF000002CswMYAS
SELECT * FROM users where id = 24115;
SELECT * FROM accounts where id = 4002896;
SELECT * FROM teams WHERE name LIKE '%adswerve%';
SELECT * FROM opportunities where crm_configuration_id = 230 AND crm_provider_id IN ("0069N000003GIQ9QAO","0061r000019yGP9AAM","0066900001S2KWlAAN","0066900001TDpj2AAD","0066900001b8uEwAAI","0069N000001rQi0QAE","006QF00000KD40mYAD","006QF00000LzpRJYAZ","0069N000002uomtQAA","0069N000002xlMLQAY","0066900001NV6ubAAD","0061r00001HJp45AAD","006QF00000uTlUoYAK","006QF00000v0bZqYAI");
SELECT * FROM opportunities WHERE crm_configuration_id = 230 AND crm_provider_id = '0069N000003GIQ9QAO'; # 6272203
SELECT u.id, u.email, ac.name, a.* FROM activities a
JOIN users u ON a.user_id = u.id
JOIN accounts ac ON a.account_id = ac.id
WHERE
uuid_to_bin('e3269598-b562-44fb-b5e9-9d2694dc63e0') = a.uuid or
uuid_to_bin('66ddc3ab-4e15-45aa-af0c-248c1eece593') = a.uuid or
uuid_to_bin('826bd328-e1cc-4213-b8d8-572454cacc07') = a.uuid;
select * from users where id = 5825;
SELECT * FROM activities WHERE uuid_to_bin('e56aa2e8-231a-421b-ab1f-cb38ed2bf573') = uuid;
select * from activities where uuid_to_bin('91e13b2f-2d1b-45f8-b1fd-1141b6563782') = uuid;
19594, 862
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 862 and sa.provider = 'salesforce';
select * from automated_reports where id = 36;
select ar.frequency, r.*, ar.* from automated_report_results r
join automated_reports ar on r.report_id = ar.id
where ar.frequency != 'one_off';
select s.* from activity_searches s join users u ON s.user_id = u.id where u.team_id = 882;
select * from nudges n where n.activity_search_id
select * from teams where created_at > '2026-03-09';
SELECT * FROM crm_layouts WHERE crm_configuration_id = 1065; # 1065
SELECT * FROM crm_layout_entities WHERE crm_layout_id = 3617;
select * from users where team_id = 1 and name like '%Lukas%'; # 7160
SELECT * FROM teams WHERE id = 575;
select * from opportunities where team_id = 575;
SELECT * FROM teams WHERE name LIKE '%Integrum ESG%'; # 1126, 1065,
select * from opportunities where team_id = 1126;
SELECT * FROM teams WHERE name LIKE '%Base%'; # 1125, 1063,
select * from opportunities where team_id = 1125;
select * from contacts c
where c.team_id = 882;
SELECT * FROM activities WHERE id = 76822967;
SELECT * FROM crm_profiles WHERE user_id = 15440;
SELECT * FROM crm_profiles WHERE crm_configuration_id = 555;
SELECT * FROM crm_configurations WHERE id = 555;
SELECT * FROM users WHERE id = 15440; # team. 581, gr. 15440, pl. 3911, act. field 162182
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 581 and sa.provider = 'salesforce';
SELECT * FROM automated_report_results order by id desc;
select * from features;
select * from team_features where feature_id = 40;
select * from teams where id = 556;
select * from automated_reports;
where id = 54; # 4fdd41f6-dcf0-30d0-b339-7345381b6044 , ["pdf","podcast"]
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from automated_report_results order by id desc;
SELECT * FROM automated_report_results WHERE id = 1919;
select * from automated_report_results WHERE report_id = 54;
select * from opportunities where id = 7594349;
SELECT * FROM teams WHERE name LIKE '%Les%'; # 711, 692, 16067 - [EMAIL]
select * from playbooks where team_id = 711; # event 226147
SELECT * FROM playbook_categories WHERE playbook_id = 5515;
SELECT * FROM crm_fields WHERE crm_configuration_id = 692 and object_type = 'event';
SELECT * FROM crm_fields WHERE id = 226147;
SELECT * FROM crm_field_values WHERE crm_field_id = 226147;
SELECT * FROM crm_configurations WHERE id = 692;
SELECT
CONCAT(u.id, CASE WHEN u.id = t.owner_id THEN ' (owner)' ELSE '' END) AS user_id,
u.email,
sa.*,
t.owner_id FROM social_accounts sa
JOIN users u on u.id = sa.sociable_id
JOIN teams t on t.id = u.team_id
WHERE u.team_id = 711 and sa.provider = 'salesforce';
SELECT * FROM crm_profiles cp JOIN users u on u.id = cp.user_id WHERE u.team_id = 711;
select * from leads;
select * from calendars;
SELECT
t.id AS team_id,
t.name,
LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1)) AS calendar_domain
FROM teams t
JOIN users u ON u.team_id = t.id
JOIN calendars c ON c.user_id = u.id AND c.status = 'active' AND c.calendar_provider_id LIKE '%@%'
LEFT JOIN team_domains td
ON td.team_id = t.id
AND td.deleted_at IS NULL
AND td.domain = LOWER(SUBSTRING_INDEX(c.calendar_provider_id, '@', -1))
GROUP BY t.id, t.name, calendar_domain
ORDER BY t.name, calendar_domain;
select * from users u join calendars c on c.user_id = u.id
where u.team_id = 882;
select * from activities where id = 74049485; # team 563 crm 537
select * from activities where id = 73272382; # team 563 crm 537
select * from activities where id = 64400389; # team 563 crm 537
select * from activities where id = 58081273; # team 563 crm 537
select * from activities where id = 54520297; # team 563 crm 537
select * from participants where activity_id = 58081273;
select * from activities where crm_configuration_id = 537 and provider = 'aircall'
and account_id = 19003658 order by updated_at desc;
select * from contacts where crm_configuration_id = 537 and id = 35957759;
select * from accounts where crm_configuration_id = 537 and id = 19003658;
select * from automated_report_results where id = 1976;
select * from automated_reports where id = 583;
select * from activity_searches where id = 87714;
select * from activity_search_filters where activity_search_id = 87714;
SELECT * FROM activities WHERE uuid_to_bin('8827f672-202d-4162-9d04-73ff5f0566a9') = uuid
or uuid_to_bin('47842446-af51-4bcb-854f-cc6560290101') = uuid;
SELECT * FROM crm_configurations WHERE provider = 'hubspot';
select * from rate_limits;
select * from automated_report_results where media_type = 'pdf' and status = 2
and id IN (18, 1872);
select * from automated_reports where id = 54;
SELECT * FROM users WHERE id IN (24623,29443,29613);
SELECT * FROM automated_report_results WHERE uuid_to_bin('822fa41b-afd3-43a9-a248-86b0e36f3131') = uuid;
select * from text_relays where created_at > '2026-05-01'
# and id IN (32415, 32416);
and id = 32412;
select * from users where team_id = 2 and email like '%scott%' and id = 29510;
SELECT * FROM activities WHERE uuid_to_bin('67cebfc2-ed56-44a2-8c68-7a0286ed8618') = uuid; # 79763436
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
InviteUserToTeamAction.php, class
MarkUserAsOnboardableAction.php, class
SyncRecordingFlagsAction.php, class
UpdateTeamMemberAction.php, class
UpdateUserRolesAction.php, class
Component
Acl
ActionItems
Activity
ActivityAnalytics
ActivitySearch
EventSubscriber, folder
FilterDefinition, folder
DealInsights, folder
Security, folder
TeamInsights, folder
ActivityActualDate.php
ActivityChannel.php
ActivityDurationRange.php
ActivityFilter.php
ActivityPlaylistIn.php
ActivityProviderIn.php
ActivityRecorded.php
ActivityRecordingStopped.php, final class
ActivityScheduledDate.php, final class
ActivityStatusIn.php, class
ActivityType.php, final class
ActivityUpdatedDate.php, final class
AiCallScoreFilter.php, final class
AutoScoreFilter.php, final class
ClosedDealsFilter.php, final class
CoachingFeedbackAverageScore.php, final class
CoachingFeedbackCoachUserIn.php, final class
CommentCountRange.php, final class
CrmFieldCollection.php, final class
CurrentStage.php, final class
Customer.php, final class
CustomerMonologueDuration.php, final class
CustomerQuestionCount.php, final class
DealAge.php, final class
DealCloseDate.php, final class
DealValue.php, final class
EngagingQuestionCount.php, final class
ExternalId.php, final class
HasPendingAiCrmNotes.php, final class
HasTopicTriggersFilterDefinition.php, final class
HasTranscription.php, final class
IndexedAtFrom.php, final class
InputTypeEnum.php, final class
InsightfulQuestionCount.php, final class
LanguageFilterDefinition.php, final class
LoggedToCrm.php, final class
NudgeRunId.php, final class
OnlyActiveUsers.php, final class
OrganiserGroupIn.php, class
OrganiserTeamIn.php, final class
OrganiserUserIn.php, class
OrganiserUserNotIn.php, final class
ParticipantUserIn.php, final class
PartnerFilterDefinition.php, final class
PatienceRange.php, final class
PlaybackTopicFilterDefinition.php, final class
ProviderFilterDefinition.php, final class
ShowInternalExternalActivitiesFilter.php, final class
SortBy.php, final class...
|
NULL
|
NULL
|
NULL
|
NULL
|