The Creators who have been most-read, ordered by number of read
        publications (ignoring if any of those publicatinos have been read
        multiple times.)

        Each Creator will have a `num_publications` attribute.
431432
def by_publications(self):
        
        if not spectator_apps.is_enabled('reading'):
            raise ImproperlyConfigured("To use the CreatorManager.by_publications() method, 'spectator.reading' must by in INSTALLED_APPS.")

        qs = self.get_queryset()

        qs = qs.exclude(publications__reading__isnull=True) \
                    .annotate(num_publications=Count('publications')) \
                    .order_by('-num_publications', 'name_sort')

        return qs
813390
public function findAllPublishedOrdered()
    {
        $builder = $this->createQueryBuilder('a')->orderBy('a.startedAt', 'DESC');

        return $builder->where(
            $builder->expr()->andX(
                $builder->expr()->isNotNull('a.startedAt'),
                $builder->expr()->lte('a.startedAt', ':now'),
                $builder->expr()->orX(
                    $builder->expr()->isNull('a.endedAt'),
                    $builder->expr()->gte('a.endedAt', ':now')
                )
            )
        )->setParameters(array('now' => new \DateTime()))->getQuery()->getResult();
    }
725351
public function markAsRead()
    {
        $entries = $this->get();

        $count = 0;

        foreach ($entries as $entry) {
            if ($entry->markAsRead()) {
                ++$count;
            }
        }

        return $count;
    }
447180
def _get_longest_hit_at_ref_start(self, nucmer_hits, hits_to_exclude=None):
        ''''''
        if hits_to_exclude is None:
            hits_to_exclude = set()
        hits_at_start = [hit for hit in nucmer_hits if self._is_at_ref_start(hit) and hit not in hits_to_exclude]
        return self._get_longest_hit_by_ref_length(hits_at_start)
1180995
public function findAllPublishedIndexableOrdered()
    {
        $builder = $this->createQueryBuilder('a')->orderBy('a.startedAt', 'DESC');
        $builder->where(
            $builder->expr()->andX(
                $builder->expr()->isNotNull('a.startedAt'),
                $builder->expr()->lte('a.startedAt', ':now'),
                $builder->expr()->orX(
                    $builder->expr()->isNull('a.endedAt'),
                    $builder->expr()->gte('a.endedAt', ':now')
                )
            )
        )->innerJoin('a.metas', 'm', Join::WITH, 'm.contents = :value');

        return $builder->setParameters(array(
                'now'   => new \DateTime(),
                'value' => 'index,follow',
            )
        )->getQuery()->getResult();
    }
650643
public function setNextToBePublished()
    {
        $next = $this->find()
            ->where([
                sprintf('%s.active', $this->getAlias()) => true,
                sprintf('%s.created >', $this->getAlias()) => new Time,
            ])
            ->order([sprintf('%s.created', $this->getAlias()) => 'ASC'])
            ->extract('created')
            ->first();

        $next = empty($next) ? false : $next->toUnixString();

        Cache::write('next_to_be_published', $next, $this->getCacheName());

        return $next;
    }
937438
public function getPublishedAt()
    {
        if ($this->status == PageStatus::PUBLISHED && $this->publishedAt === null) {
            $this->setPublishedAt($this->getCreatedAt());
        }

        return $this->publishedAt;
    }
798952
public function getPublishedDocumentCount()
	{
		$count = 0;
		foreach ($this->arrDocuments as $document)
		{
			if ($document->isPublished())
			{
				$count++;
			}
		}
		return $count;
	}
788771
def posts_count(self):
        
        return self.obj.direct_posts_count + sum(n.posts_count for n in self.children)
36266
def creators_grouped_by_role(self):
        
        role = -1
        creators = []
        for wc in self:
            if wc.role != role:
                if creators:
                    yield (role, creators)
                role = wc.role
                creators = []
            creators.append(wc.creator)

        if creators:
            yield (role, creators)
752380
def by_readings(self, role_names=['', 'Author']):
        
        if not spectator_apps.is_enabled('reading'):
            raise ImproperlyConfigured("To use the CreatorManager.by_readings() method, 'spectator.reading' must by in INSTALLED_APPS.")

        qs = self.get_queryset()

        qs = qs.filter(publication_roles__role_name__in=role_names) \
                .exclude(publications__reading__isnull=True) \
                .annotate(num_readings=Count('publications__reading')) \
                .order_by('-num_readings', 'name_sort')

        return qs
684306
def authors_et_al(self, max_authors=5):
        
        author_list = self._author_list
        if len(author_list) <= max_authors:
            authors_et_al = self.authors
        else:
            authors_et_al = ", ".join(
                self._author_list[:max_authors]) + ", et al."
        return authors_et_al
57042
public function getCandidateAuthors()
    {
        if ($this->config()->get('restrict_authors_to_group')) {
            return Group::get()->filter('Code', $this->config()->get('restrict_authors_to_group'))->first()->Members();
        }

        $list = Member::get();
        $this->extend('updateCandidateAuthors', $list);
        return $list;
    }
922253
def get_contributor_sort_value(self, obj):
        """"""
        user = obj.contributor

        if user.first_name or user.last_name:
            contributor = user.get_full_name()
        else:
            contributor = user.username

        return contributor.strip().lower()
713353
def top_submissions(self):
        """"""
        num = min(10, len(self.submissions))
        if num <= 0:
            return ''

        top_submissions = sorted(
            [x for x in self.submissions.values() if self.distinguished or
             x.distinguished is None],
            key=lambda x: (-x.score, -x.num_comments, x.title))[:num]

        if not top_submissions:
            return ''

        retval = self.post_header.format('Top Submissions')
        for sub in top_submissions:
            title = self._safe_title(sub)
            if sub.permalink in sub.url:
                retval += tt('1. {}').format(title)
            else:
                retval += tt('1. [{}]({})').format(title, sub.url)

            retval += ' by {} ({}, [{} comment{}]({}))\n'.format(
                self._user(sub.author), self._points(sub.score),
                sub.num_comments, 's' if sub.num_comments != 1 else '',
                self._permalink(sub))
        return tt('{}\n').format(retval)
326187
def most_seen_creators_card(event_kind=None, num=10):
    
    object_list = most_seen_creators(event_kind=event_kind, num=num)

    object_list = chartify(object_list, 'num_events', cutoff=1)

    return {
        'card_title': 'Most seen people/groups',
        'score_attr': 'num_events',
        'object_list': object_list,
    }
199111
def get_statistics(self):
        
        statistics = {
            "number_authors": 0,
            "number_author_names": 0,
            "number_author_abbreviations": 0,
            "number_works": 0,
            "number_work_titles": 0,
            "number_title_abbreviations": 0,
            "number_opus_maximum":0,
        }
        for author in self.get_authors():
            if author.get_urn() is not None:
                opmax = True if self.get_opus_maximum_of(author.get_urn())\
                    is not None else False
                if opmax:
                    statistics["number_opus_maximum"] += 1
            statistics["number_authors"] += 1
            statistics["number_author_names"] += len(author.get_names())
            statistics["number_author_abbreviations"] += len(
                author.get_abbreviations()
            )
            for work in author.get_works():
                statistics["number_works"] += 1
                statistics["number_work_titles"] += len(work.get_titles())
                statistics["number_title_abbreviations"] += len(
                    work.get_abbreviations()
                )
        return statistics