-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from danreale/midnight-fix
Midnight fix
- Loading branch information
Showing
8 changed files
with
139 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,48 @@ | ||
import { SortByRegionNumber } from "~/utils" | ||
import { getAllTransplantData } from "./db.server" | ||
import { SortByRegionNumber } from "~/utils"; | ||
import { getAllTransplantData } from "./db.server"; | ||
|
||
// current is the initial date, previous is the day before, changing the terminology to apply to the other routes | ||
export async function getChangeData(currentDate: string, previousDate: string, waitListType: string) { | ||
export async function getChangeData( | ||
currentDate: string, | ||
previousDate: string, | ||
waitListType: string | ||
) { | ||
const [currentData, previousData] = await Promise.all([ | ||
getAllTransplantData(currentDate, waitListType), | ||
getAllTransplantData(previousDate, waitListType) | ||
]) | ||
getAllTransplantData(previousDate, waitListType), | ||
]); | ||
|
||
const sortedCurrentData = SortByRegionNumber(currentData) | ||
const sortedPreviousData = SortByRegionNumber(previousData) | ||
const sortedCurrentData = SortByRegionNumber(currentData); | ||
const sortedPreviousData = SortByRegionNumber(previousData); | ||
|
||
const N_REGIONS = 11 | ||
let changeDataList = [] | ||
const N_REGIONS = 11; | ||
let changeDataList = []; | ||
|
||
// Compare current and previous date | ||
for (let i = 0; i < N_REGIONS; i++) { | ||
let change = changeData(sortedCurrentData[i], sortedPreviousData[i]) | ||
changeDataList.push(change) | ||
let change = changeData(sortedCurrentData[i], sortedPreviousData[i]); | ||
changeDataList.push(change); | ||
} | ||
|
||
return changeDataList | ||
return changeDataList; | ||
} | ||
|
||
export function changeData(regionDataToday: any, regionDataYesterday: any) { | ||
return [ | ||
{ | ||
...regionDataToday, | ||
blood_type_a_change: | ||
regionDataToday.blood_type_a - | ||
regionDataYesterday?.blood_type_a || 0, | ||
regionDataToday?.blood_type_a - regionDataYesterday?.blood_type_a || 0, | ||
blood_type_b_change: | ||
regionDataToday.blood_type_b - | ||
regionDataYesterday?.blood_type_b || 0, | ||
regionDataToday?.blood_type_b - regionDataYesterday?.blood_type_b || 0, | ||
blood_type_o_change: | ||
regionDataToday.blood_type_o - | ||
regionDataYesterday?.blood_type_o || 0, | ||
regionDataToday?.blood_type_o - regionDataYesterday?.blood_type_o || 0, | ||
blood_type_ab_change: | ||
regionDataToday.blood_type_ab - | ||
regionDataYesterday?.blood_type_ab || 0, | ||
regionDataToday?.blood_type_ab - regionDataYesterday?.blood_type_ab || | ||
0, | ||
blood_type_all_change: | ||
regionDataToday.blood_type_all - | ||
regionDataYesterday?.blood_type_all || 0, | ||
regionDataToday?.blood_type_all - regionDataYesterday?.blood_type_all || | ||
0, | ||
}, | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.