Closed 0x4007 closed 3 months ago
It looks like it's failing for the word "constructor" as far as I can tell, using the rpc-racer as a base for testing. I'm just running a script calling aggregateAndScoreContributions(..args)
but I'm unfamiliar with the specifics of this part of the codebase
this fails in and of itself
const wordScoreCommentDetails: { [key: string]: Decimal } = {};
const words = ["function", "was", "async", "but", "the", "constructor", "isn", "t", "I", "was"];
const ZERO = new Decimal(0);
const roleWordScore = new Decimal(0.1);
for (const word of words) {
let counter = wordScoreCommentDetails[word] || ZERO;
counter = counter.plus(roleWordScore);
wordScoreCommentDetails[word] = counter;
}
the word constructor can't be used as a key or it's touching the object constructor
const wordScoreCommentDetails: { [key: string]: Decimal } = {};
const words = ["function", "was", "async", "but", "the", "constructor", "isn", "t", "I", "was"];
const ZERO = new Decimal(0);
for (const word of words) {
let counter = wordScoreCommentDetails[word] || ZERO;
wordScoreCommentDetails[word] = counter;
}
console.log("scoringDetails: ", wordScoreCommentDetails);
scoringDetails: {
function: 0,
was: 0,
async: 0,
but: 0,
the: 0,
constructor: [Function: Object],
isn: 0,
t: 0,
I: 0
}
_getWordsNotInDisabledElements()
seems like the only sort of 'blacklist' but it's for elements as opposed to literal strings, have I missed in it the codebase or is there a need to add something like it for literals?
No there is no blacklist for words. Great find @Keyrxng!
No there is no blacklist for words. Great find @Keyrxng!
What's the approach then just wrap it in a try catch and log the failed word(s) or implement something a bit more robust?
It might be an idea to exclude reserved words like ["constructor", "toString", "prototype", etc] but it'll essentially be the same as try, catch, log wouldn't it and would need manually updated if more are found
You can dynamically generate a blacklist based on all of the properties of the scoringDetails
object.
It's not the right approach but we are going to have a brand new codebase to replace all this soon enough.
The alternative would be to design some type of encoding schema that will guarantee no collisions with the built in object properties (base64?) or alternatively just using some type of different data type to handle these words.
+ Evaluating results. Please wait...
View | Contribution | Count | Reward |
---|---|---|---|
Issue | Specification | 1 | 41.8 |
Issue | Comment | 2 | 18 |
Review | Comment | 1 | 6.2 |
Comment | Formatting | Relevance | Reward |
---|---|---|---|
There's an issue I've never seen before. Please research a solut... | 41.8code: count: 1 score: "1" words: 0 | 1 | 41.8 |
No there is no blacklist for words. Great find @Keyrxng!... | 2 | 0.74 | 2 |
You can dynamically generate a blacklist based on all of the pro... | 16code: count: 1 score: "1" words: 1 | 0.675 | 16 |
You can definitely include `my.ts` as a jest test. Just name it ... | 6.2code: count: 1 score: "2" words: 2 | 0.62 | 6.2 |
View | Contribution | Count | Reward |
---|---|---|---|
Issue | Comment | 1 | 3.2 |
Review | Comment | 1 | 8.4 |
Comment | Formatting | Relevance | Reward |
---|---|---|---|
relates to the [decimal.js](https://www.npmjs.com/package/decima... | 3.2a: count: 1 score: "1" words: 2 | 0.83 | 3.2 |
the only viable way i'd see testing this in a production like en... | 8.4 | 0.55 | 8.4 |
View | Contribution | Count | Reward |
---|---|---|---|
Issue | Task | 1 | 75 |
Issue | Comment | 4 | 0 |
Comment | Formatting | Relevance | Reward |
---|---|---|---|
It looks like it's failing for the word "constructor" as far as ... | -li: count: 2 score: "0" words: 8 code: count: 1 score: "0" words: 2 | 0.78 | - |
this fails in and of itself ```ts const wordScoreCommentDet... | -code: count: 3 score: "0" words: 0 | 0.62 | - |
``_getWordsNotInDisabledElements()`` seems like the only sort of... | -code: count: 1 score: "0" words: 1 | 0.56 | - |
> No there is no blacklist for words. Great find @Keyrxng! Wh... | - | 0.71 | - |
working https://github.com/ubiquibot/comment-incentives/actions/runs/8288619639, nice hack! @Keyrxng
I'm full of them đŸ˜‚
There's an issue I've never seen before. Please research a solution before we fund this issue.
Source https://github.com/ubiquibot/comment-incentives/actions/runs/8002349026/job/21855360540#step:5:262 Related https://github.com/ubiquity/nft-rewards/issues/3#issuecomment-1959049060