ubiquity-os-marketplace / daemon-pricing

0 stars 12 forks source link

Round decimal and eventually use a Decimal library #32

Closed gentlementlegen closed 1 week ago

gentlementlegen commented 1 month ago

When using certain duration settings, the pricing doesn't round up and ends with a lot of decimals. In this case the number should be properly calculated and eventually truncated if needed. This happens for example when setting a time like Time: <1 Minute.

Originally posted by @gentlementlegen in https://github.com/ubiquibot/sandbox/issues/23#issuecomment-2343101400

ubiquity-os[bot] commented 3 weeks ago
Deadline Thu, Sep 19, 11:04 AM UTC
Beneficiary 0x6321286F9B73f427C72e1f9F1bC6b3d25eF06605

[!TIP]

  • Use /wallet 0x0000...0000 if you want to update your registered payment wallet address.
  • Be sure to open a draft pull request as soon as possible to communicate updates on your progress.
  • Be sure to provide timely updates to us when requested, or you will be automatically unassigned from the task.
hhio618 commented 3 weeks ago

/start

ubiquity-os[bot] commented 3 weeks ago
Deadline Thu, Sep 19, 11:04 AM UTC
Beneficiary 0x6321286F9B73f427C72e1f9F1bC6b3d25eF06605

[!TIP]

  • Use /wallet 0x0000...0000 if you want to update your registered payment wallet address.
  • Be sure to open a draft pull request as soon as possible to communicate updates on your progress.
  • Be sure to provide timely updates to us when requested, or you will be automatically unassigned from the task.
0x4007 commented 3 weeks ago

Two start messages but only one assigned. This isn't right @gentlementlegen

Also it should assign and then post the start message.

gentlementlegen commented 3 weeks ago

@Keyrxng rfc

What I think happened is:

It should have just said "You are already assigned to this task" because it should have been the case.

ubiquity-os[bot] commented 1 week ago

 [ 75 WXDAI ] 

@hhio618
Contributions Overview
ViewContributionCountReward
IssueTask175
ReviewComment80
Conversation Incentives
CommentFormattingRelevanceReward
Resolves #32```ts// Examples:console.log(custo…
0
content:
  content:
    p:
      score: 0
      elementCount: 1
    pre:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 2
  wordValue: 0
  result: 0
0.7-
Appreciate the heads-up!
0.65
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 4
  wordValue: 0.2
  result: 0.65
0.1-
Hi @gentlementlegen, I've added the unit tests! May I ask what t…
2.44
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 19
  wordValue: 0.2
  result: 2.44
0.8-
@gentlementlegen, I see you've been working with a testing deplo…
8.38
content:
  content:
    p:
      score: 0
      elementCount: 3
    pre:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 81
  wordValue: 0.2
  result: 8.38
0.9-
## QAPlease refer to this Github issue:https://github.com/Ub…
3.11
content:
  content:
    h2:
      score: 1
      elementCount: 1
    p:
      score: 0
      elementCount: 2
  result: 1
regex:
  wordCount: 16
  wordValue: 0.2
  result: 2.11
0.2-
Hey @gentlementlegen, I’ve thrown in a few more test cases. Also…
3.7
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 31
  wordValue: 0.2
  result: 3.7
0.6-
@gentlementlegen Yeah, that happens sometimes LOL, did a cleanup.
1.29
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 9
  wordValue: 0.2
  result: 1.29
0.3-
@gentlementlegen Is there anything else to complete before mergi…
1.42
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 10
  wordValue: 0.2
  result: 1.42
0.2-

 [ 2.717 WXDAI ] 

@0x4007
Contributions Overview
ViewContributionCountReward
IssueComment10.966
ReviewComment41.751
Conversation Incentives
CommentFormattingRelevanceReward
Two start messages but only one assigned. This isn't right @gent…
1.38
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 22
  wordValue: 0.1
  result: 1.38
0.70.966
Bad approach use a number library so rounding is accurate. You'r…
1
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 15
  wordValue: 0.1
  result: 1
0.90.9
Seems close
0.18
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 2
  wordValue: 0.1
  result: 0.18
0.20.036
Probably should add more tests with two decimals and more decim…
0.77
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 11
  wordValue: 0.1
  result: 0.77
0.70.539
Two seem appropriate like traditional currency.
0.46
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 6
  wordValue: 0.1
  result: 0.46
0.60.276

 [ 25.752 WXDAI ] 

