-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Baby steps towards data download function
- Loading branch information
1 parent
25a749b
commit be7ad91
Showing
14 changed files
with
2,743 additions
and
7,217 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--! Previous: sha1:f4cd21cedac1eb31ea84100cbf8d8a3452540402 | ||
--! Hash: sha1:d70db66b6510ada0a863d3d17bb89203fd3c8036 | ||
|
||
-- Enter migration here | ||
grant execute on function table_of_contents_items_primary_download_url to anon; | ||
|
||
alter table data_upload_outputs add column if not exists original_filename text; | ||
|
||
update | ||
data_upload_outputs | ||
set | ||
original_filename = data_sources.uploaded_source_filename | ||
from | ||
data_sources | ||
where | ||
data_upload_outputs.data_source_id = data_sources.id | ||
and | ||
data_upload_outputs.is_original = true; | ||
|
||
create or replace function table_of_contents_items_primary_download_url(item table_of_contents_items) | ||
returns text | ||
security definer | ||
stable | ||
language sql | ||
as $$ | ||
select | ||
case | ||
when item.enable_download = false then null | ||
when item.data_layer_id is null then null | ||
else | ||
( | ||
select | ||
data_upload_outputs.url || '?download=' || data_upload_outputs.original_filename | ||
from | ||
data_upload_outputs | ||
where | ||
data_upload_outputs.data_source_id = ( | ||
select | ||
data_layers.data_source_id | ||
from | ||
data_layers | ||
where | ||
data_layers.id = item.data_layer_id | ||
) | ||
and | ||
data_upload_outputs.is_original = true | ||
limit 1 | ||
) | ||
end; | ||
$$; |
Oops, something went wrong.