Roundup Tracker - Issues

Issue 2550886

classification
Introduce an Integer class
Type: Severity: normal
Components: Infrastructure, Interface Versions: devel
process
Status: closed
:
: rouilj : antmail, rouilj
Priority: : patch

Created on 2015-06-18 10:59 by antmail, last changed 2016-06-05 04:55 by rouilj.

Files
File name Uploaded Description Edit Remove
intclass.patch antmail, 2015-06-18 10:59
int_1.diff antmail, 2016-06-03 15:35
int_2.diff antmail, 2016-06-03 15:35
int_3.diff antmail, 2016-06-03 15:35
Messages
msg5319 Author: [hidden] (antmail) Date: 2015-06-18 10:59
A Number class provided by roundup is a number of type Real. So, it
always come with a decimal part. But there is a rare case when Numbers
field used to store real type values. 

In common case there is a need to truncate decimal part to show it as
integer (at least, with Jinja engine).

So, i propose a patch (attached) to make Integer class available.
You can add fields of type Integer in common way in schema.py:

...=Class(...
value=Integer(),
...)

Needs testing.
msg5329 Author: [hidden] (rouilj) Date: 2015-06-28 03:26
Hello antmail:

Thanks for adding these patches. I have a few places
in my tracker (sysadmin) where integer only values
would be very useful.

However it looks like you forgot to diff the tests directory as
I don't see any changes to the tests. I assume you duplicated
the tests for Number to use the Integer class and verified that
they all pass. Those changes should be part of the patch as well.

Also on your patch you left a pdb load/call in there.
I also saw some whitepsace only changes that should be
be cleaned up.

Bernhard, any idea what docs need to be updated?

At least the docs/customizing.txt section on:

   Properties

should be updated to include Integer.

Also docs/FAQ.txt section on:

    How is sorting performed, and why does it seem to fail sometimes?

need to include integer sorting.

I think design.txt should stay as is since it's
a historic file and not current documentation.

antmail, can you fix these and post a new patch.
Then I'll work on applying the patch to the mainine code.
msg5338 Author: [hidden] (antmail) Date: 2015-06-29 11:31
If there is a plan to commit it i'll review it again. The  same  goes to other patches.

> John Rouillard added the comment:

> Hello antmail:

> Thanks for adding these patches. I have a few places
> in my tracker (sysadmin) where integer only values
> would be very useful.

> However it looks like you forgot to diff the tests directory as
> I don't see any changes to the tests. I assume you duplicated
> the tests for Number to use the Integer class and verified that
> they all pass. Those changes should be part of the patch as well.

> Also on your patch you left a pdb load/call in there.
> I also saw some whitepsace only changes that should be
> be cleaned up.

> Bernhard, any idea what docs need to be updated?

> At least the docs/customizing.txt section on:

>    Properties

> should be updated to include Integer.

> Also docs/FAQ.txt section on:

>     How is sorting performed, and why does it seem to fail sometimes?

> need to include integer sorting.

> I think design.txt should stay as is since it's
> a historic file and not current documentation.

> antmail, can you fix these and post a new patch.
> Then I'll work on applying the patch to the mainine code.

> ----------
> nosy: +rouilj

> ________________________________________________
> Roundup tracker <issues@roundup-tracker.org>
> <http://issues.roundup-tracker.org/issue2550886>
> ________________________________________________
msg5342 Author: [hidden] (rouilj) Date: 2015-07-05 23:42
I would like to commit this.

So please add tests and clean up the issues noted above
and I will work to get it in the main code.

-- rouilj
msg5553 Author: [hidden] (rouilj) Date: 2016-04-30 03:17
Anthony:

Were you able to clean up this patch so I can get it into the
code base?

-- rouilj
msg5572 Author: [hidden] (antmail) Date: 2016-06-03 15:35
Sorry for the late reply.

In attachment there are patches related to Integer class. 

> John Rouillard added the comment:

> Anthony:

> Were you able to clean up this patch so I can get it into the
> code base?

> -- rouilj

> ________________________________________________
> Roundup tracker <issues@roundup-tracker.org>
> <http://issues.roundup-tracker.org/issue2550886>
> ________________________________________________
msg5575 Author: [hidden] (rouilj) Date: 2016-06-04 03:24
Hi Anthony:

