Skip to content

Commit

Permalink
Fix get checks by tags (#29)
Browse files Browse the repository at this point in the history
* generate proper checks' tags Set so filter works

* Fixe code on some examples
  • Loading branch information
José Carlos Ferreiro authored and sekipaolo committed Aug 31, 2017
1 parent a38e858 commit 6223086
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ Retreive maintenance windows for production websites in the last 7 days:
.. code-block:: python
>>> import datetime
>>> checks = client.get_checks(filters={"tags": ["production": "frontend"]})
>>> checks = client.get_checks(filters={"tags": ["production", "frontend"]})
>>> start = datetime.datetime.now() - datetime.timedelta(days=7)
>>> client.get_maintenances(filters={"checks": checks, "after": start}):
>>> client.get_maintenances(filters={"checks": checks, "after": start})
Create a 1 hour maintenance window for production websites:

Expand All @@ -170,7 +170,7 @@ Create a 1 hour maintenance window for production websites:
>>> start = datetime.datetime.now() + datetime.timedelta(minutes=10)
>>> end = start + datetime.timedelta(hours=1)
>>> window = client.create_maintenance(filters={"checks": checks, "name": "pypingdom test maintenance", "start": start, "stop": stop})
>>> window = client.create_maintenance({"checks": checks, "name": "pypingdom test maintenance", "start": start, "stop": end})
Delete future maintenance windows:

Expand Down
2 changes: 1 addition & 1 deletion pypingdom/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_checks(self, filters=None):
filters = {}
res = []
for _name, check in self.checks.items():
if "tags" in filters and len(set(filters["tags"]).intersection(set(check.tags))) == 0:
if "tags" in filters and len(set(filters["tags"]).intersection(set([x['name'] for x in check.tags]))) == 0:
continue
res.append(check)
return res
Expand Down

0 comments on commit 6223086

Please sign in to comment.