You’re right. A hard-fought battle in the primaries is a tonic for the eventual nominee, unless he’s a sitting president. (See Carter and Ted Kennedy, or Bush and Buchanan for the latter.)
But that’s probably only because a sitting president already was coming from a weak position, otherwise they never would have gotten a primary challenge. So there’s no way to know that the fight didn’t help them hone their skills as well even if it wasn’t enough to win the contest.