Next / Previous / Contents / TCC Help System / NM Tech homepage

39. AccessSummary.genByHits(): Generate the hit parade

webstats.py
# - - -   A c c e s s S u m m a r y . g e n B y H i t s

    def genByHits ( self ):
        '''Generate the hit parade.
        '''

This is the Big Sort: the values in self.__urlMap are the complete set of HitCount instances. If we sort that set, the HitCount.__cmp__() method puts them in the desired order: descending order by hit count, with ascending order by URL the secondary key.

Note that this method does not check for a minimum hit count. The caller should do that, terminating the generator when it starts return entries with too few hits.

webstats.py
        #-- 1 --
        for hitCount in sorted(self.__urlMap.values()):
            yield hitCount

        #-- 2 --
        raise StopIteration