Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/vaccination fix lastUpdate #542

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions src/data-requests/vaccination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,23 @@ enum UVD {
V10 = "deltaVidPrevtynBeta",
}

// VaccineNameReverse
// VaccineNameMapping
enum VNR {
"Vaxzevria" = "astraZeneca",
"Comirnaty" = "biontech",
"Jcovden" = "janssen",
"Spikevax" = "moderna",
"Nuvaxovid" = "novavax",
"Valneva" = "valneva",
"Comirnaty bivalent (Original/Omikron)" = "biontechBivalent",
"Spikevax bivalent (Original/Omikron)" = "modernaBivalent",
"Comirnaty-Kleinkinder" = "biontechInfant",
"Comirnaty Original/Omicron BA.1" = "biontechBivalent",
"Comirnaty Original/Omicron BA.4-5" = "biontechBivalent",
"Spikevax bivalent Original/Omicron BA.1" = "modernaBivalent",
"Spikevax bivalent Original/Omicron BA.4-5" = "modernaBivalent",
"VidPrevtyn Beta" = "vidPrevtynBeta",
"Vaxzevria" = UV.V1,
"Comirnaty" = UV.V2,
"Jcovden" = UV.V3,
"Spikevax" = UV.V4,
"Nuvaxovid" = UV.V5,
"Valneva" = UV.V6,
"Comirnaty bivalent (Original/Omikron)" = UV.V7,
"Spikevax bivalent (Original/Omikron)" = UV.V8,
"Comirnaty-Kleinkinder" = UV.V9,
"Comirnaty Original/Omicron BA.1" = UV.V7,
"Comirnaty Original/Omicron BA.4-5" = UV.V7,
"Spikevax bivalent Original/Omicron BA.1" = UV.V8,
"Spikevax bivalent Original/Omicron BA.4-5" = UV.V8,
"VidPrevtyn Beta" = UV.V10,
"Comirnaty Omicron XBB.1.5" = UV.V7,
}

// UsedAgeGroups
Expand Down Expand Up @@ -600,23 +601,23 @@ export async function getVaccinationCoverage(): Promise<
});
}
);
const apiUrlCommitsMain = new URL(
`https://api.github.com/repos/robert-koch-institut/COVID-19-Impfungen_in_Deutschland/commits/main`
// get last commit of Deutschland_Bundeslaender_COVID-19-Impfungen.csv
const apiDBUrl = new URL(
"https://api.github.com/repos/robert-koch-institut/COVID-19-Impfungen_in_Deutschland/commits?path=Deutschland_Bundeslaender_COVID-19-Impfungen.csv"
);
const apiResponse: { lastUpdate: Date; sha: string } = await GetApiCommit(
apiUrlCommitsMain.href,
apiUrlCommitsMain.pathname
const lastCommitData: { lastUpdate: Date; sha: string } = await GetApiCommit(
apiDBUrl.href,
apiDBUrl.pathname
).then((apiData) => {
const lastUpdate = new Date(apiData.commit.author.date);
const sha = apiData.sha;
return { lastUpdate, sha };
return {
lastUpdate: new Date(apiData[0].commit.author.date),
sha: apiData[0].sha,
};
});
const lastUpdate = apiResponse.lastUpdate;
const sha = apiResponse.sha;

// finde den letzten Datansatz bevor dem aktuellen
// finde den letzten Datansatz vor dem aktuellen
const apiUrlTreesSha = new URL(
`https://api.github.com/repos/robert-koch-institut/COVID-19-Impfungen_in_Deutschland/git/trees/${sha}`
`https://api.github.com/repos/robert-koch-institut/COVID-19-Impfungen_in_Deutschland/git/trees/${lastCommitData.sha}`
);
const filesResponse = await GetApiTrees(
apiUrlTreesSha.href,
Expand Down Expand Up @@ -1164,7 +1165,7 @@ export async function getVaccinationCoverage(): Promise<

return {
data: coverage,
lastUpdate: lastUpdate,
lastUpdate: lastCommitData.lastUpdate,
};
}

Expand Down
Loading