bugfixing

This commit is contained in:
MuslemRahimi 2025-03-31 23:24:00 +02:00
parent 547aa8b44d
commit 85e762b37f

View File

@ -241,13 +241,14 @@
function generateEmployeeInfoHTML() { function generateEmployeeInfoHTML() {
if (employeeHistory?.length !== 0 && !dateDistance) { if (employeeHistory?.length !== 0 && !dateDistance) {
const formattedEmployees = new Intl.NumberFormat("en").format(employees); const formattedEmployees = new Intl.NumberFormat("en").format(employees);
const latestdate = new Date( const latestdate = new Date(employeeHistory?.at(0)?.date).toLocaleString(
employeeHistory[employeeHistory.length - 1]["date"], "en-US",
).toLocaleString("en-US", { {
month: "short", month: "short",
day: "numeric", day: "numeric",
year: "numeric", year: "numeric",
}); },
);
const formattedChangeRate = new Intl.NumberFormat("en").format( const formattedChangeRate = new Intl.NumberFormat("en").format(
changeRate, changeRate,
); );
@ -270,13 +271,14 @@
`; `;
} else if (employeeHistory?.length !== 0 && dateDistance) { } else if (employeeHistory?.length !== 0 && dateDistance) {
const abbreviatedEmployees = abbreviateNumber(employees); const abbreviatedEmployees = abbreviateNumber(employees);
const latestdate = new Date( const latestdate = new Date(employeeHistory?.at(0)?.date).toLocaleString(
employeeHistory[employeeHistory.length - 1]["date"], "en-US",
).toLocaleString("en-US", { {
month: "short", month: "short",
day: "numeric", day: "numeric",
year: "numeric", year: "numeric",
}); },
);
return ` return `
<span> <span>
@ -297,19 +299,19 @@
employeeHistory = data?.getHistoryEmployee ?? []; employeeHistory = data?.getHistoryEmployee ?? [];
historyList = sortByDate(employeeHistory); historyList = sortByDate(employeeHistory);
employees = employeeHistory?.at(-1)?.employeeCount; employees = employeeHistory?.at(0)?.employeeCount;
changeRate = employees - employeeHistory?.at(-2)?.employeeCount; changeRate = employees - employeeHistory?.at(1)?.employeeCount;
dateDistance = dateDistance =
new Date(employeeHistory[employeeHistory?.length - 1]["date"]) < new Date(employeeHistory?.at(0)["date"]) <
new Date(new Date().setFullYear(new Date().getFullYear() - 1)) new Date(new Date().setFullYear(new Date().getFullYear() - 1))
? true ? true
: false; : false;
growthRate = ( growthRate = (
(employeeHistory[employeeHistory?.length - 1]?.employeeCount / (employeeHistory?.at(0)?.employeeCount /
employeeHistory[employeeHistory?.length - 2]?.employeeCount - employeeHistory?.at(1)?.employeeCount -
1) * 1) *
100 100
)?.toFixed(2); )?.toFixed(2);
@ -328,7 +330,7 @@
</script> </script>
<SEO <SEO
title={`${$displayCompanyName} (${$stockTicker}) Number of Employees ${historyList?.at(-1)?.date?.slice(0, 4)} - ${historyList?.at(0)?.date?.slice(0, 4)} · Stocknear`} title={`${$displayCompanyName} (${$stockTicker}) Number of Employees ${historyList?.at(-1)?.date?.slice(0, 4)} - ${historyList?.at(0)?.date?.slice(0, 4)}`}
description={`Current and historical number of employees for ${$displayCompanyName} (${$stockTicker}) with related statistics, a chart and a data table.`} description={`Current and historical number of employees for ${$displayCompanyName} (${$stockTicker}) with related statistics, a chart and a data table.`}
/> />
@ -368,9 +370,7 @@
{#if dateDistance} {#if dateDistance}
n/a n/a
{:else} {:else}
{changeRate !== null {changeRate !== null ? changeRate : "n/a"}
? new Intl.NumberFormat("en")?.format(changeRate)
: "n/a"}
{/if} {/if}
</div> </div>
</div> </div>