Skip to content

Commit

Permalink
Baby steps towards data download function
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Feb 2, 2024
1 parent 25a749b commit be7ad91
Show file tree
Hide file tree
Showing 14 changed files with 2,743 additions and 7,217 deletions.
7,548 changes: 2,057 additions & 5,491 deletions packages/api/generated-schema-clean.gql

Large diffs are not rendered by default.

32 changes: 1 addition & 31 deletions packages/api/generated-schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -8360,12 +8360,6 @@ type Mutation {
"""
input: SubmitDataUploadInput!
): SubmitDataUploadPayload
tableOfContentsItemsPrimaryDownloadUrl(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: TableOfContentsItemsPrimaryDownloadUrlInput!
): TableOfContentsItemsPrimaryDownloadUrlPayload

"""
Toggle admin access for the given project and user. User must have already
Expand Down Expand Up @@ -13282,6 +13276,7 @@ type TableOfContentsItem implements Node {
"""
parentStableId: String
primaryDownloadUrl: String
project: Project
projectId: Int!

Expand Down Expand Up @@ -13548,31 +13543,6 @@ enum TableOfContentsItemsOrderBy {
PROJECT_ID_DESC
}

"""All input for the `tableOfContentsItemsPrimaryDownloadUrl` mutation."""
input TableOfContentsItemsPrimaryDownloadUrlInput {
"""
An arbitrary string value with no semantic meaning. Will be included in the
payload verbatim. May be used to track mutations by the client.
"""
clientMutationId: String
item: TableOfContentsItemInput
}

"""The output of our `tableOfContentsItemsPrimaryDownloadUrl` mutation."""
type TableOfContentsItemsPrimaryDownloadUrlPayload {
"""
The exact same `clientMutationId` that was provided in the mutation input,
unchanged and unused. May be used by a client to track mutations.
"""
clientMutationId: String

"""
Our root query field type. Allows us to run any query from our mutation payload.
"""
query: Query
string: String
}

enum TileScheme {
TMS
XYZ
Expand Down
50 changes: 50 additions & 0 deletions packages/api/migrations/committed/000291.sql
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;
$$;
Loading

0 comments on commit be7ad91

Please sign in to comment.