# Buggy code
def next_run(self):
    """Return when backlog should run next."""
    if self.action._last_backlog <= 1:
        return datetime.date.today()
    else:
        return datetime.date.fromordinal(
            self.action._last_backlog + self.action.cycleTime
        )


# Traceback (TypeError)
2017-11-11 19:37:28 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.stats', 'indexerid': '269750'}
2017-11-11 19:37:28 DEBUG    TORNADO :: [b16e0e5] API :: show.stats: {'indexerid': '269750'}
2017-11-11 19:37:28 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:28 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:28 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.stats', 'indexerid': '296762'}
2017-11-11 19:37:28 DEBUG    TORNADO :: [b16e0e5] API :: show.stats: {'indexerid': '296762'}
2017-11-11 19:37:28 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+21&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:28 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:28 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:28 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 021
2017-11-11 19:37:30 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+021&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:30 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:30 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:31 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search mode: Episode
2017-11-11 19:37:31 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 22
2017-11-11 19:37:32 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:32 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:32 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.seasonlist', 'indexerid': '323168'}
2017-11-11 19:37:32 DEBUG    TORNADO :: [b16e0e5] API :: show.seasonlist: {'indexerid': '323168'}
2017-11-11 19:37:33 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+22&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:33 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:33 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:33 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 022
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.seasonlist', 'indexerid': '323168'}
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: show.seasonlist: {'indexerid': '323168'}
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.addnew', 'help': '1'}
2017-11-11 19:37:33 DEBUG    TORNADO :: [b16e0e5] API :: show.addnew: {'help': '1'}
2017-11-11 19:37:35 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+022&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:35 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:35 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:35 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search mode: Episode
2017-11-11 19:37:35 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 23
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.addnew', 'help': '1'}
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: show.addnew: {'help': '1'}
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.seasons', 'season': '2', 'indexerid': '323168'}
2017-11-11 19:37:36 DEBUG    TORNADO :: [b16e0e5] API :: show.seasons: {'season': '2', 'indexerid': '323168'}
2017-11-11 19:37:38 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+23&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:38 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:38 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:38 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 023
2017-11-11 19:37:39 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:39 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:39 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'show.addnew', 'help': '1'}
2017-11-11 19:37:39 DEBUG    TORNADO :: [b16e0e5] API :: show.addnew: {'help': '1'}
2017-11-11 19:37:40 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+023&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:40 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:40 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:40 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search mode: Episode
2017-11-11 19:37:40 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 24
2017-11-11 19:37:42 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+24&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:42 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:42 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:42 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 024
2017-11-11 19:37:44 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+024&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:44 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:44 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:45 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search mode: Episode
2017-11-11 19:37:45 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 25
2017-11-11 19:37:47 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] GET URL: **********api?apikey=**********&maxage=1500&cat=5030%2C5040&q=Dragon+Ball+25&limit=100&t=search&offset=0 [Status: 200]
2017-11-11 19:37:47 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] User-Agent: Medusa/0.0.1 (Linux; 4.2.8; f84e2c22-c327-11e7-8b77-00089bcba4cc)
2017-11-11 19:37:47 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] No results returned from provider. Check chosen Newznab search categories in provider settings and/or usenet retention
2017-11-11 19:37:47 DEBUG    SEARCHQUEUE-BACKLOG-76666 :: [NZBPLANET] :: [b16e0e5] Search show using search string: Dragon Ball 025
2017-11-11 19:37:49 DEBUG    TORNADO :: [b16e0e5] API :: 127.0.0.1 - gave correct API KEY. ACCESS GRANTED
2017-11-11 19:37:49 DEBUG    TORNADO :: [b16e0e5] API :: all args: ()
2017-11-11 19:37:49 DEBUG    TORNADO :: [b16e0e5] API :: all kwargs: {'cmd': 'sb.checkscheduler'}
2017-11-11 19:37:49 DEBUG    TORNADO :: [b16e0e5] API :: sb.checkscheduler: {}
2017-11-11 19:37:49 ERROR    TORNADO :: [b16e0e5] API :: 'integer argument expected, got float'
Traceback (most recent call last):
  File "/share/CACHEDEV1_DATA/.qpkg/Medusa/Medusa/medusa/server/api/v1/core.py", line 126, in get
    out_dict = _call_dispatcher(args, kwargs)
  File "/share/CACHEDEV1_DATA/.qpkg/Medusa/Medusa/medusa/server/api/v1/core.py", line 196, in call_dispatcher
    cur_out_dict = func(cur_args, cur_kwargs).run()  # call function and get response
  File "/share/CACHEDEV1_DATA/.qpkg/Medusa/Medusa/medusa/server/api/v1/core.py", line 1423, in run
    next_backlog = app.backlog_search_scheduler.next_run().strftime(dateFormat).decode(app.SYS_ENCODING)
  File "/share/CACHEDEV1_DATA/.qpkg/Medusa/Medusa/medusa/search/backlog.py", line 33, in next_run
    return datetime.date.fromordinal(self.action._last_backlog + self.action.cycleTime)
TypeError: integer argument expected, got float

# Fixed code
def next_run(self):
    """Return when backlog should run next."""
    if self.action._last_backlog <= 1:
        return datetime.date.today()
    else:
        backlog_frequency_in_days = int(self.action.cycleTime)
        return datetime.date.fromordinal(
            self.action._last_backlog + backlog_frequency_in_days
        )