mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 15:06:19 -05:00
Testing total size.
This commit is contained in:
parent
5cbd4c755c
commit
603771b74c
2 changed files with 7 additions and 3 deletions
|
|
@ -627,16 +627,17 @@ def get_file_statistics():
|
|||
curs.execute('''
|
||||
SELECT
|
||||
COUNT(path) AS "total_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype LIKE 'video/%') AS "video_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype = 'application/pdf') AS "pdf_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype LIKE 'image/%' AND file.associated = FALSE) AS "image_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype = 'application/zip') AS "zip_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype LIKE 'video/%') AS "video_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype LIKE 'image/%' AND file.associated = FALSE) AS "image_count",
|
||||
COUNT(path) FILTER (WHERE file.mimetype LIKE 'audio/%' AND file.associated = FALSE) AS "audio_count",
|
||||
SUM(size)::BIGINT AS "total_size"
|
||||
FROM
|
||||
file
|
||||
''')
|
||||
statistics = dict(curs.fetchall()[0])
|
||||
statistics['total_size'] = statistics['total_size'] or 0
|
||||
|
||||
curs.execute('SELECT COUNT(*) FROM archive')
|
||||
statistics['archive_count'] = curs.fetchall()[0][0]
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ def test_file_statistics(test_session, test_client, example_pdf, example_mobi, e
|
|||
assert response.status_code == HTTPStatus.OK
|
||||
assert response.json['file_statistics'] == {
|
||||
'archive_count': 0,
|
||||
'total_size': 0,
|
||||
'audio_count': 0,
|
||||
'ebook_count': 0,
|
||||
'image_count': 0,
|
||||
|
|
@ -264,7 +265,9 @@ def test_file_statistics(test_session, test_client, example_pdf, example_mobi, e
|
|||
|
||||
request, response = test_client.get('/api/statistics')
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
assert response.json['file_statistics'] == {
|
||||
stats = response.json['file_statistics']
|
||||
stats.pop('total_size')
|
||||
assert stats == {
|
||||
'archive_count': 0,
|
||||
'audio_count': 0,
|
||||
'ebook_count': 2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue