コード例 #1
0
 def test_index_pages(self):
     solr = SolrConnection(settings.SOLR)
     solr.delete_query('type:page')
     solr.commit()
     self.assertEqual(si.page_count(), 0)
     si.index_pages()
     self.assertEqual(si.page_count(), 2)
コード例 #2
0
 def test_index_pages(self):
     solr = si.conn()
     solr.delete(q='type:page')
     solr.commit()
     self.assertEqual(si.page_count(), 0)
     si.index_pages()
     self.assertEqual(si.page_count(), 2)
コード例 #3
0
def newspaper_info(request):
    info = cache.get("newspaper_info")
    if info is None:
        total_page_count = solr_index.page_count()
        titles_with_issues = models.Title.objects.filter(has_issues=True)
        titles_with_issues_count = titles_with_issues.count()

        _places = models.Place.objects.filter(titles__in=titles_with_issues)
        states_with_issues = sorted(set(place.state for place in _places if place.state is not None))

        _languages = models.Language.objects.filter(titles__in=titles_with_issues)
        languages_with_issues = sorted(set((lang.code, lang.name) for lang in _languages))

        # TODO: might make sense to add a Ethnicity.has_issue model field
        # to save having to recompute this all the time, eventhough it
        # shouldn't take more than 1/2 a second, it all adds up eh?
        ethnicities_with_issues = []
        for e in models.Ethnicity.objects.all():
            # fliter out a few ethnicities, not sure why really
            if e.has_issues and e.name not in ["African", "Canadian", "Welsh"]:
                ethnicities_with_issues.append(e.name)

        info = {'titles_with_issues_count': titles_with_issues_count,
                'states_with_issues': states_with_issues,
                'languages_with_issues': languages_with_issues,
                'ethnicities_with_issues': ethnicities_with_issues,
                'total_page_count': total_page_count}

        cache.set("newspaper_info", info)

    return info
コード例 #4
0
def newspaper_info(request):
    info = cache.get("newspaper_info")
    if info is None:
        total_page_count = solr_index.page_count()
        titles_with_issues = models.Title.objects.filter(has_issues=True)
        titles_with_issues_count = titles_with_issues.count()

        _places = models.Place.objects.filter(titles__in=titles_with_issues)
        states_with_issues = sorted(set(place.state for place in _places if place.state is not None))

        _languages = models.Language.objects.filter(titles__in=titles_with_issues)
        languages_with_issues = sorted(set((lang.code, lang.name) for lang in _languages))

        # TODO: might make sense to add a Ethnicity.has_issue model field
        # to save having to recompute this all the time, eventhough it
        # shouldn't take more than 1/2 a second, it all adds up eh?
        ethnicities_with_issues = []
        for e in models.Ethnicity.objects.all():
            # fliter out a few ethnicities, not sure why really
            if e.has_issues and e.name not in ["African", "Canadian", "Welsh"]:
                ethnicities_with_issues.append(e.name)

        info = {'titles_with_issues_count': titles_with_issues_count,
                'states_with_issues': states_with_issues,
                'languages_with_issues': languages_with_issues,
                'ethnicities_with_issues': ethnicities_with_issues,
                'total_page_count': total_page_count}

        cache.set("newspaper_info", info)

    return info
コード例 #5
0
    def test_count(self):
        solr = solr_index.conn()
        solr.delete(q='type:page')
        solr_index.index_pages()
        solr.commit()
        self.assertEqual(solr_index.page_count(), 108)

        q = QueryDict('proxtext=')
        p = solr_index.SolrPaginator(q)
        self.assertEqual(108, p.count)
コード例 #6
0
ファイル: reports.py プロジェクト: MaximilianoR/open-oni
def status(request):
    page_title = 'System Status'
    page_count = models.Page.objects.all().count()
    issue_count = models.Issue.objects.all().count()
    batch_count = models.Batch.objects.all().count()
    title_count = models.Title.objects.all().count()
    holding_count = models.Holding.objects.all().count()
    essay_count = models.Essay.objects.all().count()
    pages_indexed = solr_index.page_count()
    titles_indexed = solr_index.title_count()
    return render(request, 'reports/status.html', locals())
コード例 #7
0
ファイル: reports.py プロジェクト: open-oni/open-oni
def status(request):
    page_title = 'System Status'
    page_count = models.Page.objects.all().count()
    issue_count = models.Issue.objects.all().count()
    batch_count = models.Batch.objects.all().count()
    title_count = models.Title.objects.all().count()
    holding_count = models.Holding.objects.all().count()
    essay_count = models.Essay.objects.all().count()
    pages_indexed = solr_index.page_count()
    titles_indexed = solr_index.title_count()
    return render_to_response('reports/status.html', dictionary=locals(),
                              context_instance=RequestContext(request))
コード例 #8
0
ファイル: reports.py プロジェクト: johnscancella/open-oni
def status(request):
    page_title = 'System Status'
    page_count = models.Page.objects.all().count()
    issue_count = models.Issue.objects.all().count()
    batch_count = models.Batch.objects.all().count()
    title_count = models.Title.objects.all().count()
    holding_count = models.Holding.objects.all().count()
    essay_count = models.Essay.objects.all().count()
    pages_indexed = solr_index.page_count()
    titles_indexed = solr_index.title_count()
    return render_to_response('reports/status.html',
                              dictionary=locals(),
                              context_instance=RequestContext(request))