Giter VIP home page Giter VIP logo

Comments (7)

igorkasyanchuk avatar igorkasyanchuk commented on June 8, 2024

@synth can you make a fix? it looks like a very simple fix, and it would be great if you can make it.

Sample: https://github.com/igorkasyanchuk/rails_db/blob/rails_4_x/lib/rails_db/table.rb#L65

from rails_performance.

synth avatar synth commented on June 8, 2024

I spent an hour trying to do it, but I'm not too familiar with ActiveSupport::Duration's nor the internals of this gem. Can you provide some insight on what Utils.days is and how it's used?

I tried

      ActiveSupport::Duration.parse("PT#{RP.duration % 24.days}S").parts[:days] + 1

but there is no days part.

In Rails 5.0.x RP.duration % 24.days is 14400 in seconds, so I'm pretty confused on why this references the :days key in parts.

from rails_performance.

igorkasyanchuk avatar igorkasyanchuk commented on June 8, 2024

image
maybe you can just use source code ? I mean just add this method dynamically to the ActiveSupport::Duration and patch it (backport)? if Rails version is 5.0

it basically counts number of the days added to the configuration

from rails_performance.

synth avatar synth commented on June 8, 2024

what is the significance of 24.days? I'm confused on why you would mod 4.hours with 24.days...Should this be 24.hours instead?

And also why do you add +1?

It will also help me if you can clarify what the expected default return value is. Is it 14400 seconds (4 hours)?

from rails_performance.

igorkasyanchuk avatar igorkasyanchuk commented on June 8, 2024

If you have 4 hours it will return 0+1
If you have 32 hours it will be 1+1
I need to count number of days covered in range, and minimum is 1

from rails_performance.

synth avatar synth commented on June 8, 2024

Right, so if you are counting days, it should be 24.hours, not 24.days. I'll try to put some time into this today and see what I can come up with.

from rails_performance.

synth avatar synth commented on June 8, 2024

Ok, proposed fix in #4

from rails_performance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.