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

@ -179,9 +179,14 @@ class INIParser(object):
request_total_run_seconds = self.config.getint(section, 'request_total_run_seconds')
issue_status_counts = self.config.getboolean(section, 'get_issue_status_counts')
issue_status_run_seconds = self.config.getint(section, 'issue_status_run_seconds')
server = OmbiServer(server_id, scheme + url, apikey, verify_ssl, request_type_counts,
request_type_run_seconds, request_total_counts,
request_total_run_seconds)
request_total_run_seconds, issue_status_counts,
issue_status_run_seconds)
if service == 'sickchill':
get_missing = self.config.getboolean(section, 'get_missing')

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)

View file

@ -61,6 +61,8 @@ class OmbiServer(NamedTuple):
request_type_run_seconds: int = 30
request_total_counts: bool = False
request_total_run_seconds: int = 30
issue_status_counts: bool = False
issue_status_run_seconds: int = 30
class TautulliServer(NamedTuple):
@ -106,6 +108,11 @@ class OmbiRequestCounts(NamedTuple):
approved: int = 0
available: int = 0
class OmbiIssuesCounts(NamedTuple):
pending: int = 0
inProgress: int = 0
resolved: int = 0
class TautulliStream(NamedTuple):
rating: str = None