From 21fd7bd5d15850da942991bcdb7c00c3332231cc Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sat, 18 Aug 2018 01:16:14 -0700 Subject: create index on release_rev_abstracts --- rust/migrations/2018-05-12-001226_init/up.sql | 2 ++ 1 file changed, 2 insertions(+) (limited to 'rust/migrations') diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index 783d2f94..960623a3 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -209,6 +209,8 @@ CREATE TABLE release_rev_abstract ( lang TEXT ); +CREATE INDEX release_rev_abstract_rev_idx ON release_rev_abstract(release_rev); + CREATE TABLE release_ident ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), is_live BOOL NOT NULL DEFAULT false, -- cgit v1.2.3 From bed06d8726a063e177ccd8a40554a799e0fdb1f1 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 19 Aug 2018 16:45:51 -0700 Subject: add index on file_rev_url file_rev --- rust/migrations/2018-05-12-001226_init/up.sql | 2 ++ 1 file changed, 2 insertions(+) (limited to 'rust/migrations') diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index 960623a3..a1de656d 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -145,6 +145,8 @@ CREATE TABLE file_rev_url ( url TEXT NOT NULL ); +CREATE INDEX file_rev_url_rev_idx ON file_rev_url(file_rev); + CREATE TABLE file_ident ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), is_live BOOL NOT NULL DEFAULT false, -- cgit v1.2.3 From 42fa2a4d01d31922de2a61881860840f2bfa80f5 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 19 Aug 2018 18:27:48 -0700 Subject: add index on release_rev_abstract SHA1 column --- rust/migrations/2018-05-12-001226_init/up.sql | 1 + 1 file changed, 1 insertion(+) (limited to 'rust/migrations') diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index a1de656d..024273a7 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -212,6 +212,7 @@ CREATE TABLE release_rev_abstract ( ); CREATE INDEX release_rev_abstract_rev_idx ON release_rev_abstract(release_rev); +CREATE INDEX release_rev_abstract_sha1_idx ON release_rev_abstract(abstract_sha1); CREATE TABLE release_ident ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), -- cgit v1.2.3 From b8ca8ebdae304dcc2a694e5dfbc9070003f0df8a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Aug 2018 01:18:10 -0700 Subject: use index_val, not index, in SQL schema --- rust/migrations/2018-05-12-001226_init/up.sql | 8 ++++---- rust/src/api_server.rs | 12 ++++++------ rust/src/database_models.rs | 8 ++++---- rust/src/database_schema.rs | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'rust/migrations') diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql index 024273a7..b0733576 100644 --- a/rust/migrations/2018-05-12-001226_init/up.sql +++ b/rust/migrations/2018-05-12-001226_init/up.sql @@ -276,7 +276,7 @@ CREATE TABLE release_contrib ( creator_ident_id UUID REFERENCES creator_ident(id), raw_name TEXT, role TEXT, -- TODO: enum? - index BIGINT, + index_val BIGINT, extra_json JSON ); @@ -287,7 +287,7 @@ CREATE TABLE release_ref ( id BIGSERIAL PRIMARY KEY, release_rev UUID REFERENCES release_rev(id) NOT NULL, target_release_ident_id UUID REFERENCES release_ident(id), -- or work? - index BIGINT, + index_val BIGINT, key TEXT, extra_json JSON, -- title, year, container_title, locator (aka, page), oci_id container_title TEXT, @@ -432,12 +432,12 @@ INSERT INTO release_rev_abstract (release_rev, abstract_sha1, mimetype, lang) VA ('00000000-0000-0000-4444-FFF000000001', '1ba86bf8c2979a62d29b18b537e50b2b093be27e', 'text/plain', 'en'), ('00000000-0000-0000-4444-FFF000000002', '0da908ab584b5e445a06beb172e3fab8cb5169e3', 'application/xml+jats', 'en'); -INSERT INTO release_contrib (release_rev, creator_ident_id, raw_name, role, index) VALUES +INSERT INTO release_contrib (release_rev, creator_ident_id, raw_name, role, index_val) VALUES ('00000000-0000-0000-4444-FFF000000002', null, null, null, null), ('00000000-0000-0000-4444-FFF000000002', '00000000-0000-0000-2222-000000000002', 'some contrib', 'editor', 4), ('00000000-0000-0000-4444-FFF000000003', '00000000-0000-0000-2222-000000000003', 'John P. A. Ioannidis', 'author', 0); -INSERT INTO release_ref (release_rev, target_release_ident_id, index, extra_json) VALUES +INSERT INTO release_ref (release_rev, target_release_ident_id, index_val, extra_json) VALUES ('00000000-0000-0000-4444-FFF000000002', null, null, null), ('00000000-0000-0000-4444-FFF000000002', '00000000-0000-0000-4444-000000000001', 4, '{"unstructured":"citation note"}'), ('00000000-0000-0000-4444-FFF000000003', null, 0, '{"unstructured": "Ioannidis JP, Haidich AB, Lau J. Any casualties in the clash of randomised and observational evidence? BMJ. 2001;322:879–880"}'), diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs index 66e6359a..b0dff173 100644 --- a/rust/src/api_server.rs +++ b/rust/src/api_server.rs @@ -198,12 +198,12 @@ fn release_row2entity( let refs: Vec = release_ref::table .filter(release_ref::release_rev.eq(rev.id)) - .order(release_ref::index.asc()) + .order(release_ref::index_val.asc()) .get_results(conn) .expect("fetch release refs") .into_iter() .map(|r: ReleaseRefRow| ReleaseRef { - index: r.index, + index: r.index_val, key: r.key, extra: r.extra_json, container_title: r.container_title, @@ -216,12 +216,12 @@ fn release_row2entity( let contribs: Vec = release_contrib::table .filter(release_contrib::release_rev.eq(rev.id)) - .order((release_contrib::role.asc(), release_contrib::index.asc())) + .order((release_contrib::role.asc(), release_contrib::index_val.asc())) .get_results(conn) .expect("fetch release refs") .into_iter() .map(|c: ReleaseContribRow| ReleaseContrib { - index: c.index, + index: c.index_val, raw_name: c.raw_name, role: c.role, extra: c.extra_json, @@ -741,7 +741,7 @@ impl Server { target_release_ident_id: r.target_release_id .clone() .map(|v| fcid2uuid(&v).expect("valid fatcat identifier")), - index: r.index, + index_val: r.index, key: r.key.clone(), container_title: r.container_title.clone(), year: r.year, @@ -773,7 +773,7 @@ impl Server { .clone() .map(|v| fcid2uuid(&v).expect("valid fatcat identifier")), raw_name: c.raw_name.clone(), - index: c.index, + index_val: c.index, role: c.role.clone(), extra_json: c.extra.clone(), }) diff --git a/rust/src/database_models.rs b/rust/src/database_models.rs index 258bcab7..47e00bcf 100644 --- a/rust/src/database_models.rs +++ b/rust/src/database_models.rs @@ -228,7 +228,7 @@ pub struct ReleaseContribRow { pub creator_ident_id: Option, pub raw_name: Option, pub role: Option, - pub index: Option, + pub index_val: Option, pub extra_json: Option, } @@ -239,7 +239,7 @@ pub struct ReleaseContribNewRow { pub creator_ident_id: Option, pub raw_name: Option, pub role: Option, - pub index: Option, + pub index_val: Option, pub extra_json: Option, } @@ -249,7 +249,7 @@ pub struct ReleaseRefRow { pub id: i64, pub release_rev: Uuid, pub target_release_ident_id: Option, - pub index: Option, + pub index_val: Option, pub key: Option, pub extra_json: Option, pub container_title: Option, @@ -263,7 +263,7 @@ pub struct ReleaseRefRow { pub struct ReleaseRefNewRow { pub release_rev: Uuid, pub target_release_ident_id: Option, - pub index: Option, + pub index_val: Option, pub key: Option, pub extra_json: Option, pub container_title: Option, diff --git a/rust/src/database_schema.rs b/rust/src/database_schema.rs index 3a8fe901..a6605d81 100644 --- a/rust/src/database_schema.rs +++ b/rust/src/database_schema.rs @@ -159,7 +159,7 @@ table! { creator_ident_id -> Nullable, raw_name -> Nullable, role -> Nullable, - index -> Nullable, + index_val -> Nullable, extra_json -> Nullable, } } @@ -191,7 +191,7 @@ table! { id -> Int8, release_rev -> Uuid, target_release_ident_id -> Nullable, - index -> Nullable, + index_val -> Nullable, key -> Nullable, extra_json -> Nullable, container_title -> Nullable, -- cgit v1.2.3