Skip to content

Commit 4537cbc

Browse files
committed
make plugin downloads page more performant
1 parent ea573ee commit 4537cbc

File tree

4 files changed

+50
-46
lines changed

4 files changed

+50
-46
lines changed
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
<script lang="ts">
2-
import { Line, Plot, RegressionY } from 'svelteplot';
3-
import type { IndividualDownloadDataPoint } from '../../../../../../data-wasm/pkg/data_wasm';
2+
import { Line, Plot } from 'svelteplot';
43
import ChartWrapper from '../../ChartWrapper.svelte';
54
65
interface Props {
7-
dataPoints: IndividualDownloadDataPoint[];
6+
dataPoints: number[];
87
}
98
109
const { dataPoints }: Props = $props();
1110
12-
const mappedData = dataPoints
13-
.filter(x => x.downloads > 0 && x.version_count > 0)
14-
.sort((a, b) => b.downloads - a.downloads)
15-
.map((point, i) => {
16-
return {
17-
rank: i,
18-
id: point.id,
19-
downloads: point.downloads,
20-
};
21-
});
11+
const mappedData = dataPoints.map((downloads, index) => {
12+
return {
13+
index: index,
14+
downloads: downloads,
15+
};
16+
});
2217
</script>
2318

2419
<ChartWrapper>
2520
<Plot grid x={{ label: 'Rank →', type: 'linear' }} y={{ label: '↑ Downloads', type: 'log', domain: [1, 10_000_000] }}>
26-
<Line data={mappedData} x="rank" y="downloads" stroke="var(--sl-color-text-accent)" />
21+
<Line data={mappedData} x="index" y="downloads" stroke="var(--sl-color-text-accent)" />
2722
</Plot>
2823
</ChartWrapper>

website/src/components/svelte/charts/downloads/DownloadNameChart.svelte

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
<script lang="ts">
22
import { Dot, GridY, Plot, RegressionY } from 'svelteplot';
3-
import type { IndividualDownloadDataPoint } from '../../../../../../data-wasm/pkg/data_wasm';
43
import ChartWrapper from '../../ChartWrapper.svelte';
54
65
interface Props {
7-
dataPoints: IndividualDownloadDataPoint[];
6+
dataPoints: number[];
87
}
98
109
const { dataPoints }: Props = $props();
1110
12-
const mappedData = dataPoints
13-
.filter(x => x.downloads > 0 && x.version_count > 0)
14-
.sort((a, b) => a.name.localeCompare(b.name))
15-
.map((point, i) => {
16-
return {
17-
index: i,
18-
id: point.id,
19-
name: point.name,
20-
downloads: point.downloads ?? null,
21-
version_count: point.version_count ?? null,
22-
};
23-
});
11+
const mappedData = dataPoints.map((downloads, index) => {
12+
return {
13+
index: index,
14+
downloads: downloads,
15+
};
16+
});
2417
</script>
2518

2619
<ChartWrapper>
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
<script lang="ts">
22
import { Dot, Plot } from 'svelteplot';
3-
import type { IndividualDownloadDataPoint } from '../../../../../../data-wasm/pkg/data_wasm';
43
import ChartWrapper from '../../ChartWrapper.svelte';
54
65
interface Props {
7-
dataPoints: IndividualDownloadDataPoint[];
6+
dataPoints: {
7+
date: Date;
8+
downloads: number;
9+
version_count: number;
10+
}[];
811
}
912
1013
const { dataPoints }: Props = $props();
11-
12-
const mappedData = dataPoints
13-
.filter(x => x.downloads > 0 && x.version_count > 0)
14-
.map(point => {
15-
return {
16-
id: point.id,
17-
date: new Date(point.date),
18-
downloads: point.downloads ?? null,
19-
version_count: point.version_count ?? null,
20-
};
21-
});
2214
</script>
2315

2416
<ChartWrapper>
2517
<Plot grid x={{ label: 'Releases →', type: 'log' }} y={{ label: '↑ Downloads', type: 'log', domain: [1, 10_000_000] }}>
26-
<Dot data={mappedData} x="version_count" y="downloads" opacity={0.3} stroke="var(--sl-color-text-accent)" />
18+
<Dot data={dataPoints} x="version_count" y="downloads" opacity={0.3} stroke="var(--sl-color-text-accent)" />
2719
</Plot>
2820
</ChartWrapper>
2921

3022
<ChartWrapper>
3123
<Plot grid x={{ label: 'Release Date →' }} y={{ label: '↑ Downloads', type: 'log', domain: [1, 10_000_000] }}>
32-
<Dot data={mappedData} x="date" y="downloads" opacity={0.3} stroke="var(--sl-color-text-accent)" />
24+
<Dot data={dataPoints} x="date" y="downloads" opacity={0.3} stroke="var(--sl-color-text-accent)" />
3325
</Plot>
3426
</ChartWrapper>

website/src/pages/pluginstats/downloads.astro

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ const view = data.view();
1111
1212
const downloadDataPoints = view.total_download_data(data);
1313
const individualDownloadDataPoints = view.individual_download_data(data);
14+
15+
const downloadRelationDataPoints = individualDownloadDataPoints
16+
.filter(x => x.downloads > 0 && x.version_count > 0)
17+
.map(point => {
18+
return {
19+
date: new Date(point.date),
20+
downloads: point.downloads,
21+
version_count: point.version_count,
22+
};
23+
});
24+
25+
const downloadNameDataPoints = individualDownloadDataPoints
26+
.filter(x => x.downloads > 0 && x.version_count > 0)
27+
.sort((a, b) => a.name.localeCompare(b.name))
28+
.map(point => {
29+
return point.downloads;
30+
});
31+
32+
const downloadDistributionDataPoints = individualDownloadDataPoints
33+
.filter(x => x.downloads > 0 && x.version_count > 0)
34+
.sort((a, b) => b.downloads - a.downloads)
35+
.map(point => {
36+
return point.downloads;
37+
});
1438
---
1539

1640
<StarlightPage
@@ -31,19 +55,19 @@ const individualDownloadDataPoints = view.individual_download_data(data);
3155
more releases. The second figure shows the correlation between the number of downloads and the initial release time.
3256
</p>
3357

34-
<DownloadRelationChart dataPoints={individualDownloadDataPoints} client:visible />
58+
<DownloadRelationChart dataPoints={downloadRelationDataPoints} client:visible />
3559

3660
<p>
3761
The chart below shows the correlation between the name of the plugin and the number of downloads. The regression line is calculated using the Simple Linear
3862
Regression algorithm. It is evident that there is a slight correlation between the placement of the plugin in the alphabet and the number of downloads.
3963
</p>
4064

41-
<DownloadNameChart dataPoints={individualDownloadDataPoints} client:visible />
65+
<DownloadNameChart dataPoints={downloadNameDataPoints} client:visible />
4266

4367
<p>
4468
This chart shows the overall distribution of downloads, it is clear that the majority of plugins have a low number of downloads, with a few plugins having a
4569
very high number of downloads.
4670
</p>
4771

48-
<DownloadDistributionChart dataPoints={individualDownloadDataPoints} client:visible />
72+
<DownloadDistributionChart dataPoints={downloadDistributionDataPoints} client:visible />
4973
</StarlightPage>

0 commit comments

Comments
 (0)