<commit_before>import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crowdsource.settings")
from crowdsource.settings import recorded_image_root, resized_start, web_server_start_resized, bl_image_root
from lost_visions import models
from lost_visions.utils.db_tools import find_image

__author__ = 'ubuntu'


def get_book_images(book_id):

    # print type(book_id), book_id

    query = 'SELECT il."location", im."id", im."views_begun", im."views_completed", ' \
            'im."volume", im."publisher", im."title", im."first_author", im."BL_DLS_ID", ' \
            'im."pubplace", im."book_identifier", im."ARK_id_of_book", im."date", im."flickr_url", ' \
            'im."image_idx", im."page", im."flickr_id", im."flickr_small_source", ' \
            'im."flickr_small_height", im."flickr_small_width", im."flickr_medium_source", ' \
            'im."flickr_medium_height", im."flickr_medium_width", im."flickr_large_source", ' \
            'im."flickr_large_height", im."flickr_large_width", im."flickr_original_source", ' \
            'im."flickr_original_height", im."flickr_original_width" ' \
            'from "image" as im left outer join lost_visions_imagelocation as il ' \
            'on im.book_identifier = il.book_id and im.volume = il.volume and ' \
            'im.page = il.page and im.image_idx = il.idx where im.book_identifier == %s'

    fast_image_data = models.Image.objects.db_manager('default').raw(query, [str(book_id)])

    # print fast_image_data.query

    return get_image_data_for_array(fast_image_data)

def get_image_data_for_array(image_data):<commit_msg>sqlite allows ==, postgres only does =. damnit.<commit_after>import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "crowdsource.settings")
from crowdsource.settings import recorded_image_root, resized_start, web_server_start_resized, bl_image_root
from lost_visions import models
from lost_visions.utils.db_tools import find_image

__author__ = 'ubuntu'


def get_book_images(book_id):

    # print type(book_id), book_id

    query = 'SELECT il."location", im."id", im."views_begun", im."views_completed", ' \
            'im."volume", im."publisher", im."title", im."first_author", im."BL_DLS_ID", ' \
            'im."pubplace", im."book_identifier", im."ARK_id_of_book", im."date", im."flickr_url", ' \
            'im."image_idx", im."page", im."flickr_id", im."flickr_small_source", ' \
            'im."flickr_small_height", im."flickr_small_width", im."flickr_medium_source", ' \
            'im."flickr_medium_height", im."flickr_medium_width", im."flickr_large_source", ' \
            'im."flickr_large_height", im."flickr_large_width", im."flickr_original_source", ' \
            'im."flickr_original_height", im."flickr_original_width" ' \
            'from "image" as im left outer join lost_visions_imagelocation as il ' \
            'on im.book_identifier = il.book_id and im.volume = il.volume and ' \
            'im.page = il.page and im.image_idx = il.idx where im.book_identifier = %s'

    fast_image_data = models.Image.objects.db_manager('default').raw(query, [str(book_id)])

    # print fast_image_data.query

    return get_image_data_for_array(fast_image_data)

def get_image_data_for_array(image_data):
{'fraction_non_alphanumeric': 0.13606911447084233, 'fraction_numerical': 0.0, 'mean_word_length': 3.8678678678678677, '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': '6193722', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1082, 'n_words': 186}