{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE CPP                 #-}

module Distribution.Fedora.BodhiReleases
  (getBodhiReleases)
where

import Control.Exception.Extra (retry)
import Data.Aeson (Object)
import Fedora.Bodhi (bodhiReleases, makeKey)
import System.Cached.JSON

-- FIXME softer/warning on failure?
getBodhiReleases :: IO [Object]
getBodhiReleases :: IO [Object]
getBodhiReleases =
  Int -> IO [Object] -> IO [Object]
forall a. Int -> IO a -> IO a
retry Int
2 (IO [Object] -> IO [Object]) -> IO [Object] -> IO [Object]
forall a b. (a -> b) -> a -> b
$
  String -> String -> IO [Object] -> NominalDiffTime -> IO [Object]
forall a.
(FromJSON a, ToJSON a) =>
String -> String -> IO a -> NominalDiffTime -> IO a
getCachedJSONQuery String
"fedora" String
"bodhi-releases.json"
  (Query -> IO [Object]
bodhiReleases (String -> String -> Query
makeKey String
"exclude_archived" String
"True")) NominalDiffTime
450