import json


def _hash_task(task):
    """ Returns a unique hash for identify a task and its params """

    params = task.get("params")
    if params:
        params = json.dumps(sorted(list(task["params"].items()), key=lambda x: x[0]))  # pylint: disable=no-member

    full = [str(task.get(x)) for x in ["path", "interval", "dailytime", "weekday", "monthday", "queue"]]

    full.extend([str(params)])
    return " ".join(full)