Beispiel #1
0
    def get_results(self):
        results = []

        total_db_documents = Document.objects.only('pk',).count()

        results.extend([
            _('Documents in database: %d') % total_db_documents,
        ])

        try:
            total_storage_documents, storage_used_space = storage_count()
            results.append(_('Documents in storage: %d') %
                           total_storage_documents)
            results.append(_('Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % {
                'base_2': pretty_size(storage_used_space),
                'base_10': pretty_size_10(storage_used_space),
                'bytes': storage_used_space
            })
        except NotImplementedError:
            pass

        results.extend([
            _('Document pages in database: %d') % DocumentPage.objects.only('pk',).count(),
        ])

        return results
Beispiel #2
0
def get_statistics():
    total_db_documents = Document.objects.only('pk',).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(_(u'Documents in storage: %d') %
            total_storage_documents)
        paragraphs.append(_(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % {
            'base_2': pretty_size(storage_used_space),
            'base_10': pretty_size_10(storage_used_space),
            'bytes': storage_used_space
        })
    except NotImplementedError:
        pass

    paragraphs.extend(
        [
            _(u'Document pages in database: %d') % DocumentPage.objects.only('pk',).count(),
            _(u'Minimum amount of pages per document: %(page_count__min)d') % DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Min('page_count')),
            _(u'Maximum amount of pages per document: %(page_count__max)d') % DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Max('page_count')),
            _(u'Average amount of pages per document: %(page_count__avg)f') % DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Avg('page_count')),
        ]
    )
    #[(day_count['date_added'].strftime('%Y-%m-%d'), day_count['id__count']) for day_count in Document.objects.values('date_added').annotate(Count("id"))]

    return {
        'title': _(u'Document statistics'),
        'paragraphs': paragraphs
    }
Beispiel #3
0
def get_statistics():
    total_db_documents = Document.objects.only('pk',).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(_(u'Documents in storage: %d') %
            total_storage_documents)
        paragraphs.append(_(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes') % {
            'base_2': pretty_size(storage_used_space),
            'base_10': pretty_size_10(storage_used_space),
            'bytes': storage_used_space
        })
    except NotImplementedError:
        pass

    document_stats = DocumentVersion.objects.annotate(page_count=Count('documentpage')).aggregate(Min('page_count'), Max('page_count'), Avg('page_count'))
    paragraphs.extend(
        [
            _(u'Document pages in database: %d') % DocumentPage.objects.only('pk',).count(),
            _(u'Minimum amount of pages per document: %d') % (document_stats['page_count__max'] or 0),
            _(u'Maximum amount of pages per document: %d') % (document_stats['page_count__max'] or 0),
            _(u'Average amount of pages per document: %f') % (document_stats['page_count__avg'] or 0),
        ]
    )

    return {
        'title': _(u'Document statistics'),
        'paragraphs': paragraphs
    }
Beispiel #4
0
def get_statistics():
    total_db_documents = Document.objects.only('pk', ).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(
            _(u'Documents in storage: %d') % total_storage_documents)
        paragraphs.append(
            _(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes'
              ) % {
                  'base_2': pretty_size(storage_used_space),
                  'base_10': pretty_size_10(storage_used_space),
                  'bytes': storage_used_space
              })
    except NotImplementedError:
        pass

    document_stats = DocumentVersion.objects.annotate(
        page_count=Count('documentpage')).aggregate(Min('page_count'),
                                                    Max('page_count'),
                                                    Avg('page_count'))
    paragraphs.extend([
        _(u'Document pages in database: %d') %
        DocumentPage.objects.only('pk', ).count(),
        _(u'Minimum amount of pages per document: %d') %
        (document_stats['page_count__min'] or 0),
        _(u'Maximum amount of pages per document: %d') %
        (document_stats['page_count__max'] or 0),
        _(u'Average amount of pages per document: %f') %
        (document_stats['page_count__avg'] or 0),
    ])

    return {'title': _(u'Document statistics'), 'paragraphs': paragraphs}
Beispiel #5
0
def get_statistics():
    total_db_documents = Document.objects.only('pk', ).count()

    paragraphs = [
        _(u'Document types: %d') % DocumentType.objects.count(),
        _(u'Documents in database: %d') % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(
            _(u'Documents in storage: %d') % total_storage_documents)
        paragraphs.append(
            _(u'Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes'
              ) % {
                  'base_2': pretty_size(storage_used_space),
                  'base_10': pretty_size_10(storage_used_space),
                  'bytes': storage_used_space
              })
    except NotImplementedError:
        pass

    paragraphs.extend([
        _(u'Document pages in database: %d') %
        DocumentPage.objects.only('pk', ).count(),
        _(u'Minimum amount of pages per document: %(page_count__min)d') %
        DocumentVersion.objects.annotate(
            page_count=Count('documentpage')).aggregate(Min('page_count')),
        _(u'Maximum amount of pages per document: %(page_count__max)d') %
        DocumentVersion.objects.annotate(
            page_count=Count('documentpage')).aggregate(Max('page_count')),
        _(u'Average amount of pages per document: %(page_count__avg)f') %
        DocumentVersion.objects.annotate(
            page_count=Count('documentpage')).aggregate(Avg('page_count')),
    ])
    #[(day_count['date_added'].strftime('%Y-%m-%d'), day_count['id__count']) for day_count in Document.objects.values('date_added').annotate(Count("id"))]

    return {'title': _(u'Document statistics'), 'paragraphs': paragraphs}
Beispiel #6
0
def get_statistics():
    total_db_documents = Document.objects.only("pk").count()

    paragraphs = [
        _(u"Document types: %d") % DocumentType.objects.count(),
        _(u"Documents in database: %d") % total_db_documents,
    ]

    try:
        total_storage_documents, storage_used_space = storage_count()
        paragraphs.append(_(u"Documents in storage: %d") % total_storage_documents)
        paragraphs.append(
            _(u"Space used in storage: %(base_2)s (base 2), %(base_10)s (base 10), %(bytes)d bytes")
            % {
                "base_2": pretty_size(storage_used_space),
                "base_10": pretty_size_10(storage_used_space),
                "bytes": storage_used_space,
            }
        )
    except NotImplementedError:
        pass

    paragraphs.extend(
        [
            _(u"Document pages in database: %d") % DocumentPage.objects.only("pk").count(),
            _(u"Minimum amount of pages per document: %(page_count__min)d")
            % DocumentVersion.objects.annotate(page_count=Count("documentpage")).aggregate(Min("page_count")),
            _(u"Maximum amount of pages per document: %(page_count__max)d")
            % DocumentVersion.objects.annotate(page_count=Count("documentpage")).aggregate(Max("page_count")),
            _(u"Average amount of pages per document: %(page_count__avg)f")
            % DocumentVersion.objects.annotate(page_count=Count("documentpage")).aggregate(Avg("page_count")),
        ]
    )
    # [(day_count['date_added'].strftime('%Y-%m-%d'), day_count['id__count']) for day_count in Document.objects.values('date_added').annotate(Count("id"))]

    return {"title": _(u"Document statistics"), "paragraphs": paragraphs}