permaweb / vouch-x

A vouch service based on the x platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Retrieves the user's metrics from the /users/me API.
  2. Applies the predefined weights to calculate the Confidence-Value.
  3. Returns the calculated Confidence-Value.

Requirements

  1. API Interaction: The function should interact with the /users/me API to fetch the user's metrics.
  2. Calculation Logic: Apply the following weights to the respective metrics:
    • Tweet: 0.001
    • Follower: 0.02
    • Verified: 8.00
    • Listed: 0.05
  3. 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

  1. Correct Calculation: The function accurately calculates the Confidence-Value using the provided weights.
  2. Performance: The function performs efficiently for a large number of API calls.
  3. Testing: Unit tests cover various scenarios, including edge cases like zero values and missing properties.

Affected Units

  • Vouch-X Service

Action Items for Engineers

  1. Implement Function:

    • Develop the calculateConfidenceValue function in JavaScript as per the pseudo code provided.
  2. API Integration:

    • Ensure the function fetches data from the /users/me API and applies the weights correctly.
  3. Testing:

    • Write unit tests to validate the function with different sets of input data.
  4. 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.