In your patch for roundup/hyperdb.py you have:

class Integer(_Type):
    """An object designating an integer property"""
    def from_raw(self, value, translator=translation, **kw):
        value = value.strip()
        ...

but there is no translation function/variable/... in the current
roundup code.

I removed that argument and it seems to have stopped the tests
from crashing. I also reverted a change you made to the testNumber
function in test/test_hyperdbvals.py.

-        self.assertEqual(self._test('number', '  10 '), 10)
+        self.assertEqual(self._test('number', '  1 '), 1)

I reinstated the test against 10 and removed the test against 1.

I also added test for:

    self.assertEqual(self._test('integer', '  0 '), 0)
    self.assertNotEqual(self._test('integer', '  -100.2 '), -100.2)

to testInteger since I assume it should truncate the .2, and I wanted to
test 0 as the midpoint of the range.

I also updated the docs to include Integer in the places where Number
was mentioned.

I am currently running:

  python run_tests.py -k 'not test_postgresql'

if it all passes I plan on checking it in unless you have an issue
with my changes above.
msg5576 Author: [hidden] (antmail) Date: 2016-06-04 10:41
Dear, John.

(****)
> In your patch for roundup/hyperdb.py you have:
> but there is no translation function/variable/... in the current
> roundup code.

 It   seems  to  be  related  to  my  patch   "[issue2550871]  Extending
translation ability (for date at least)".

> I removed that argument and it seems to have stopped the tests
> from crashing. I also reverted a change you made to the testNumber
> function in test/test_hyperdbvals.py.

> -        self.assertEqual(self._test('number', '  10 '), 10)
> +        self.assertEqual(self._test('number', '  1 '), 1)

> I reinstated the test against 10 and removed the test against 1.

I have no objection. I've set 10 to distinct from boolean values which
may be presented as 1/0.  I've thought that there may be a bad case when
test  for 1 passed but internally parsed as Boolean value. This is the
reason why I use 10. But it doesn't matter.

> I also added test for:

>     self.assertEqual(self._test('integer', '  0 '), 0)
>     self.assertNotEqual(self._test('integer', '  -100.2 '), -100.2)

> to testInteger since I assume it should truncate the .2, and I wanted to
> test 0 as the midpoint of the range.

I really welcome extending the test cases.

> I also updated the docs to include Integer in the places where Number
> was mentioned.

It's  the  most  hard  work for me because of my poor English.  Really
thank you that you made it.

> I am currently running:

>   python run_tests.py -k 'not test_postgresql'

> if it all passes I plan on checking it in unless you have an issue
> with my changes above.

If review of patch "[issue2550871]  Extending
translation  ability"  is  delayed for indefinitely then support of Integer
may  be  applied  as described above. If progress on [issue2550871] is
coming   then   Integer   support   may   be  applied  without changes
mentioned in (****).

> ________________________________________________
> Roundup tracker <issues@roundup-tracker.org>
> <http://issues.roundup-tracker.org/issue2550886>
> ________________________________________________
msg5577 Author: [hidden] (rouilj) Date: 2016-06-05 04:55
Committed as: e424987d294a
History
Date User Action Args
2016-06-05 05:29:27rouiljlinkissue2550871 dependencies
2016-06-05 04:55:51rouiljsetstatus: open -> closed
2016-06-05 04:55:35rouiljsetmessages: + msg5577
2016-06-04 10:41:07antmailsetmessages: + msg5576
2016-06-04 03:26:54rouiljsetassignee: rouilj
2016-06-04 03:24:57rouiljsetmessages: + msg5575
2016-06-03 15:35:54antmailsetfiles: + int_1.diff, int_2.diff, int_3.diff
messages: + msg5572
2016-04-30 03:17:58rouiljsetmessages: + msg5553
2015-07-05 23:42:25rouiljsetstatus: new -> open
messages: + msg5342
2015-06-29 11:31:00antmailsetmessages: + msg5338
2015-06-28 03:26:39rouiljsetnosy: + rouilj
messages: + msg5329
2015-06-18 10:59:27antmailcreate