|
|
|
@ -28,6 +28,23 @@ instance ToJSON FinalResult where |
|
|
|
|
toJSON FinalResult{..} = |
|
|
|
|
object [ "id" .= resultId, "ct" .= resultCountry, "cn" .= resultContinent, "g" .= resultGoals ] |
|
|
|
|
|
|
|
|
|
---- |
|
|
|
|
|
|
|
|
|
data WorldcupData = WorldcupData { |
|
|
|
|
worldcupTeams :: Teams, |
|
|
|
|
worldcupCountries :: Countries, |
|
|
|
|
worldcupContinents :: Continents, |
|
|
|
|
worldcupTourneys :: Tourneys |
|
|
|
|
} deriving (Show) |
|
|
|
|
|
|
|
|
|
type Tourneys = HashMap String Tourney |
|
|
|
|
|
|
|
|
|
data Tourney = Tourney { |
|
|
|
|
tourneyGames :: [Game], |
|
|
|
|
tourneyTeams :: [Int] } deriving (Show) |
|
|
|
|
|
|
|
|
|
---- |
|
|
|
|
|
|
|
|
|
parseInt :: Value -> Int |
|
|
|
|
parseInt Null = 0 |
|
|
|
|
parseInt x = read $ BL8.unpack $ encode x :: Int |
|
|
|
@ -55,6 +72,9 @@ buildFinalResult ets hmT hmC hmN gs = P.foldl reducer [] ets where |
|
|
|
|
getContinentName x = continentName (continentFromTeamId x hmT hmC hmN) |
|
|
|
|
goalCount x = goalsFromTeamId x gs |
|
|
|
|
|
|
|
|
|
buildWorldcupData :: WorldcupData |
|
|
|
|
buildWorldcupData = WorldcupData HM.empty HM.empty HM.empty HM.empty |
|
|
|
|
|
|
|
|
|
main :: IO () |
|
|
|
|
main = do |
|
|
|
|
dataTeams <- BL.readFile "./data/teams.json" |
|
|
|
@ -73,8 +93,10 @@ main = do |
|
|
|
|
let continents = parseContinents (AE.eitherDecode dataContinents) |
|
|
|
|
let rounds = parseRounds (AE.eitherDecode dataRounds) |
|
|
|
|
|
|
|
|
|
let encoded = encode $ buildFinalResult eventteams teams countries continents games |
|
|
|
|
BL8.putStrLn encoded |
|
|
|
|
P.putStrLn $ show (P.length eventteams) ++ " teams found." |
|
|
|
|
BL8.putStrLn "Writing teams.json" |
|
|
|
|
BL8.writeFile "teams.json" encoded |
|
|
|
|
print events |
|
|
|
|
|
|
|
|
|
-- let encoded = encode $ buildFinalResult eventteams teams countries continents games |
|
|
|
|
-- BL8.putStrLn encoded |
|
|
|
|
-- P.putStrLn $ show (P.length eventteams) ++ " teams found." |
|
|
|
|
-- BL8.putStrLn "Writing teams.json" |
|
|
|
|
-- BL8.writeFile "teams.json" encoded |
|
|
|
|