Skip to content

Commit

Permalink
Rename usage-related functions to insights in download module
Browse files Browse the repository at this point in the history
Tool: gitpod/catfood.gitpod.cloud
  • Loading branch information
filiptronicek committed Feb 7, 2025
1 parent d8da447 commit b3f510d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const DownloadInsightsToast = ({ organizationId, from, to, organizationNa
if (isLoading) {
return (
<div>
<span>Preparing usage export</span>
<span>Preparing insights export</span>
<br />
<span className="text-sm">Exporting page {progress}</span>
</div>
Expand All @@ -64,15 +64,15 @@ export const DownloadInsightsToast = ({ organizationId, from, to, organizationNa
<div className="flex flex-row items-start space-x-2">
<AlertTriangle className="w-5 h-5 mt-0.5" />
<div>
<span>Error exporting your usage data:</span>
<span>Error exporting your insights data:</span>
<pre className="mt-2 whitespace-normal text-sm">{error.message}</pre>
</div>
</div>
);
}

if (!data || !data.blob || data.count === 0) {
return <span>No usage data for the selected period.</span>;
return <span>No insights data for the selected period.</span>;
}

const readableSize = prettyBytes(data.blob.size);
Expand All @@ -81,7 +81,7 @@ export const DownloadInsightsToast = ({ organizationId, from, to, organizationNa
return (
<div className="flex flex-row items-start justify-between space-x-2">
<div>
<span>Usage export complete.</span>
<span>Insights export complete.</span>
<p className="dark:text-gray-500">
{readableSize} &middot; {formattedCount} {data.count !== 1 ? "entries" : "entry"} exported
</p>
Expand Down
16 changes: 8 additions & 8 deletions components/dashboard/src/insights/download/download-sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ type Args = Pick<ListWorkspaceSessionsRequest, "organizationId" | "from" | "to">
onProgress?: (percentage: number) => void;
};

export type DownloadUsageCSVResponse = {
export type DownloadInsightsCSVResponse = {
blob: Blob | null;
filename: string;
count: number;
};

const downloadUsageCSV = async ({
const downloadInsightsCSV = async ({
organizationId,
from,
to,
organizationName,
signal,
onProgress,
}: Args): Promise<DownloadUsageCSVResponse> => {
}: Args): Promise<DownloadInsightsCSVResponse> => {
const start = dayjs(from?.toDate()).format("YYYYMMDD");
const end = dayjs(to?.toDate()).format("YYYYMMDD");
const filename = `gitpod-sessions-${organizationName}-${start}-${end}.csv`;
Expand Down Expand Up @@ -197,16 +197,16 @@ export const transformSessionRecord = (session: WorkspaceSession) => {

export const useDownloadSessionsCSV = (args: Args) => {
const client = useQueryClient();
const key = getDownloadUsageCSVQueryKey(args);
const key = getDownloadInsightsCSVQueryKey(args);

const abort = useCallback(() => {
client.removeQueries([key]);
}, [client, key]);

const query = useQuery<DownloadUsageCSVResponse, Error>(
const query = useQuery<DownloadInsightsCSVResponse, Error>(
key,
async ({ signal }) => {
return downloadUsageCSV({ ...args, signal });
return downloadInsightsCSV({ ...args, signal });
},
{
retry: false,
Expand All @@ -221,6 +221,6 @@ export const useDownloadSessionsCSV = (args: Args) => {
};
};

const getDownloadUsageCSVQueryKey = (args: Args) => {
return noPersistence(["usage-export", args]);
const getDownloadInsightsCSVQueryKey = (args: Args) => {
return noPersistence(["insights-export", args]);
};

0 comments on commit b3f510d

Please sign in to comment.