feat: added rescheduled filter and fixed extra fetching of data for cancelled filter for insights
What does this PR do?
- Fixes #24531
- Fixes CAL-6599
The Insights/Bookings and Routing false positively fetched the data when "Cancelled" booking status is selected. All the bookings has a column in DB called "Rescheduled" which is by default set to null, but when a meeting is rescheduled, it is set to true and the meeting status is set to "CANCELLED". So when the "Cancelled" status is selected, the rescheduled meetings are also being fetched which leads to incorrect stats.
This PR resolves this false-positive fetching and introduces a separate "Rescheduled" filter to only fetch the rescheduled meetings.
There are 4 scenarios that can happen while fetching the data:
- Cancelled or Rescheduled filters are not selected, in this case the data will be fetched normally
- Cancelled is selected, in this case all Bookings which status is marked as CANCELLED and their "rescheduled" column is either null or false, they will be fetched.
- Rescheduled is selected, in this case all Bookings whose "rescheduled" column is true will be fetched.
- Rescheduled and Cancelled both are selected, in this case all the bookings with "CANCELLED" status will be fetched, this will also fetch the rescheduled bookings because rescheduled bookings are marked as CANCELLED and their "rescheduled" field is set to true.
This PR covers all of the above cases.
Visual Demo (For contributors especially)
A visual demonstration is strongly recommended, for both the original and new change (video / image - any one). Will attach soon
Image Demo (if applicable):
For routing:
For Bookings:
Mandatory Tasks (DO NOT REMOVE)
- [x] I have self-reviewed the code (A decent size PR without self-review might be rejected).
- [x] I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. N/A
- [ ] I confirm automated tests are in place that prove my fix is effective or that my feature works.
How should this be tested?
Will describe soon
@Zopsss is attempting to deploy a commit to the cal Team on Vercel.
A member of the Team first needs to authorize it.
The code is currently a bit messy and contains debugging console logs. Will remove them once I ensure that everything is working fine and also attach the demo video in PR description.
hey @pedroccastro, @Ryukemeister, @dhairyashiil I am trying to run this integration test: https://github.com/calcom/cal.com/blob/main/packages/features/insights/services/InsightsRoutingService.integration-test.ts but it is saying file not found:
PS D:\OpenSource\cal.com> yarn test packages\features\insights\services\InsightsRoutingService.integration-test.ts
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
RUN v2.1.9 D:/OpenSource/cal.com
filter: packages/features/insights/services/InsightsRoutingService.integration-test.ts
[@calcom/lib] Config
include: packages/**/*.{test,spec}.{ts,js}, apps/**/*.{test,spec}.{ts,js}
exclude: **/node_modules/**/*, **/.next/**/*, packages/embeds/**/*, packages/lib/hooks/**/*, packages/platform/**/*, apps/api/v1/**/*, apps/api/v2/**/*
[@calcom/api] Config
include: apps/api/v1/**/*.{test,spec}.{ts,js}
exclude: **/node_modules/**/*, **/.next/**/*, packages/embeds/**/*, packages/lib/hooks/**/*, packages/platform/**/*, apps/api/v2/**/*
[@calcom/features] Config
include: packages/features/**/*.{test,spec}.tsx
exclude: packages/features/form-builder/**/*, packages/features/bookings/**/*
[@calcom/closecom] Config
include: packages/app-store/closecom/**/*.{test,spec}.{ts,js}
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/app-store-core] Config
include: packages/app-store/*.{test,spec}.[jt]s?(x)
exclude: packages/app-store/delegationCredential.test.ts
[@calcom/app-store-delegation-credential] Config
include: packages/app-store/delegationCredential.test.ts
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/routing-forms] Config
include: packages/app-store/routing-forms/**/*.test.tsx
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/ui] Config
include: packages/ui/components/**/*.{test,spec}.[jt]s?(x)
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/features/form-builder] Config
include: packages/features/form-builder/**/*.{test,spec}.[jt]sx
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/features/bookings] Config
include: packages/features/bookings/**/*.{test,spec}.[jt]sx
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/web/components] Config
include: apps/web/components/**/*.{test,spec}.[jt]sx
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[EventTypeAppCardInterface components] Config
include: packages/app-store/_components/**/*.{test,spec}.[jt]s?(x)
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/packages/lib/hooks] Config
include: packages/lib/hooks/**/*.{test,spec}.{ts,js}
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/web/modules/views] Config
include: apps/web/modules/**/*.{test,spec}.tsx
exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
[@calcom/embeds] Config
include: packages/embeds/**/*.{test,spec}.{ts,js}
exclude: packages/embeds/**/packaged/**/*.{test,spec}.{ts,js}
No test files found, exiting with code 0
am I missing something here?
@CarinaWolli I have attached videos of both: Bookings and Routing, can you please check them out? Let me know if anything else is needed!
hey @pedroccastro, @Ryukemeister, @dhairyashiil I am trying to run this integration test: https://github.com/calcom/cal.com/blob/main/packages/features/insights/services/InsightsRoutingService.integration-test.ts but it is saying file not found:
am I missing something here?
run this command:
yarn test packages/features/insights/services/InsightsRoutingService.integration-test.ts -- --integrationTestsOnly
by design integration tests need to be run with a special flag