Skip to content

feat: setting to enable weights on attribute in route#18592

Merged
CarinaWolli merged 17 commits intomainfrom
feat/enable-attribute-weights-setting
Jan 30, 2025
Merged

feat: setting to enable weights on attribute in route#18592
CarinaWolli merged 17 commits intomainfrom
feat/enable-attribute-weights-setting

Conversation

@CarinaWolli
Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli commented Jan 10, 2025

What does this PR do?

Adds a new setting to routing from routes to choose if attribute weights should be used with a dropdown to pick the attribute. You can only pick attributes that have weights enabled and that are used in the route with 'Value of field ...'.

Before it was not transparent when we switch to attribute weights. That's the logic used before:
If an attribute had weights enabled and any routing form used this attribute with 'Value of field ...' it would always automatically switch to attribute weights.

Screenshot 2025-01-14 at 12 30 49 PM

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • TODO 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.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@keithwillcode keithwillcode added consumer core area: core, team members only labels Jan 10, 2025
@CarinaWolli CarinaWolli changed the title feat: setting to enable weights on attribute feat: setting to enable weights on attribute in route Jan 10, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cal-com-ui-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 2:38am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 2:38am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 2:38am

@github-actions github-actions Bot added Not urgent Created by Linear-GitHub Sync routing-forms area: routing forms, routing, forms Urgent Created by Linear-GitHub Sync 🧹 Improvements Improvements to existing features. Mostly UX/UI labels Jan 14, 2025
@CarinaWolli CarinaWolli added High priority Created by Linear-GitHub Sync and removed Urgent Created by Linear-GitHub Sync labels Jan 16, 2025
@dosubot dosubot Bot added i18n area: i18n, translations ✨ feature New feature or request labels Jan 16, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 16, 2025

E2E results are ready!

Copy link
Copy Markdown
Contributor

@Udit-takkar Udit-takkar left a comment

Choose a reason for hiding this comment

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

Code looks fine. will wait for hariom's review before merging

Comment thread packages/lib/server/getLuckyUser.ts Outdated
Comment on lines +878 to +882
const attributeWithEnabledWeights = await prisma.attribute.findFirst({
where: {
id: attributeIdForWeights,
teamId: organizationId,
isWeightsEnabled: true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could make this query potentially faster by using findUnique with just id as we have that now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. I changed it to findUnique

Comment thread packages/lib/server/getLuckyUser.ts
@hariombalhara
Copy link
Copy Markdown
Member

Removed the weighted attributes logi from Route component https://github.com/calcom/cal.com/pull/18974/files#

Co-authored-by: Hariom Balhara <hariombalhara@gmgmail.com>
hariombalhara
hariombalhara previously approved these changes Jan 29, 2025
@CarinaWolli
Copy link
Copy Markdown
Member Author

@hariombalhara can I get another approval please, only changed findFirst to findUnique 🙏

@CarinaWolli CarinaWolli merged commit 8d2dc0b into main Jan 30, 2025
@CarinaWolli CarinaWolli deleted the feat/enable-attribute-weights-setting branch January 30, 2025 16:44
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Feb 25, 2025
* add UI to Routes

* add attributeIdForWeights to route json

* fixes and clean up

* clean up onChangeAttributeIdForWeights

* fix type errors

* fix attribute weights in getLuckyUser

* adjust tests

* fixes for attribute rule changes

* fix type error

* Keep weighted attributes logic outside Route (calcom#18974)

Co-authored-by: Hariom Balhara <hariombalhara@gmgmail.com>

* use findUnique

* fix test

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmgmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only ✨ feature New feature or request High priority Created by Linear-GitHub Sync i18n area: i18n, translations 🧹 Improvements Improvements to existing features. Mostly UX/UI Not urgent Created by Linear-GitHub Sync ready-for-e2e routing-forms area: routing forms, routing, forms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-4994] Setting to define if attribute weights should be used

4 participants