move the map_stats math into the SQL db