Skip to content

Commit

Permalink
Merge pull request #174 from AI-READI/expiration-date
Browse files Browse the repository at this point in the history
Expiration date and prettybyte binary size
  • Loading branch information
kirenotneb authored Jan 9, 2025
2 parents 315f0f5 + ea7441e commit 93eac24
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
5 changes: 3 additions & 2 deletions components/download/FolderSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const totalBytes = computed(() =>

<span v-if="folder.size" class="text-xs font-thin"
>{{ folder.numberOfFiles }} files,
{{ prettyBytes(folder.size) }}</span
{{ prettyBytes(folder.size, { binary: true }) }}</span
>
</div>
</div>
Expand All @@ -100,6 +100,7 @@ const totalBytes = computed(() =>
</n-checkbox-group>

<p v-if="hasFolderSizes">
Total size of selected folders: {{ prettyBytes(totalBytes) }}
Total size of selected folders:
{{ prettyBytes(totalBytes, { binary: true }) }}
</p>
</template>
8 changes: 6 additions & 2 deletions components/files/FolderViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ function convertDirectory(
},
[
directory.size
? h("span", { class: "text-sm" }, prettyBytes(directory.size) || "")
? h(
"span",
{ class: "text-sm" },
prettyBytes(directory.size, { binary: true }) || "",
)
: null,
directory.size ? h(NDivider, { vertical: true }) : null,
h(
Expand Down Expand Up @@ -242,7 +246,7 @@ const openMetadataDrawer = (currentPath: Array<string>) => {
<n-divider v-if="drawerDetails.numberOfFiles" vertical />

<p v-if="drawerDetails.size">
{{ prettyBytes(drawerDetails.size) }}
{{ prettyBytes(drawerDetails.size, { binary: true }) }}
</p>
</div>
</n-flex>
Expand Down
22 changes: 18 additions & 4 deletions pages/datasets/[datasetid]/access/request/[requestid].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import hljs from "highlight.js/lib/core";
import powershell from "highlight.js/lib/languages/powershell";
import { unix } from "dayjs";
definePageMeta({
middleware: ["auth"],
Expand All @@ -25,7 +26,10 @@ const notUserDownload = user?.id !== request.user_details_id;
const dataReady = request.status === "READY";
const isExpired = request.status === "EXPIRED";
const userKey = user?.email.replace(/[^a-zA-Z0-9]/g, "");
const expiresAt = request.expires_at
? unix(request.expires_at).format("MMM D, YYYY HH:mm Z")
: null;
const requestSasUri = request.download_uri;
const azcopyCommand = `azcopy copy "${requestSasUri}" "C:\\local\\path" --recursive=true`;
Expand Down Expand Up @@ -90,9 +94,19 @@ if (error.value) {

<div v-else-if="dataReady">
<p>
Your dataset is ready for download. Due to the number and size of
of the files included in typical datasets, we recommend using one
of the following clients:
Access to your dataset will expire on:
<strong class="text-lg font-black">{{ expiresAt }} UTC</strong>.
</p>

<p>
Please make sure to complete downloading your dataset before this
time. You will need to request a new dataset if you do not
complete the download before then.
</p>

<p>
Due to the number and size of of the files included in typical
datasets, we recommend using one of the following clients:
</p>

<n-tabs type="line" animated>
Expand Down
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ model download_request {
secure_hash String? @db.Char(64)
created_at BigInt
updated_on BigInt
expires_at BigInt
download_files download_files[]
published_dataset published_dataset @relation(fields: [dataset_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
download_agreement download_agreement @relation(fields: [download_agreement_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
Expand Down
14 changes: 13 additions & 1 deletion server/api/downloads/request/[requestid]/index.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineEventHandler(async (event) => {
download_agreement_id: true,
download_key: true,
download_uri: true,
expires_at: true,
status: true,
user_details_id: true,
},
Expand All @@ -21,7 +22,18 @@ export default defineEventHandler(async (event) => {
});

if (request) {
return request;
return {
id: request.id,
dataset_id: request.dataset_id,
download_agreement_id: request.download_agreement_id,
download_key: request.download_key,
download_uri: request.download_uri,
expires_at: request.expires_at
? Number(BigInt(request.expires_at))
: null,
status: request.status,
user_details_id: request.user_details_id,
};
} else {
return createError({
statusCode: 404,
Expand Down

0 comments on commit 93eac24

Please sign in to comment.