@gentlementlegen
Contributions Overview
ViewContributionCountReward
IssueSpecification19.06
IssueComment17.71
ReviewComment118.982
Conversation Incentives
CommentFormattingRelevanceReward
When using certain duration settings, the pricing doesn't round …
3.02
content:
  content:
    p:
      score: 0
      elementCount: 2
    em:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 55
  wordValue: 0.1
  result: 3.02
19.06
@Keyrxng rfcWhat I think happened is:- no user was assigned…
10.85
content:
  content:
    p:
      score: 0
      elementCount: 7
    ul:
      score: 1
      elementCount: 1
    li:
      score: 0.5
      elementCount: 4
  result: 3
regex:
  wordCount: 75
  wordValue: 0.2
  result: 7.85
0.67.71
Please add the required tests, otherwise good to go with the PR.
0.83
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 12
  wordValue: 0.1
  result: 0.83
0.70.581
It seems your last commit added a lot of files that should not b…
1.33
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 21
  wordValue: 0.1
  result: 1.33
0.60.798
Maybe add a test with `0.73 hours` or things like that t…
1.06
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 16
  wordValue: 0.1
  result: 1.06
0.80.848
I think you can use `as unknown as Context` to avoid dis…
0.59
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 8
  wordValue: 0.1
  result: 0.59
0.90.531
Should be removed.
0.25
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 3
  wordValue: 0.1
  result: 0.25
0.40.1
Should be removed.
0.25
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 3
  wordValue: 0.1
  result: 0.25
0.40.1
Should be removed.
0.25
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 3
  wordValue: 0.1
  result: 0.25
0.40.1
Could you add:- unit tests- a link to a QA test
2.77
content:
  content:
    p:
      score: 0
      elementCount: 3
    ul:
      score: 1
      elementCount: 1
    li:
      score: 0.5
      elementCount: 2
  result: 2
regex:
  wordCount: 11
  wordValue: 0.1
  result: 0.77
0.752.5775
@hhio618 Thank you. If you could try running it in your org with…
2.83
content:
  content:
    p:
      score: 0
      elementCount: 2
    hr:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 51
  wordValue: 0.1
  result: 2.83
0.651.8395
@hhio618 This might help you get started: https://github.com/ubi…
2.45
content:
  content:
    p:
      score: 0
      elementCount: 2
  result: 0
regex:
  wordCount: 43
  wordValue: 0.1
  result: 2.45
0.51.225
No, just a second pair of eyes, when @0x4007 approves it will ge…
0.94
content:
  content:
    p:
      score: 0
      elementCount: 1
  result: 0
regex:
  wordCount: 14
  wordValue: 0.1
  result: 0.94
0.30.282
0x4007 commented 1 week ago

@gentlementlegen my link doesn't work

gentlementlegen commented 1 week ago

@0x4007 This error seems familiar: https://github.com/ubiquity-os-marketplace/conversation-rewards/actions/runs/11165001249/job/31035657102#step:7:463

Error: Failed to get token decimals for token: 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d
    at ZB (/home/runner/work/conversation-rewards/conversation-rewards/node_modules/@ubiquibot/permit-generation/dist/core/index-BeQ_V1CH.js:31:1707)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async nb (/home/runner/work/conversation-rewards/conversation-rewards/node_modules/@ubiquibot/permit-generation/dist/core/index-BeQ_V1CH.js:31:4773)
    at PermitGenerationModule.transform (/home/runner/work/conversation-rewards/conversation-rewards/src/parser/permit-generation-module.ts:101:25)
    at Processor.run (/home/runner/work/conversation-rewards/conversation-rewards/src/parser/processor.ts:37:24)
    at run (/home/runner/work/conversation-rewards/conversation-rewards/src/run.ts:25:5)
0x4007 commented 5 days ago

@0x4007 This error seems familiar: https://github.com/ubiquity-os-marketplace/conversation-rewards/actions/runs/11165001249/job/31035657102#step:7:463

Error: Failed to get token decimals for token: 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d
    at ZB (/home/runner/work/conversation-rewards/conversation-rewards/node_modules/@ubiquibot/permit-generation/dist/core/index-BeQ_V1CH.js:31:1707)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async nb (/home/runner/work/conversation-rewards/conversation-rewards/node_modules/@ubiquibot/permit-generation/dist/core/index-BeQ_V1CH.js:31:4773)
    at PermitGenerationModule.transform (/home/runner/work/conversation-rewards/conversation-rewards/src/parser/permit-generation-module.ts:101:25)
    at Processor.run (/home/runner/work/conversation-rewards/conversation-rewards/src/parser/processor.ts:37:24)
    at run (/home/runner/work/conversation-rewards/conversation-rewards/src/run.ts:25:5)

@whilefoo can you make a fix for this?