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

Decimal value in trends widget #15

Open
amunz opened this issue May 1, 2018 · 2 comments
Open

Decimal value in trends widget #15

amunz opened this issue May 1, 2018 · 2 comments

Comments

@amunz
Copy link

amunz commented May 1, 2018

Hello,
I would like to add an issues closed over issues opened ratio to the trends widget in the Issue Trackers page. I have gotten it to show up, but the value is displayed as an integer when I would like for it to be a decimal.
issuesclosedopenedratio

I edited the /api/pages/issue/trends.py file to add the ratio.

    trends = {
        "created": {
            'before': no_issues_created_before,
            'after': no_issues_created,
            'title': "Issues opened this period"
        },
        "authors": {
            'before': no_creators_before,
            'after': no_creators,
            'title': "People opening issues this period"
        },
        "closed": {
            'before': no_issues_closed_before,
            'after': no_issues_closed,
            'title': "Issues closed this period"
        },
        "closers": {
            'before': no_closers_before,
            'after': no_closers,
            'title': "People closing issues this period"
        },
        "ratio":{
            'before': no_issues_closed_before / no_issues_created_before,
            'after': no_issues_closed/no_issues_created,
            'title': "Ratio of Issues Closed / Issues Opened"
        }
    }

I have tried casting the variables to a float, but the UI still displays an integer.
Any help would be appreciated. Thanks.

@Humbedooh
Copy link
Member

I suspect the JS is forcing integer values. I'll look into that. Perhaps we need to add an extra argument to the JSON output to specify that this is a float and should be presented as a float.

@Humbedooh
Copy link
Member

oh, I see the issue. You have to specify in python (2.7 at least) that you want a floating point result, or it will turn it into an integer. Something like:

"ratio":{
'before': 100 * no_issues_closed_before / no_issues_created_before / 100.0,
'after': 100 * no_issues_closed / no_issues_created / 100.0,
'title': "Ratio of Issues Closed / Issues Opened"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants