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

cssColorClasses should be configurable #55

Closed
hexmode opened this issue Jun 17, 2016 · 1 comment
Closed

cssColorClasses should be configurable #55

hexmode opened this issue Jun 17, 2016 · 1 comment

Comments

@hexmode
Copy link
Contributor

hexmode commented Jun 17, 2016

Right now this is hard-coded into the class:

    public function __construct ( Title $title ) {

        $this->mTitle = $title;
        $this->cssColorClasses = array(
            'excellent',
            // 'good',
            'okay',
            // 'warning',
            'danger',
        );
    }

Instead the config object should be read. Defaults should be kept in extension.json.

@hexmode
Copy link
Contributor Author

hexmode commented Jun 17, 2016

Documentation should also be improved.

Right now, from looking at the code, it looks like you have two different arrays that determine which color class to use:

$GLOBALS['egWatchAnalyticsWatchQualityColors'] = array(
    // 6,   // score over 6   = excellent
    // 4,   // score over 4   = good
    // 1.5, // score over 1.5 = okay
    // 0.5, // score over 0.5 = not so good
         // score < 0.5    = bad

    5,   // score over 5   = excellent
    1.5, // score over 1.5 = okay
    // score < 1.5
);
$GLOBALS['egWatchAnalyticsReviewStatusColors'] = array(
    // 4, // 5+ reviews = excellent
    // 3, // 4 reviews  = good
    // 2, // 3 reviews  = okay
    // 1, // 2 reviews  = not so good
    //    // 0 or 1     = BAD

    4, // score over 4 = good
    2, // score over 2 = okay
    // 0 or 1 = BAD
);

This could be changed to something like:

$egWatchAnalyticsWatchQualityColors = [
    5     => 'excellent',
    1.5  => 'okay',
        null    => 'danger',
];
$egWatchAnalyticsReviewStatusColors' = [
    4  => 'excellent',
    2  => 'okay',
    null => 'danger'
];

I use null instead of 0 to allow for the possibility of negative scores.

Besides avoiding the hard-coding, it avoids problem where the number of cssColors wouldn't match the number of levels available -- a potentially subtle way to introduce problems.

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

1 participant