Postgresql after 'for each row' triggers don't actually execute after each row?
Since the your INSERT and UPDATE are atomic (either all rows inserted/updated or none), you cannot catch a state when the count will not be 5 or 0.  First the INSERT happens, then the trigger is fired for all the rows.