feat (Vouch-X): Add Confidence Value based on x.com public metrics
twilson63 opened this issue · comments
Document of Ready Issue: Confidence-Value Calculation for Vouch-X Service
Background
The Vouch-X Service needs to calculate a Confidence-Value for a user's account based on specific metrics provided by the /users/me API. These metrics include followers count, following count, tweet count, listed count, and like count. The calculated Confidence-Value will help determine the reliability and influence of the user.
Problem Statement
We need a function in JavaScript that uses predefined weights to calculate a Confidence-Value based on the metrics retrieved from the /users/me API. The weights for each property are as follows:
- Tweet: 0.001
- Follower: 0.02
- Verified: 8.00 (Assuming there's a boolean indicating if the user is verified)
- Listed: 0.05
Solution
Create a JavaScript function that:
- Retrieves the user's metrics from the /users/me API.
- Applies the predefined weights to calculate the Confidence-Value.
- Returns the calculated Confidence-Value.
Requirements
- API Interaction: The function should interact with the /users/me API to fetch the user's metrics.
- Calculation Logic: Apply the following weights to the respective metrics:
- Tweet: 0.001
- Follower: 0.02
- Verified: 8.00
- Listed: 0.05
- Implementation in JavaScript: The function should be implemented in JavaScript and be capable of running in the current service environment.
Technical Specifications
- Function Name: calculateConfidenceValue
- Input: User metrics object from /users/me API response.
- Output: Calculated Confidence-Value (number).
Pseudo Code
function calculateConfidenceValue(userMetrics) {
const tweetWeight = 0.001;
const followerWeight = 0.02;
const verifiedWeight = 8.00;
const listedWeight = 0.05;
const { followers_count, tweet_count, listed_count, verified } = userMetrics.public_metrics;
const confidenceValue = (tweet_count * tweetWeight) +
(followers_count * followerWeight) +
(listed_count * listedWeight) +
(verified ? verifiedWeight : 0);
return confidenceValue;
}
Example Usage
const userMetrics = {
"public_metrics": {
"followers_count": 1045,
"tweet_count": 4534,
"listed_count": 23,
"verified": true
}
};
const confidenceValue = calculateConfidenceValue(userMetrics);
console.log(confidenceValue); // Outputs the calculated Confidence-Value
Acceptance Criteria
- Correct Calculation: The function accurately calculates the Confidence-Value using the provided weights.
- Performance: The function performs efficiently for a large number of API calls.
- Testing: Unit tests cover various scenarios, including edge cases like zero values and missing properties.
Affected Units
- Vouch-X Service
Action Items for Engineers
-
Implement Function:
- Develop the
calculateConfidenceValue
function in JavaScript as per the pseudo code provided.
- Develop the
-
API Integration:
- Ensure the function fetches data from the /users/me API and applies the weights correctly.
-
Testing:
- Write unit tests to validate the function with different sets of input data.
-
Documentation:
- Document the function usage and integration steps for future reference.
Feel free to reach out for any clarifications or further assistance needed in implementing this feature.