Skip to content
Snippets Groups Projects
Commit b5231c89 authored by Manon Blanco's avatar Manon Blanco Committed by Erwan Rouchet
Browse files

Export image server

parent d0ed4745
No related branches found
No related tags found
1 merge request!1460Export image server
......@@ -26,6 +26,7 @@ logger = logging.getLogger(__name__)
# Map SQLite table names to PostgreSQL query files
EXPORT_QUERIES = [
'image_server',
'image',
'worker_version',
'element',
......
SELECT DISTINCT image.id, CONCAT(TRIM(TRAILING '/' FROM server.url), '/', image.path), image.width, image.height
SELECT DISTINCT image.id, CONCAT(TRIM(TRAILING '/' FROM server.url), '/', image.path), image.width, image.height, image.server_id
FROM images_image image
INNER JOIN documents_element element ON (element.image_id = image.id)
INNER JOIN images_imageserver server ON (server.id = image.server_id)
......
SELECT DISTINCT server.id, server.display_name, server.url, server.max_width, server.max_height
FROM images_imageserver server
INNER JOIN images_image image ON (image.server_id = server.id)
INNER JOIN documents_element element ON (element.image_id = image.id)
WHERE element.corpus_id = '{corpus_id}'::uuid
PRAGMA foreign_keys = ON;
CREATE TABLE image_server (
id VARCHAR(37) NOT NULL,
display_name VARCHAR(250) NOT NULL,
url TEXT NOT NULL,
max_width INTEGER,
max_height INTEGER,
PRIMARY KEY (id),
UNIQUE (url),
CHECK (max_width >= 0 AND max_height >= 0)
);
CREATE TABLE image (
id VARCHAR(37) NOT NULL,
url TEXT NOT NULL,
width INTEGER NOT NULL,
height INTEGER NOT NULL,
server_id VARCHAR(37) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (server_id) REFERENCES image_server (id) ON DELETE CASCADE,
UNIQUE (url),
CHECK (width >= 0 AND height >= 0)
);
......
......@@ -22,7 +22,7 @@ from arkindex.documents.models import (
Transcription,
TranscriptionEntity,
)
from arkindex.images.models import Image
from arkindex.images.models import Image, ImageServer
from arkindex.project.tests import FixtureTestCase
from ponos.models import Artifact
......@@ -124,13 +124,28 @@ class TestExport(FixtureTestCase):
db = sqlite3.connect(db_path)
self.assertCountEqual(
db.execute('SELECT id, url, width, height FROM image').fetchall(),
db.execute('SELECT id, display_name, url, max_width, max_height FROM image_server').fetchall(),
[
(
str(image_server.id),
image_server.display_name,
image_server.url,
image_server.max_width,
image_server.max_height
)
for image_server in ImageServer.objects.all()
]
)
self.assertCountEqual(
db.execute('SELECT id, url, width, height, server_id FROM image').fetchall(),
[
(
str(image.id),
image.url,
image.width,
image.height
image.height,
str(image.server.id)
)
for image in Image.objects.all()
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment