Skip to content

Commit

Permalink
Merge pull request #5 from permaweb/twilson63/feat-vouch-x-add-confid…
Browse files Browse the repository at this point in the history
…ence-3

fix: bug with user.fields and twitter #3
  • Loading branch information
twilson63 authored May 21, 2024
2 parents 14ab97f + b038cba commit 3fd7b1a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/lib/calc-confidence-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const LISTED_WEIGHT = 0.05
export function calculate(user) {
// calculateConfidenceValue.js
const { followers_count, tweet_count, listed_count } = user.public_metrics;
const verified = user.verified ? user.verified !== 'none' : false;
const verified = user.verified;

const confidenceValue = Math.floor((tweet_count * TWEET_WEIGHT) +
(followers_count * FOLLOWER_WEIGHT) +
Expand Down
2 changes: 1 addition & 1 deletion server/routes/x.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function callback(req, res) {
})
// get created at and return to client
//
const params = { 'user.fields': 'created_at' }
const params = { 'user.fields': 'created_at,public_metrics,verified' }
client.get('users/me', params).then(async ({ data }) => {
console.log(data)
await vouch(data.created_at, req.session.address, data.username, calculate(data))
Expand Down
8 changes: 4 additions & 4 deletions server/test/confidence-value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('calculate the correct confidence value for a verified user', () => {
tweet_count: 4534,
listed_count: 23
},
verified: 'blue'
verified: true
};
const expectedValue = Math.floor((4534 * 0.001) + (1045 * 0.02) + (23 * 0.05) + 8.00);
const confidenceValue = calculate(userMetrics);
Expand All @@ -23,7 +23,7 @@ test('calculate the correct confidence value for a non-verified user', () => {
tweet_count: 4534,
listed_count: 23
},
verified: 'none'
verified: false
};
const expectedValue = Math.floor((4534 * 0.001) + (1045 * 0.02) + (23 * 0.05));
const confidenceValue = calculate(userMetrics);
Expand All @@ -50,7 +50,7 @@ test('calculate the correct confidence value when some metrics are zero', () =>
tweet_count: 0,
listed_count: 0
},
verified: 'blue'
verified: true
};
const expectedValue = 8.00;
const confidenceValue = calculate(userMetrics);
Expand All @@ -64,7 +64,7 @@ test('calculate the correct confidence value when all metrics are zero and user
tweet_count: 0,
listed_count: 0
},
verified: 'none'
verified: false
};
const expectedValue = 0;
const confidenceValue = calculate(userMetrics);
Expand Down

0 comments on commit 3fd7b1a

Please sign in to comment.