Find condition calculation

I’m trying to do a find with a particular condition.

I have a runs table with a n_passed_steps column and an n_failed_steps
column.

I’m trying to do a find, to find all records, limited to the last 10,
ordered by descending id, but with a pass percentage rate greater than
50%.

So i’ve got the :all, :limit => 10, :order => ‘id DESC’ bit, it’s just
the :conditions bit I’m struggling with.

The calculation is ((n_passed_steps/(n_passed_steps + n_failed_steps)) *
100) > 50 but if I simply insert that after :conditions, whether it be
in ‘quotes’ or [square brackets] I get an error.

What is the correct way to go about this?

HI Paul,

What’s your error? Also, post to us the dbms you’re using and maybe the
schema of your table (migration?) and the snippet being used for the
find.

We need more info in order to effectively help you!

Regards,


Peter F.

iPhone – “IT”-ness.
href=
Apple’s iPhone could become iconic ‘It Object’ - MacDailyNews

On Jul 12, 2007, at 5:12 AM, Paul N. wrote:

the :conditions bit I’m struggling with.

The calculation is ((n_passed_steps/(n_passed_steps +
n_failed_steps)) *
100) > 50 but if I simply insert that after :conditions, whether it be
in ‘quotes’ or [square brackets] I get an error.

What is the correct way to go about this?

Don’t try so hard:

:conditions => ‘n_passed_steps > n_failed_steps’

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Rob B. wrote:

On Jul 12, 2007, at 5:12 AM, Paul N. wrote:

the :conditions bit I’m struggling with.

The calculation is ((n_passed_steps/(n_passed_steps +
n_failed_steps)) *
100) > 50 but if I simply insert that after :conditions, whether it be
in ‘quotes’ or [square brackets] I get an error.

What is the correct way to go about this?

Don’t try so hard:

:conditions => ‘n_passed_steps > n_failed_steps’

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

That’s so obvious now you mention it!

However… the 50% figure was just as an example. Say I wanted to set
the pass rate to something else?

On Jul 13, 2007, at 4:51 AM, Paul N. wrote:

What is the correct way to go about this?
That’s so obvious now you mention it!

However… the 50% figure was just as an example. Say I wanted to set
the pass rate to something else?

Assuming: 0…100 === pass_rate,

:conditions => [ ‘(100.0 * n_passed_steps)/(n_passed_steps +
n_failed_steps) > ?’,
pass_rate ]

-Rob

Rob B. http://agileconsultingllc.com
[email protected]