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

Simplify function parameters #4

Closed
klahnakoski opened this issue Mar 29, 2016 · 1 comment
Closed

Simplify function parameters #4

klahnakoski opened this issue Mar 29, 2016 · 1 comment

Comments

@klahnakoski
Copy link
Contributor

Changing the function parameter names will simplify the functions using those parameters:

function executeQuery1(param) {
    var test = param.test;
    var buildRevision = param.buildRevision;
    var query = {
        "limit": 10000,
        "where": {
            "eq":{
                "test.url": test,
                "build.revision": buildRevision
            }
        },
        "groupby": ["source.file"],
        "from": "coverage"
    };

can be changed to

function executeQuery1(eqParam) {
    var query = {
        "limit": 10000,
        "where": {
            "eq":eqParam
        },
        "groupby": ["source.file"],
        "from": "coverage"
    };

if your calls parameters are changed

executeQuery1({
    "test.url": test
    "build.revision": buildRevision
})

this allows you to add additional filters with no change to the called code:

executeQuery1({
    "test.url": test
    "build.revision": buildRevision,
    "build.platform": "linux64"
})

You could bring this a step further, and accept a whole where clause ias a parameter:

function executeQuery1(where) {
    var query = {
        "limit": 10000,
        "where": where,
        "groupby": ["source.file"],
        "from": "coverage"
    };

Your call is more complicated,

executeQuery1({"eq": {
    "test.url": test
    "build.revision": buildRevision,
}});

... but you have more sophisticated filtering options:

executeQuery1({"and":[
    {"gt":{"run.timestamp":{"date":"yesterday"}}},
    {"eq": {
        "test.url": test
        "build.revision": buildRevision,
    }}
]})
@chinhodado
Copy link
Owner

Done with 638d30b

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