change average price to median price on the dashboard (#300)

* change average price to median price on the dashboard

* Use more efficient median calculation

Co-authored-by: Christian Kellner <weakmap@gmail.com>

* Fix applied suggestion artifacts

* Update sql query and js sort function

* Group sql statement by id

* Revert sort function change

---------

Co-authored-by: Christian Kellner <weakmap@gmail.com>
This commit is contained in:
bytedream
2026-04-20 10:13:11 +02:00
committed by GitHub
parent 522bbc2282
commit cc0164b689
3 changed files with 35 additions and 21 deletions

View File

@@ -37,7 +37,7 @@ dashboardRouter.get('/', async (req, res) => {
const totalJobs = jobs.length;
const totalListings = jobs.reduce((sum, j) => sum + (j.numberOfFoundListings || 0), 0);
const jobIds = jobs.map((j) => j.id);
const { numberOfActiveListings, avgPriceOfListings } = getListingsKpisForJobIds(jobIds);
const { numberOfActiveListings, medianPriceOfListings } = getListingsKpisForJobIds(jobIds);
// Build Pie data in a simple shape the frontend can consume directly
// Shape: { labels: string[], values: number[] } with values as percentages
const providerPieRaw = getProviderDistributionForJobIds(jobIds);
@@ -63,7 +63,7 @@ dashboardRouter.get('/', async (req, res) => {
totalJobs,
totalListings,
numberOfActiveListings,
avgPriceOfListings,
medianPriceOfListings,
},
pie: providerPie,
};