Merge pull request #74 from anderssonoscar0/nightly

Add Ombi Issues Count
This commit is contained in:
Nicholas St. Germain 2018-12-29 21:53:19 -06:00 committed by GitHub
commit 21a559fccc
5 changed files with 46 additions and 2 deletions

View file

@ -3,7 +3,7 @@ from requests import Session, Request
from datetime import datetime, timezone
from varken.helpers import connection_handler, hashit
from varken.structures import OmbiRequestCounts, OmbiMovieRequest, OmbiTVRequest
from varken.structures import OmbiRequestCounts, OmbiIssuesCounts, OmbiMovieRequest, OmbiTVRequest
class OmbiAPI(object):
@ -162,3 +162,31 @@ class OmbiAPI(object):
]
self.dbmanager.write_points(influx_payload)
def get_issue_counts(self):
now = datetime.now(timezone.utc).astimezone().isoformat()
endpoint = '/api/v1/Issues/count'
req = self.session.prepare_request(Request('GET', self.server.url + endpoint))
get = connection_handler(self.session, req, self.server.verify_ssl)
if not get:
return
requests = OmbiIssuesCounts(**get)
influx_payload = [
{
"measurement": "Ombi",
"tags": {
"type": "Issues_Counts"
},
"time": now,
"fields": {
"pending": requests.pending,
"in_progress": requests.inProgress,
"resolved": requests.resolved
}
}
]
self.dbmanager.write_points(influx_payload)