<commit_before>import datetime
from django.conf import settings
import os

from eulfedora.views import datastream_etag
from eulfedora.server import Repository, RequestFailed

from readux.books.models import Volume, VolumeV1_0, Page, PageV1_0
from readux.utils import solr_interface, md5sum

'''
Conditional methods for calculating last modified time and ETags
for view methods in :mod:`readux.books.views`.

.. Note::

  In many cases, the Solr indexing timestamp is used rather than the object
  modification time, as this may account for changes to the site or indexing
  (including adding pages to a volume that is otherwise unchanged).
'''


def volumes_modified(request):
    'last modification time for all volumes'
    solr = solr_interface()
    results = solr.query(content_model=VolumeV1_0.VOLUME_CONTENT_MODEL) \
                  .sort_by('-timestamp').field_limit('timestamp')
    # NOTE: using solr indexing timestamp instead of object last modified, since
    # if an object's index has changed it may have been modified
    if results.count():
        return results[0]['timestamp']
<commit_msg>Fix volumes modified helper for cover view<commit_after>import datetime
from django.conf import settings
import os

from eulfedora.views import datastream_etag
from eulfedora.server import Repository, RequestFailed

from readux.books.models import Volume, VolumeV1_0, Page, PageV1_0
from readux.utils import solr_interface, md5sum

'''
Conditional methods for calculating last modified time and ETags
for view methods in :mod:`readux.books.views`.

.. Note::

  In many cases, the Solr indexing timestamp is used rather than the object
  modification time, as this may account for changes to the site or indexing
  (including adding pages to a volume that is otherwise unchanged).
'''


def volumes_modified(request, *args, **kwargs):
    'last modification time for all volumes'
    solr = solr_interface()
    results = solr.query(content_model=VolumeV1_0.VOLUME_CONTENT_MODEL) \
                  .sort_by('-timestamp').field_limit('timestamp')
    # NOTE: using solr indexing timestamp instead of object last modified, since
    # if an object's index has changed it may have been modified
    if results.count():
        return results[0]['timestamp']

{'fraction_non_alphanumeric': 0.0701058201058201, 'fraction_numerical': 0.007054673721340388, 'mean_word_length': 4.313817330210773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '95524', 'n_tokens_mistral': 627, 'n_tokens_neox': 610, 'n_words': 246}