Browse Source

增加代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 4 years ago
parent
commit
e761b3cb65
2 changed files with 16 additions and 5 deletions
  1. +15
    -4
      models/dbsql/dataset_foreigntable_for_es.sql
  2. +1
    -1
      public/home/search.js

+ 15
- 4
models/dbsql/dataset_foreigntable_for_es.sql View File

@@ -14,7 +14,8 @@ CREATE FOREIGN TABLE public.dataset_es
repo_id bigint,
created_unix bigint,
updated_unix bigint,
file_name text
file_name text,
file_desc text
)SERVER multicorn_es
OPTIONS
(
@@ -38,7 +39,10 @@ DELETE FROM public.dataset_es;
user_id,
repo_id,
created_unix,
updated_unix,file_name)
updated_unix,
file_name,
file_desc
)
SELECT
b.id,
b.title,
@@ -52,7 +56,9 @@ DELETE FROM public.dataset_es;
b.user_id,
b.repo_id,
b.created_unix,
b.updated_unix,(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment a where a.dataset_id=b.id and a.is_private=false)
b.updated_unix,
(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment a where a.dataset_id=b.id and a.is_private=false),
(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment a where a.dataset_id=b.id and a.is_private=false)
FROM public.dataset b,public.repository c where b.repo_id=c.id and c.is_private=false;


@@ -116,10 +122,13 @@ $def$
BEGIN
if (TG_OP = 'UPDATE') then
update public.dataset_es SET file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.dataset_id and is_private=false) where id=NEW.dataset_id;
update public.dataset_es SET desc_name=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.dataset_id and is_private=false) where id=NEW.dataset_id;
elsif (TG_OP = 'INSERT') then
update public.dataset_es SET file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.dataset_id and is_private=false) where id=NEW.dataset_id;
update public.dataset_es SET desc_name=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.dataset_id and is_private=false) where id=NEW.dataset_id;
elsif (TG_OP = 'DELETE') then
update public.dataset_es SET file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=OLD.dataset_id and is_private=false) where id=OLD.dataset_id;
update public.dataset_es SET desc_name=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=OLD.dataset_id and is_private=false) where id=OLD.dataset_id;
end if;
return NEW;
END;
@@ -142,9 +151,11 @@ $def$
SET description=NEW.description,
title=NEW.title,
category=NEW.category,
task=NEW.task,
download_times=NEW.download_times,
updated_unix=NEW.updated_unix,
file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false)
file_name=(select array_to_string(array_agg(name order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false),
desc_name=(select array_to_string(array_agg(description order by created_unix desc),'-#,#-') from public.attachment where dataset_id=NEW.id and is_private=false)
where id=NEW.id;
return new;
END


+ 1
- 1
public/home/search.js View File

@@ -51,7 +51,7 @@ var sortBy={
"43":"created_unix.keyword",
"44":"created_unix.keyword",
"50":"default",
"51":"download_times.keyword",
"51":"download_times",
"60":"default",
"61":"updated_unix.keyword"
};


Loading…
Cancel
Save