Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to new summary data #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/yii-dev-panel-sdk/src/Helper/collectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum CollectorsMap {
ConsoleAppInfoCollector = 'Yiisoft\\Yii\\Debug\\Collector\\Console\\ConsoleAppInfoCollector',
WebAppInfoCollector = 'Yiisoft\\Yii\\Debug\\Collector\\Web\\WebAppInfoCollector',
CommandCollector = 'Yiisoft\\Yii\\Debug\\Collector\\Console\\CommandCollector',
MiddlewareCollector = 'Yiisoft\\Yii\\Debug\\Collector\\Web\\MiddlewareCollector',
MiddlewareCollector = 'Yiisoft\\Middleware\\Dispatcher\\Debug\\MiddlewareCollector ',
RequestCollector = 'Yiisoft\\Yii\\Debug\\Collector\\Web\\RequestCollector',
MailerCollector = 'Yiisoft\\Mailer\\Debug\\MailerCollector',
VarDumperCollector = 'Yiisoft\\Yii\\Debug\\Collector\\VarDumperCollector',
Expand Down
34 changes: 17 additions & 17 deletions packages/yii-dev-panel-sdk/src/Helper/collectorsTotal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ import {CollectorsMap} from '@yiisoft/yii-dev-panel-sdk/Helper/collectors';
export const getCollectedCountByCollector = (collector: CollectorsMap, data: DebugEntry): number | undefined => {
switch (collector) {
case CollectorsMap.AssetCollector:
return Number(data.asset?.bundles?.total);
return Number(data.summary[CollectorsMap.AssetCollector]?.asset?.bundles?.total);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also types should be changed

case CollectorsMap.DatabaseCollector:
return Number(data.db?.queries?.total) + Number(data.db?.transactions?.total);
return Number(data.summary[CollectorsMap.DatabaseCollector]?.db?.queries?.total) + Number(data.summary[CollectorsMap.DatabaseCollector]?.db?.transactions?.total);
case CollectorsMap.ExceptionCollector:
return Object.values(data.exception ?? []).length > 0 ? 1 : 0;
return Object.values(data.summary[CollectorsMap.ExceptionCollector] ?? []).length > 0 ? 1 : 0;
case CollectorsMap.EventCollector:
return Number(data.event?.total);
return Number(data.summary[CollectorsMap.EventCollector]?.total);
case CollectorsMap.LogCollector:
return Number(data.logger?.total);
return Number(data.summary[CollectorsMap.LogCollector]?.total);
case CollectorsMap.ServiceCollector:
return Number(data.service?.total);
return Number(data.summary[CollectorsMap.ServiceCollector]?.total);
case CollectorsMap.VarDumperCollector:
return Number(data['var-dumper']?.total);
return Number(data.summary[CollectorsMap.VarDumperCollector]?.total);
case CollectorsMap.ValidatorCollector:
return Number(data.validator?.total);
return Number(data.summary[CollectorsMap.ValidatorCollector]?.validator?.total);
case CollectorsMap.MiddlewareCollector:
return Number(data.middleware?.total);
return Number(data.summary[CollectorsMap.MiddlewareCollector]?.middleware?.total);
case CollectorsMap.QueueCollector:
return (
Number(data.queue?.countPushes) +
Number(data.queue?.countStatuses) +
Number(data.queue?.countProcessingMessages)
Number(data.summary[CollectorsMap.QueueCollector]?.queue?.countPushes) +
Number(data.summary[CollectorsMap.QueueCollector]?.queue?.countStatuses) +
Number(data.summary[CollectorsMap.QueueCollector]?.queue?.countProcessingMessages)
);
case CollectorsMap.HttpClientCollector:
return Number(data.http?.count);
return Number(data.summary[CollectorsMap.HttpClientCollector]?.count);
case CollectorsMap.HttpStreamCollector:
return Number(data.http_stream?.length);
return Number(data.summary[CollectorsMap.HttpStreamCollector]?.streams.length);
case CollectorsMap.MailerCollector:
return Number(data.mailer?.total);
return Number(data.summary[CollectorsMap.MailerCollector]?.mailer?.total);
case CollectorsMap.FilesystemStreamCollector:
return Object.values(data.fs_stream ?? []).reduce((acc, value) => acc + value, 0);
return Object.values(data.summary[CollectorsMap.FilesystemStreamCollector]?.streams ?? []).reduce((acc, value) => acc + value, 0);
case CollectorsMap.ConsoleAppInfoCollector:
return 0;
case CollectorsMap.TimelineCollector:
return Number(data.timeline?.total);
return Number(data.summary[CollectorsMap.TimelineCollector]?.total);
default:
return undefined;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/yii-dev-panel-sdk/src/Helper/debugEntry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {DebugEntry} from '@yiisoft/yii-dev-panel-sdk/API/Debug/Debug';
import {CollectorsMap} from "@yiisoft/yii-dev-panel-sdk/Helper/collectors";

export function isDebugEntryAboutConsole(entry: DebugEntry): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "summary" to the DebugEntry type

return entry && 'console' in entry;
return entry && CollectorsMap.CommandCollector in entry.summary;
}

export function isDebugEntryAboutWeb(entry: DebugEntry): boolean {
return entry && 'web' in entry;
return entry && CollectorsMap.WebAppInfoCollector in entry.summary;
}
12 changes: 6 additions & 6 deletions packages/yii-dev-panel/src/Module/Debug/Pages/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ const DebugEntryAutocomplete = ({data, onChange}: DebugEntryAutocompleteProps) =

const renderLabel = useCallback((entry: DebugEntry): string => {
if (isDebugEntryAboutConsole(entry)) {
return [entry.command?.exitCode === 0 ? '[OK]' : '[ERROR]', entry.command?.input].filter(Boolean).join(' ');
return [entry.summary[CollectorsMap.CommandCollector]?.exitCode === 0 ? '[OK]' : '[ERROR]', entry.summary[CollectorsMap.CommandCollector]?.input].filter(Boolean).join(' ');
}
if (isDebugEntryAboutWeb(entry)) {
return ['[' + entry.response.statusCode + ']', entry.request.method, entry.request.path].join(' ');
return ['[' + entry.summary[CollectorsMap.RequestCollector]?.response.statusCode + ']', entry.summary[CollectorsMap.RequestCollector]?.request.method, entry.summary[CollectorsMap.RequestCollector]?.request.path].join(' ');
}
return entry.id;
}, []);
Expand All @@ -176,13 +176,13 @@ const DebugEntryAutocomplete = ({data, onChange}: DebugEntryAutocompleteProps) =
<Typography component="span" sx={{flex: 1}}>
<Chip
sx={{borderRadius: '5px 5px', margin: '0 2px'}}
label={`${entry.response?.statusCode} ${entry.request.method}`}
color={buttonColorHttp(entry.response?.statusCode)}
label={`${entry.summary[CollectorsMap.RequestCollector]?.response?.statusCode} ${entry.summary[CollectorsMap.RequestCollector]?.request.method}`}
color={buttonColorHttp(entry.summary[CollectorsMap.RequestCollector]?.response?.statusCode)}
/>
<span style={{margin: '0 2px'}}>{entry.request.path}</span>
<span style={{margin: '0 2px'}}>{entry.summary[CollectorsMap.RequestCollector]?.request.path}</span>
</Typography>
<Typography component="span" sx={{margin: '0 auto'}}>
<span>{formatDate(entry.web.request.startTime)}</span>
<span>{formatDate(entry.summary[CollectorsMap.WebAppInfoCollector]?.request.startTime)}</span>
</Typography>
</>
)}
Expand Down