Skip to content

feat(statistic): add services count#282

Merged
l1ttps merged 5 commits intomainfrom
dashboard
Feb 24, 2026
Merged

feat(statistic): add services count#282
l1ttps merged 5 commits intomainfrom
dashboard

Conversation

@l1ttps
Copy link
Copy Markdown
Member

@l1ttps l1ttps commented Feb 24, 2026

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @l1ttps, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on enhancing the application's statistical capabilities by introducing a 'services' count, which is now integrated into the backend data models, API responses, and the frontend dashboard. Alongside this new feature, significant refactoring was performed on the vulnerabilities API to streamline parameter handling. Minor UI adjustments and code cleanup, including a directory rename, contribute to overall system improvement.

Highlights

  • Services Count Integration: Introduced a new 'services' count across the application, including API responses, database entities, frontend statistics, and timeline trends, providing a new metric for workspace overview.
  • API Refactoring for Vulnerabilities: Refactored the getVulnerabilities API endpoint and service method to explicitly pass workspaceId as a separate argument rather than as part of the query DTO, improving API design and consistency.
  • UI Enhancements: Updated the Dashboard menu link to the root path and added a 'Services' card to the dashboard statistics, replacing the 'Ports' card. The DatePickerWithRange component now supports a custom label.
  • Codebase Cleanup: Corrected a typo in the tools-provider directory name and removed several unused statistic calculation methods from the StatisticService.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • console/src/components/common/layout/menu-bar.tsx
    • Updated the Dashboard menu item's URL to the root path ('/').
  • console/src/components/ui/date-picker-range.tsx
    • Added an optional label prop to DatePickerWithRangeProps interface.
    • Incorporated the label prop into the component's function signature.
    • Used the label prop for the date picker's placeholder text, defaulting to 'Pick a date range'.
  • console/src/hooks/useTimelineTrend.ts
    • Added a services property of type number to the TimelineStatistic interface.
  • console/src/pages/dashboard/components/statistic.tsx
    • Replaced the EthernetPort icon import with Server icon.
    • Added a new statistic card for 'Services' using the Server icon and statistics?.services value.
    • Commented out the existing 'Ports' statistic card.
  • console/src/pages/vulnerabilities/list-vulnerabilitys.tsx
    • Added a label="Date" prop to the DatePickerWithRange component instance.
  • console/src/services/apis/gen/queries.ts
    • Added a services property to the StatisticResponseDto interface.
    • Added a services property to the Statistic interface.
    • Removed workspaceId from VulnerabilitiesControllerGetVulnerabilitiesParams.
    • Made the params argument optional for vulnerabilitiesControllerGetVulnerabilities and its related infinite query and use query hooks.
  • core-api/src/mcp/mcp.tools.ts
    • Reordered import statements for better organization.
    • Updated the call to this.vulnerabilitiesService.getVulnerabilities to pass workspaceId as a separate argument.
  • core-api/src/modules/jobs-registry/jobs-registry.service.ts
    • Corrected the import path for builtInTools from tools-privider to tools-provider.
  • core-api/src/modules/jobs-registry/processors/job-result.processor.ts
    • Corrected the import path for builtInTools from tools-privider to tools-provider.
  • core-api/src/modules/statistic/dto/statistic.dto.ts
    • Added a services property with ApiProperty decorator to StatisticResponseDto.
  • core-api/src/modules/statistic/entities/statistic.entity.ts
    • Added a services column with ApiProperty decorator to the Statistic entity.
  • core-api/src/modules/statistic/statistic.service.ts
    • Removed unused methods: getTotalVulnerabilities, getTotalUniqueTechnologies, and getTotalUniquePorts.
    • Removed the conditional block that returned default statistic values when no statistics were found.
    • Included services in the StatisticResponseDto mapping.
    • Updated getTechCounts to query the latest HttpResponse and filter by isErrorPage.
    • Added a new getServiceCounts method to count distinct AssetService entities per workspace.
    • Updated getPortCounts to filter by isErrorPage.
    • Included serviceCounts in the Promise.all call within calculateStatistics.
    • Initialized services to 0 in the statisticsMap for new workspace statistics.
    • Updated service counts in the statistics map.
  • core-api/src/modules/tools/tools-privider/built-in-tools.ts
    • Renamed the directory tools-privider to tools-provider.
  • core-api/src/modules/tools/tools-privider/official-support-tools.ts
    • Renamed the directory tools-privider to tools-provider.
  • core-api/src/modules/tools/tools.service.ts
    • Updated import paths for builtInTools and officialSupportTools to reflect the tools-provider directory rename.
  • core-api/src/modules/vulnerabilities/dto/get-vulnerability.dto.ts
    • Removed the workspaceId property from GetVulnerabilitiesQueryDto.
    • Updated descriptions for createdAtFrom and createdAtTo ApiProperty decorators for better readability.
  • core-api/src/modules/vulnerabilities/vulnerabilities.controller.ts
    • Reordered import statements.
    • Added getWorkspaceId: true to the Doc decorator for getVulnerabilities endpoint.
    • Modified getVulnerabilities method to receive workspaceId via @WorkspaceId() decorator.
    • Updated the call to this.vulnerabilitiesService.getVulnerabilities to pass workspaceId as a separate argument.
  • core-api/src/modules/vulnerabilities/vulnerabilities.service.ts
    • Modified the getVulnerabilities method signature to accept workspaceId as a separate argument.
  • worker/services/core-api/api.ts
    • Added a services property to the StatisticResponseDto interface.
    • Added a services property to the Statistic interface.
    • Made the query parameter optional for vulnerabilitiesControllerGetVulnerabilities.
    • Removed workspaceId from the query parameters of vulnerabilitiesControllerGetVulnerabilities.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request successfully introduces the 'services' count to the workspace statistics across the application. The changes include backend updates to the statistics entity, DTOs, and service logic, as well as frontend updates to display the new metric on the dashboard. The refactoring of technology counts to use the latest HTTP response is a good improvement for accuracy. I have provided some feedback regarding the efficiency of the database queries in the statistics service and suggested some simplifications.

.innerJoin(
'assetService.httpResponses',
'latest_http',
'latest_http.id = (SELECT hr.id FROM http_responses hr WHERE hr."assetServiceId" = assetService.id ORDER BY hr."createdAt" DESC LIMIT 1)',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a correlated subquery in a join condition can lead to significant performance degradation as the subquery is executed for every row in the AssetService table. For large datasets, consider using a more efficient approach such as joining with a subquery that uses DISTINCT ON (PostgreSQL specific) or window functions to identify the latest IDs first.

.leftJoin('target.workspaceTargets', 'wt')
.where('wt.workspaceId IN (:...workspaceIds)', { workspaceIds });
.where('wt.workspaceId IN (:...workspaceIds)', { workspaceIds })
.andWhere('"assetService"."isErrorPage" = false');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

It is recommended to use TypeORM property names instead of raw SQL strings with quotes for column names in andWhere clauses. This ensures that the query remains correct even if the naming strategy (e.g., snake_case vs camelCase) changes in the future. Also, consider using innerJoin instead of leftJoin for the related tables since you are filtering by workspaceId in the where clause.

Suggested change
.andWhere('"assetService"."isErrorPage" = false');
.andWhere('assetService.isErrorPage = false');

@l1ttps l1ttps merged commit 0498a80 into main Feb 24, 2026
9 checks passed
@l1ttps l1ttps deleted the dashboard branch March 22, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant