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

[Feature] Implement Global Stats Endpoint in API #8190

Open
5 of 8 tasks
rahul-rocket opened this issue Sep 11, 2024 · 0 comments
Open
5 of 8 tasks

[Feature] Implement Global Stats Endpoint in API #8190

rahul-rocket opened this issue Sep 11, 2024 · 0 comments
Assignees

Comments

@rahul-rocket
Copy link
Collaborator

rahul-rocket commented Sep 11, 2024

Description:

We need to implement a new public endpoint in the Gauzy API to provide global statistics. This endpoint should aggregate data across all tenants and return key metrics in a JSON format. It should be accessible only if a specific environment variable FEATURE_OPEN_STATS is set to true. By default, this endpoint should be disabled.

Requirements:

1. Endpoint Details:

  • Path: /api/stats/global
  • Method: GET
  • Visibility: Publicly accessible only if FEATURE_OPEN_STATS environment variable is set to true.

2. Environment Variable Configuration:

  • Add an environment variable named FEATURE_OPEN_STATS with the default value set to false.
  • If FEATURE_OPEN_STATS is set to true, the endpoint should be enabled and accessible publicly.
  • Ensure proper handling of the environment variable to prevent exposure when not explicitly enabled.

3. Metrics to Include:

  • Hours Tracked (hours): Total number of hours tracked across all tenants. This should be calculated from all time logs, considering their exact duration rather than fixed slot lengths.
  • Invoices (invoices): Total number of invoices generated across all tenants.
  • Employees (employees): Total number of employees across all tenants.
  • Organizations (organizations): Total number of organizations in the system.
  • Tenants (tenants): Total number of tenants.
  • Expenses (expenses): Total amount of expenses recorded.
  • Income (income): Total income generated.
  • Tasks (tasks): Total number of tasks recorded.

4. Response Format:

{
"hours": "2343354",
"invoices": 3343,
"employees": 43545,
"organizations": 454,
"tenants": 4545,
"expenses": 454645,
"income": 67676,
"tasks": 12345
}

Note: Include data for all entities, including archived and deleted records.

@rahul-rocket rahul-rocket self-assigned this Sep 11, 2024
rahul-rocket added a commit that referenced this issue Sep 11, 2024
rahul-rocket added a commit that referenced this issue Sep 12, 2024
evereq added a commit that referenced this issue Sep 14, 2024
* [Refactor] Employee DTOs / Interface (#8173)

* fix: employee bill rate currency DTO & candidate entity relations

* Revert "fix: employee bill rate currency DTO & candidate entity relations"

This reverts commit b212fac.

* fix: candidate model, entity and DTOs

* fix: update rates DTOs for pay period

* fix: update employee profile & error handling

* fix: candidate & employee entity and DTOs

* fix: updated employee entity input interfaces

* fix(deepscan): removed unused import

* fix(deepscan): removed unused import

* feat: added missing favicon for apps (#8174)

* feat: added 'CLOC' time log source

* feat: added missing translation for source filter dropdown

* feat: archivedAt mysql migration

* feat: adding acrhivedAt sqlite migrations

* fix: desktop build

* fix: rename migration file

* fix: titlebar menu

* fix: updated migration for PostgreSQL & SQLite

* fix: splash screen theme

* fix(mysql): updated migration for duplicate column

* fix: titlebar menu desktop

* fix: theme missing variable and setDefault app setting values on first start

* fix: updated migration for MySQL

* fix: adjust header desktop app

* fix: removed unnecessary employee_job_preset table changes

* fix(deepscan): removed unused import

* feat: add favorite entity

* fix: optional property for repository custom field

* fix: optional status mapper

* fix: removed router module for register routes

* feat: favorite entity migration

* fix(typos): fix typo issues

* feat: added columns for organization project entity

* add-reject-candidate-email

* fix: add new columns to OrganizationProject entity

- Added [icon, status, archiveTasksIn, closeTasksIn] to OrganizationProject entity.

* fix: updated entity & interfaces

* feat: add favorite APIs

* [Feat] Time & Activities Register Dynamic Tabs  (#8182)

* feat: dynamic tabs & routes registered for time & activity page

* feat: routes registered for time & activities page

- Added [Apps/URL] routes registered.
- Added [Screenshot] routes registered.

* feat: routes registered for time & activities page

- Added [Apps/URL] routes registered.
- Added [Screenshot] routes registered.

* fix: screenshots started at  group by

* fix(cspell): typo spelling :-)

* fix: global favorite service

* fix: desktop app translation break

* fix: access methods from dicovery servicce

* fix(typos): typos errors

* fix: updated organization project DTOs

* feat: favorites dynamic get related entities

* feat: add new columns to OrganizationTeamEmployee entity

- Added [isManager, assignedAt] to OrganizationProject entity.

* fix: updated organization team members APIs

* fix(cspell): typo spelling :-)

* fix(deepscan): removed unused import

* feat(env): add new variable for global stats endpoint

* feat: add feature global stats enum

* refactor: get toggle features for environment

* fix: rename favorite fields

* feat(env): add new variable for global stats endpoint

* feat: #8190 few global public stats

* fix: entityId finder and delete permission

* fix: use super method to get monthly active users count

* [IN PROGRESS]Send rejection email to candidate

* [IN PROGRESS]Send rejection email to candidate

* chore(deps): bump dset from 3.1.3 to 3.1.4

Bumps [dset](https://github.com/lukeed/dset) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/lukeed/dset/releases)
- [Commits](lukeed/dset@v3.1.3...v3.1.4)

---
updated-dependencies:
- dependency-name: dset
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix: rename method

* chore(deps): bump express from 4.19.2 to 4.20.0

Bumps [express](https://github.com/expressjs/express) from 4.19.2 to 4.20.0.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](expressjs/express@4.19.2...4.20.0)

---
updated-dependencies:
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix(deepscan): nullish coalescing operator (??)

* feat: total tracked overall duration in seconds to hours

* fix(cspell): typo spelling :-)

* feat: count and total amount for invoices/payments created

* feat: count and total amount for teams/tasks created

* feat: user stats (total and last month active users)

* send email to rejected candidate

* integre feedback

* integre feedback

* feat: add translations for "Reject Candidate" in various languages

- Arabic (ar): "رفض المرشح"
- Bulgarian (bg): "Отхвърли кандидат"
- German (de): "Kandidat ablehnen"
- English (en): "Reject Candidate"
- Spanish (es): "Rechazar Candidato"
- French (fr): "Rejeter le Candidat"
- Hebrew (he): "לדחות את המועמד"
- Italian (it): "Rifiuta Candidato"
- Dutch (nl): "Kandidaat Afwijzen"
- Polish (pl): "Odrzuć Kandydata"
- Portuguese (pt): "Rejeitar Candidato"
- Russian (ru): "Отклонить кандидата"
- Chinese (zh): "拒绝候选人"

* feat: add migration for email templates (ID: MigrateEmailTemplates1726206783506)

- Created `MigrateEmailTemplates1726206783506` migration class.
- This migration handles updates and insertions for email templates in the database.

* fix: dark theme charts ticks

* update: styles for .charts-bar-vertical in time-tracking-charts.component.scss

* fix: remove deprecated Employee resolver and related code

* fix: remove deprecated route resolvers

* fix(deepscan): removed unused import

* Fix/#8159 random bad request (#8197)

* chore: add new command to make mac build fast in package.json

* fix: intervalDAO and IntervalService remove idle queries

* refactor: PowerManagerDetectInactivity and DesktopOsInactivityHandler classes, updating event handling, inactivity detection, and idle time removal logic.

* fix: remove idle event listener conditional statements, added checks, and modified IPC renderer events

* feat: prevent duplicated API Requests method for start/stop API calls

* feat: add `isOnBattery` property to `BasePowerManagerDecorator` and `DesktopPowerManager`, and updated `DesktopOsInactivityHandler` to use it.

* Fix/#7492 task switching (#8195)

* feat: create selector interface

* feat: create generate store and query abstract

* feat: create reusable components

* feat: create client selector feature

* feat: create note selector feature

* feat: project selector feature

* feat: create task selector feature

* feat: create team selector feature

* feat: create time tracker form

* refactored: Time Tracker component to use GauzyTimeTrackerForm, removed client, project, team, and task selection fields, and added TimeTrackerModule to imports in TimeTrackerModule.

* updated various files in desktop-ui-lib, including selector stores, components, and modules, with changes to imports, exports, and method implementations.

* fix: null safety in selector queries, and add canAddTag and addTagText properties to gauzy-select components"

* feat: add isLoading input to SelectComponent and updated ClientSelector, ProjectSelector, TaskSelector, and TeamSelector components to use it.

* update: styles and templates for ng-select component in desktop-ui-lib and desktop-timer apps.

* feat: integrate selectors to time tracker

* refactor SelectorStore: update data concatenation and remove redundant line

* feat: add time tracker query, store, and implement dialog for task updates

* remove: NbButtonModule, NbIconModule, and PipeModule imports from TimeTrackerFormModule.

* update project selector, task selector, and team selector components; modify time tracker form and query; add ignition method to time tracker store; update time tracker component

* update: time tracker component to calculate and send idle time on restart

* fix: TimeTracker component to send startedAt as ISO string, and modify TimerTrackerChangeDialog component to add large class and expanded$ observable

* feat: add isLoading$, disabled$, and hasError$ bindings to client-selector, project-selector, task-selector, and team-selector components

* refactor: desktop timer app update imports, rename variables, and modify component templates and logic

* refactor: adjust logic in time tracker form and dialog components.

* chore: add new command to make mac build fast in package.json

* fix: intervalDAO and IntervalService remove idle queries

* refactor: PowerManagerDetectInactivity and DesktopOsInactivityHandler classes, updating event handling, inactivity detection, and idle time removal logic.

* fix: remove idle event listener conditional statements, added checks, and modified IPC renderer events

* feat: prevent duplicated API Requests method for start/stop API calls

* feat: add `isOnBattery` property to `BasePowerManagerDecorator` and `DesktopPowerManager`, and updated `DesktopOsInactivityHandler` to use it.

* feat: add new IPC handlers

* refactor: TimeTrackerComponent and TimeTrackerService: removed ITimerStatus, added ITimeLog, modified method signatures and implementations

* feat: add `hasPermission` property to  selectors and update components to use new property, and removed old permission BehaviorSubjects.

* feat: add UntilDestroy decorator to several components, modified time-tracker-form.component.ts, and updated time-tracker.query.ts and time-tracker.component.ts

* fix: use complete value

* feat:  handle UPDATE_SELECTOR IPC event

* feat: update desktop-ipc, desktop-timer, and time-tracker component with changes to timer handling and dependencies.

* fix:  deepscan

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Rahul R. <[email protected]>
Co-authored-by: GloireMutaliko21 <[email protected]>
Co-authored-by: syns2191 <[email protected]>
Co-authored-by: Kifungo A <[email protected]>
Co-authored-by: samuelmbabhazi <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
evereq added a commit that referenced this issue Sep 15, 2024
* [Refactor] Employee DTOs / Interface (#8173)

* fix: employee bill rate currency DTO & candidate entity relations

* Revert "fix: employee bill rate currency DTO & candidate entity relations"

This reverts commit b212fac.

* fix: candidate model, entity and DTOs

* fix: update rates DTOs for pay period

* fix: update employee profile & error handling

* fix: candidate & employee entity and DTOs

* fix: updated employee entity input interfaces

* fix(deepscan): removed unused import

* fix(deepscan): removed unused import

* feat: added missing favicon for apps (#8174)

* feat: added 'CLOC' time log source

* feat: added missing translation for source filter dropdown

* feat: archivedAt mysql migration

* feat: adding acrhivedAt sqlite migrations

* fix: desktop build

* fix: rename migration file

* fix: titlebar menu

* fix: updated migration for PostgreSQL & SQLite

* fix: splash screen theme

* fix(mysql): updated migration for duplicate column

* fix: titlebar menu desktop

* fix: theme missing variable and setDefault app setting values on first start

* fix: updated migration for MySQL

* fix: adjust header desktop app

* fix: removed unnecessary employee_job_preset table changes

* fix(deepscan): removed unused import

* feat: add favorite entity

* fix: optional property for repository custom field

* fix: optional status mapper

* fix: removed router module for register routes

* feat: favorite entity migration

* fix(typos): fix typo issues

* feat: added columns for organization project entity

* add-reject-candidate-email

* fix: add new columns to OrganizationProject entity

- Added [icon, status, archiveTasksIn, closeTasksIn] to OrganizationProject entity.

* fix: updated entity & interfaces

* feat: add favorite APIs

* [Feat] Time & Activities Register Dynamic Tabs  (#8182)

* feat: dynamic tabs & routes registered for time & activity page

* feat: routes registered for time & activities page

- Added [Apps/URL] routes registered.
- Added [Screenshot] routes registered.

* feat: routes registered for time & activities page

- Added [Apps/URL] routes registered.
- Added [Screenshot] routes registered.

* fix: screenshots started at  group by

* fix(cspell): typo spelling :-)

* fix: global favorite service

* fix: desktop app translation break

* fix: access methods from dicovery servicce

* fix(typos): typos errors

* fix: updated organization project DTOs

* feat: favorites dynamic get related entities

* feat: add new columns to OrganizationTeamEmployee entity

- Added [isManager, assignedAt] to OrganizationProject entity.

* fix: updated organization team members APIs

* fix(cspell): typo spelling :-)

* fix(deepscan): removed unused import

* feat(env): add new variable for global stats endpoint

* feat: add feature global stats enum

* refactor: get toggle features for environment

* fix: rename favorite fields

* feat(env): add new variable for global stats endpoint

* feat: #8190 few global public stats

* fix: entityId finder and delete permission

* fix: use super method to get monthly active users count

* [IN PROGRESS]Send rejection email to candidate

* [IN PROGRESS]Send rejection email to candidate

* chore(deps): bump dset from 3.1.3 to 3.1.4

Bumps [dset](https://github.com/lukeed/dset) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/lukeed/dset/releases)
- [Commits](lukeed/dset@v3.1.3...v3.1.4)

---
updated-dependencies:
- dependency-name: dset
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix: rename method

* chore(deps): bump express from 4.19.2 to 4.20.0

Bumps [express](https://github.com/expressjs/express) from 4.19.2 to 4.20.0.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](expressjs/express@4.19.2...4.20.0)

---
updated-dependencies:
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix(deepscan): nullish coalescing operator (??)

* feat: total tracked overall duration in seconds to hours

* fix(cspell): typo spelling :-)

* feat: count and total amount for invoices/payments created

* feat: count and total amount for teams/tasks created

* feat: user stats (total and last month active users)

* send email to rejected candidate

* integre feedback

* integre feedback

* feat: add translations for "Reject Candidate" in various languages

- Arabic (ar): "رفض المرشح"
- Bulgarian (bg): "Отхвърли кандидат"
- German (de): "Kandidat ablehnen"
- English (en): "Reject Candidate"
- Spanish (es): "Rechazar Candidato"
- French (fr): "Rejeter le Candidat"
- Hebrew (he): "לדחות את המועמד"
- Italian (it): "Rifiuta Candidato"
- Dutch (nl): "Kandidaat Afwijzen"
- Polish (pl): "Odrzuć Kandydata"
- Portuguese (pt): "Rejeitar Candidato"
- Russian (ru): "Отклонить кандидата"
- Chinese (zh): "拒绝候选人"

* feat: add migration for email templates (ID: MigrateEmailTemplates1726206783506)

- Created `MigrateEmailTemplates1726206783506` migration class.
- This migration handles updates and insertions for email templates in the database.

* fix: dark theme charts ticks

* update: styles for .charts-bar-vertical in time-tracking-charts.component.scss

* fix: remove deprecated Employee resolver and related code

* fix: remove deprecated route resolvers

* fix(deepscan): removed unused import

* Fix/#8159 random bad request (#8197)

* chore: add new command to make mac build fast in package.json

* fix: intervalDAO and IntervalService remove idle queries

* refactor: PowerManagerDetectInactivity and DesktopOsInactivityHandler classes, updating event handling, inactivity detection, and idle time removal logic.

* fix: remove idle event listener conditional statements, added checks, and modified IPC renderer events

* feat: prevent duplicated API Requests method for start/stop API calls

* feat: add `isOnBattery` property to `BasePowerManagerDecorator` and `DesktopPowerManager`, and updated `DesktopOsInactivityHandler` to use it.

* Fix/#7492 task switching (#8195)

* feat: create selector interface

* feat: create generate store and query abstract

* feat: create reusable components

* feat: create client selector feature

* feat: create note selector feature

* feat: project selector feature

* feat: create task selector feature

* feat: create team selector feature

* feat: create time tracker form

* refactored: Time Tracker component to use GauzyTimeTrackerForm, removed client, project, team, and task selection fields, and added TimeTrackerModule to imports in TimeTrackerModule.

* updated various files in desktop-ui-lib, including selector stores, components, and modules, with changes to imports, exports, and method implementations.

* fix: null safety in selector queries, and add canAddTag and addTagText properties to gauzy-select components"

* feat: add isLoading input to SelectComponent and updated ClientSelector, ProjectSelector, TaskSelector, and TeamSelector components to use it.

* update: styles and templates for ng-select component in desktop-ui-lib and desktop-timer apps.

* feat: integrate selectors to time tracker

* refactor SelectorStore: update data concatenation and remove redundant line

* feat: add time tracker query, store, and implement dialog for task updates

* remove: NbButtonModule, NbIconModule, and PipeModule imports from TimeTrackerFormModule.

* update project selector, task selector, and team selector components; modify time tracker form and query; add ignition method to time tracker store; update time tracker component

* update: time tracker component to calculate and send idle time on restart

* fix: TimeTracker component to send startedAt as ISO string, and modify TimerTrackerChangeDialog component to add large class and expanded$ observable

* feat: add isLoading$, disabled$, and hasError$ bindings to client-selector, project-selector, task-selector, and team-selector components

* refactor: desktop timer app update imports, rename variables, and modify component templates and logic

* refactor: adjust logic in time tracker form and dialog components.

* chore: add new command to make mac build fast in package.json

* fix: intervalDAO and IntervalService remove idle queries

* refactor: PowerManagerDetectInactivity and DesktopOsInactivityHandler classes, updating event handling, inactivity detection, and idle time removal logic.

* fix: remove idle event listener conditional statements, added checks, and modified IPC renderer events

* feat: prevent duplicated API Requests method for start/stop API calls

* feat: add `isOnBattery` property to `BasePowerManagerDecorator` and `DesktopPowerManager`, and updated `DesktopOsInactivityHandler` to use it.

* feat: add new IPC handlers

* refactor: TimeTrackerComponent and TimeTrackerService: removed ITimerStatus, added ITimeLog, modified method signatures and implementations

* feat: add `hasPermission` property to  selectors and update components to use new property, and removed old permission BehaviorSubjects.

* feat: add UntilDestroy decorator to several components, modified time-tracker-form.component.ts, and updated time-tracker.query.ts and time-tracker.component.ts

* fix: use complete value

* feat:  handle UPDATE_SELECTOR IPC event

* feat: update desktop-ipc, desktop-timer, and time-tracker component with changes to timer handling and dependencies.

* fix:  deepscan

* refactor: moved integration setting resolvers to the ui-core

* fix: dynamic register integrations routes

* [Feature] Comments and Notes (#8196)

* feat: added comment model

* feat: added comment migrations

* feat: comment commands and handlers

* feat: comment APIs

* fix: comments model and migration

* fix: missing fields and index

* fix: comment field type

* [Feat] Generic Reaction Model / Entity (#8200)

* feat: added reaction model

* feat: added reaction entity

* feat: added reaction commands and handlers

* feat: added reaction APIs

* feat: reaction migrations

* Update app.module.ts

---------

Co-authored-by: Ruslan Konviser <[email protected]>

* chore: more fixes for desktop windows builds

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Rahul R. <[email protected]>
Co-authored-by: GloireMutaliko21 <[email protected]>
Co-authored-by: syns2191 <[email protected]>
Co-authored-by: Kifungo A <[email protected]>
Co-authored-by: samuelmbabhazi <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gloire Mutaliko (Salva) <[email protected]>
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

No branches or pull requests

1 participant