ubiquity-os-marketplace / daemon-pricing

0 stars 12 forks source link

fix: round decimals #35

Closed hhio618 closed 1 week ago

hhio618 commented 3 weeks ago

Resolves #32

// Examples:
console.log(customTruncate(1.799999));          // Output: 1
console.log(customTruncate(3.00000001));        // Output: 3
console.log(customTruncate(3.001));             // Output: 3
console.log(customTruncate(456.99999999998));   // Output: 457
console.log(customTruncate(10.689876543));      // Output: 10
gentlementlegen commented 3 weeks ago

Could you add:

hhio618 commented 3 weeks ago

Hi @gentlementlegen, I've added the unit tests! May I ask what type of QA testing you would like?

gentlementlegen commented 2 weeks ago

@hhio618 Thank you. If you could try running it in your org with a configuration containing 1 minute for valid time and show that tags are properly generated, that would be great.


Tested within my own org with 1.5 minutes which seemed to price the task at 0 USD: https://github.com/Meniole/assistive-pricing/issues/2

hhio618 commented 2 weeks ago

@gentlementlegen, I see you've been working with a testing deployment of UbiquityOS. It would be really helpful for me to get my instance up and running as well, but I couldn't find the installation documentation. Could you share a link if you have it?

Also, I saw that you've deployed this plugin with basePriceMultiplier: 1. Just a quick heads-up: with these configurations, the price calculation would be:

price = base x 1000 x calculateLabelValue("<1.5 minutes") x (priority / 10) = 
1 x 1000 x (1.5 x 0.002) x 0.1 = 0.3 // which will be rounded to 0

We could round this up to 1 instead, what do you think?

gentlementlegen commented 2 weeks ago

@hhio618 This might help you get started: https://github.com/ubiquity/ubiquibot-kernel/wiki/Hello-world-plugin-onboarding-tutorial

0.3 is a valid price, We do support decimals, I do not know how many we want for the pricing tag, @0x4007 would know better.

0x4007 commented 2 weeks ago

I do not know how many we want for the pricing tag

Two seem appropriate like traditional currency.

hhio618 commented 2 weeks ago

Could you add:

  • unit tests
  • a link to a QA test

QA

Please refer to this Github issue: https://github.com/Ubiquity-test/ubiquity-sandbox/issues/7

hhio618 commented 2 weeks ago

Hey @gentlementlegen, I’ve thrown in a few more test cases. Also, just realized the calculateLabelValue function turns the input time into an integer, so those decimal places are getting tossed anyway.

hhio618 commented 1 week ago

@gentlementlegen Yeah, that happens sometimes LOL, did a cleanup.

hhio618 commented 1 week ago

@gentlementlegen Is there anything else to complete before merging this?

gentlementlegen commented 1 week ago

No, just a second pair of eyes, when @0x4007 approves it will get merged.