Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reward month occurence should be dynamic #853

Merged

Conversation

tenmoves
Copy link
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #827

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • doctests
  • manual

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@tenmoves tenmoves added bug Something isn't working core team Assigned to the core team rewards labels Jan 19, 2023
@tenmoves tenmoves self-assigned this Jan 19, 2023
@tenmoves tenmoves requested a review from Neylix January 25, 2023 14:49
@@ -53,7 +53,17 @@ defmodule Archethic.Reward do
trunc(50 / uco_usd_price / number_of_reward_occurences_per_month * @unit_uco)
end

defp number_of_reward_occurences_per_month(), do: @number_of_reward_occurences_per_month
defp number_of_reward_occurences_per_month() do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, the function Utils.number_of_reward_occurences_per_month() is working well and the issue is that it was called only at compile time.

Isn't it possible to just move it to runtime like this ?

defp number_of_reward_occurences_per_month() do 
    datetime = NaiveDateTime.utc_now()
    interval = Application.get_env(:archethic, RewardScheduler)[:interval]
    Utils.number_of_reward_occurences_per_month(interval, datetime)
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no because in some cases depending on the interval it can take more than 1s to execute which is not acceptable

@Neylix Neylix merged commit dc716e7 into archethic-foundation:develop Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core team Assigned to the core team rewards
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reward month occurence is static
3 participants