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

[refacto] - refacto: agent popularity query #6145

Merged
merged 5 commits into from
Jul 9, 2024

Conversation

JulesBelveze
Copy link
Contributor

@JulesBelveze JulesBelveze commented Jul 9, 2024

Description

This PR refactors the agent popularity query to improve efficiency and reduce database load. The main changes include:

  • Removing the user count calculation, as it's no longer needed for the UI.
  • Changing the time period for popularity calculation from 30 days to 7 days.
  • Always show a modal when changing the scope of an assistant

Risk

Overlooking files in which userCount was used.

There will be a discrepancy between in the message count until the Redis caches expire. Indeed, we are switching from 30 days to 7 days and what's currently in Redis cache is the count for 30 days.

Deploy Plan

  1. Test on front-edge
  2. Deploy to front

Jules added 3 commits July 9, 2024 15:19
…timeframe and simplify data

 - Change the agent ranking calculation period from 30 days to a shorter 7 days timeframe for more recent data relevance
 - Remove the tracking and storage of user counts related to agent mentions, simplifying the data model and storage requirements
 - Clean up unused imports and functions, such as `agentMentionsUserCount`, to streamline the codebase
 - Update related functions to adapt to the removal of user count tracking and the new ranking timeframe
 - Ensure backwards compatibility by incrementing message count only if the counts have already been computed
 - The userCount field is removed from the usage data structure for agent configurations

[types] - refactor: update AgentUsageType interface

 - Removed userCount property to reflect changes in usage data handling
 - Adjusted associated comments to remove references to userCount in the timePeriodSec field
…in SharingDropdown

 - Remove conditions related to initial state and user count when setting new scope

[front/components/assistant] - refactor: streamline assistant usage message in Usage.tsx

 - Remove user count detail from the usage message display logic
Copy link

sentry-io bot commented Jul 9, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: front/lib/api/assistant/agent_usage.ts

Function Unhandled Issue
storeCountsInRedis Error: The client is closed Commander.execPatch [...
Event Count: 1 Affected Users: 0

Did you find this useful? React with a 👍 or 👎

 - Removed unnecessary use of Promise.all for a single async operation
@JulesBelveze JulesBelveze force-pushed the fix/agent-popularity-query branch from 254fd2e to 5715782 Compare July 9, 2024 13:25
Copy link
Contributor

@philipperolet philipperolet left a comment

Choose a reason for hiding this comment

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

LGTM 👍

// Ranking of agents is done over a 30 days period.
const rankingTimeframeSec = 60 * 60 * 24 * 30; // 30 days
// Ranking of agents is done over a 7 days period.
const rankingTimeframeSec = 60 * 60 * 24 * 7; // 30 days
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove 30 days comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops overlooked that one sorry 👍🏼

 - Fixed the inaccurate comment to reflect the actual 7 days period used for agent ranking computations
Copy link
Contributor

@flvndvd flvndvd left a comment

Choose a reason for hiding this comment

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

Thank you 🙇

@JulesBelveze JulesBelveze merged commit 8f07f76 into main Jul 9, 2024
4 checks passed
@JulesBelveze JulesBelveze deleted the fix/agent-popularity-query branch July 9, 2024 14:26
albandum pushed a commit that referenced this pull request Aug 28, 2024
* [front/lib/api/assistant] - refactor: update agent usage calculation timeframe and simplify data

 - Change the agent ranking calculation period from 30 days to a shorter 7 days timeframe for more recent data relevance
 - Remove the tracking and storage of user counts related to agent mentions, simplifying the data model and storage requirements
 - Clean up unused imports and functions, such as `agentMentionsUserCount`, to streamline the codebase
 - Update related functions to adapt to the removal of user count tracking and the new ranking timeframe
 - Ensure backwards compatibility by incrementing message count only if the counts have already been computed

* [front] - refactor: remove userCount from agent usage data

 - The userCount field is removed from the usage data structure for agent configurations

[types] - refactor: update AgentUsageType interface

 - Removed userCount property to reflect changes in usage data handling
 - Adjusted associated comments to remove references to userCount in the timePeriodSec field

* [front/components/assistant] - refactor: simplify scope change logic in SharingDropdown

 - Remove conditions related to initial state and user count when setting new scope

[front/components/assistant] - refactor: streamline assistant usage message in Usage.tsx

 - Remove user count detail from the usage message display logic

* [front] - refactor: simplify retrieval of agent message count

 - Removed unnecessary use of Promise.all for a single async operation

* [assistant] - fix: correct comment for agent ranking timeframe

 - Fixed the inaccurate comment to reflect the actual 7 days period used for agent ranking computations

---------

Co-authored-by: Jules <[email protected]>
@albandum
Copy link
Contributor

@JulesBelveze you might have a bit more context, do you know why we poke redis for the usage on the ui ?
#6145

@JulesBelveze
Copy link
Contributor Author

@albandum The main reason we were storing usage on Redis is because those queries are really expensive and we do not want them to be ran for each admin landing on the workspace page.

@albandum
Copy link
Contributor

@JulesBelveze looks like we removed that from the workspace page, now it only shows when you open an assistant modal if I'm not mistaken so might not be necessary anymore

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.

4 participants