Skip to content

Commit

Permalink
respect ratio in evolution calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Nov 20, 2024
1 parent 510ba47 commit c6712a7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 35 deletions.
14 changes: 9 additions & 5 deletions plugins/MultiSites/tests/UI/AllWebsitesDashboard_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ describe('AllWebsitesDashboard', function () {

expect(await getSitesTableCell(1, 1)).to.equal('Site 1');
expect(await getSitesTableCell(1, 2)).to.equal('2');
expect(await getSitesTableCell(2, 1)).to.equal('Site 2');
expect(await getSitesTableCell(2, 2)).to.equal('1');

// reverse default "visits" sorting
await page.click('.sitesTableSort.sitesTableSortDesc');
Expand Down Expand Up @@ -221,19 +223,21 @@ describe('AllWebsitesDashboard', function () {
});

it('should allow sorting by other metrics', async function () {
// sort by "pageviews"
await page.click('.sitesTable th:nth-child(3)');
// sort by "hits"
await page.click('.sitesTable th:nth-child(4)');
await page.waitForNetworkIdle();

expect(await getSitesTableCell(1, 1)).to.equal('Site 1');
expect(await getSitesTableCell(1, 3)).to.equal('3');
expect(await getSitesTableCell(1, 4)).to.equal('4');
expect(await getSitesTableCell(2, 1)).to.equal('Site 3');
expect(await getSitesTableCell(2, 4)).to.equal('4');

// reverse sorting
await page.click('.sitesTable th:nth-child(3)');
await page.click('.sitesTable th:nth-child(4)');
await page.waitForNetworkIdle();

expect(await getSitesTableCell(1, 1)).to.not.equal('Site 1');
expect(await getSitesTableCell(1, 3)).to.equal('0');
expect(await getSitesTableCell(1, 4)).to.equal('0');
});

it('should allow changing the evolution metric', async function () {
Expand Down
54 changes: 27 additions & 27 deletions plugins/MultiSites/vue/dist/MultiSites.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/MultiSites/vue/dist/MultiSites.umd.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
</td>

<td :colspan="displaySparkline ? 1 : 2">
<template v-if="!site.isGroup && !!site[evolutionMetric]">
<template v-if="!site.isGroup && sparklineMetric in site">
<img :src="evolutionIconSrc" alt="" />
<span :class="evolutionTrendClass">
{{ calculateAndFormatEvolution(
site[sparklineMetric], site[`previous_${sparklineMetric}`], true) }}
site[sparklineMetric], site[`previous_${sparklineMetric}`] * site.ratio, true
) }}
</span>
</template>
</td>
Expand Down
1 change: 1 addition & 0 deletions plugins/MultiSites/vue/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface DashboardMetrics {
previous_nb_pageviews: number;
nb_visits: number;
previous_nb_visits: number;
ratio: number;
revenue: number;
previous_revenue: number;
}
Expand Down

0 comments on commit c6712a7

Please sign in to comment.