Skip to content

Commit

Permalink
Merge pull request #74 from anderssonoscar0/nightly
Browse files Browse the repository at this point in the history
Add Ombi Issues Count
  • Loading branch information
dirtycajunrice authored Dec 30, 2018
2 parents ec883b5 + d78f4fb commit f22c5eb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Varken.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def threaded(job):
schedule.every(server.request_type_run_seconds).seconds.do(threaded, OMBI.get_request_counts)
if server.request_total_counts:
schedule.every(server.request_total_run_seconds).seconds.do(threaded, OMBI.get_all_requests)
if server.issue_status_counts:
schedule.every(server.issue_status_run_seconds).seconds.do(threaded, OMBI.get_issue_counts)

if CONFIG.sickchill_enabled:
for server in CONFIG.sickchill_servers:
Expand Down
2 changes: 2 additions & 0 deletions data/varken.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ get_request_type_counts = true
request_type_run_seconds = 300
get_request_total_counts = true
request_total_run_seconds = 300
get_issue_status_counts = true
issue_status_run_seconds = 300

[sickchill-1]
url = sickchill.domain.tld:8081
Expand Down
7 changes: 6 additions & 1 deletion varken/iniparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,14 @@ def parse_opts(self):

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')
Expand Down
30 changes: 29 additions & 1 deletion varken/ombi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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):
Expand Down Expand Up @@ -162,3 +162,31 @@ def get_request_counts(self):
]

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)
7 changes: 7 additions & 0 deletions varken/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f22c5eb

Please sign in to comment.