# HG changeset patch # User unc0rr # Date 1377452627 -14400 # Node ID 49eb707b936715df45e68ff234a0188a841f7ffa # Parent 43798a77f1d16abb7aa9f32c4d6dc76d594366ec Extract time from file name, assuming it is stored in 'replay' folder diff -r 43798a77f1d1 -r 49eb707b9367 gameServer/OfficialServer/extdbinterface.hs --- a/gameServer/OfficialServer/extdbinterface.hs Sun Aug 25 00:03:00 2013 +0400 +++ b/gameServer/OfficialServer/extdbinterface.hs Sun Aug 25 21:43:47 2013 +0400 @@ -23,7 +23,7 @@ "INSERT INTO gameserver_stats (players, rooms, last_update) VALUES (?, ?, UNIX_TIMESTAMP())" dbQueryAchievement = - "INSERT INTO achievements (typeid, userid, value, filename, location) \ + "INSERT INTO achievements (time, typeid, userid, value, filename, location) \ \ VALUES ((SELECT id FROM achievement_types WHERE name = ?), (SELECT uid FROM users WHERE name = ?), \ \ ?, ?, ?)" @@ -57,14 +57,18 @@ StoreAchievements fileName teams info -> mapM_ (run dbConn dbQueryAchievement) $ (parseStats fileName teams) info +readTime = read . B.unpack . B.take 19 . B.drop 8 + parseStats :: B.ByteString -> [(B.ByteString, B.ByteString)] -> [B.ByteString] -> [[SqlValue]] parseStats fileName teams = ps where + time = readTime fileName ps [] = [] ps ("DRAW" : bs) = ps bs ps ("WINNERS" : n : bs) = ps $ drop (readInt_ n) bs ps ("ACHIEVEMENT" : typ : teamname : location : value : bs) = - [SqlByteString typ + [ SqlUTCTime time + , SqlByteString typ , SqlByteString $ fromMaybe "" (lookup teamname teams) , SqlInt32 (readInt_ value) , SqlByteString fileName