Skip to content

Commit

Permalink
fix getCurrentStat crash
Browse files Browse the repository at this point in the history
  • Loading branch information
wwsalmon committed Feb 12, 2023
1 parent de897c2 commit b57d4f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ function getSeriesData(vaxEvents: HydratedDocument<IVaxEvent>[], type: "infectio
function getCurrentStat(vaxEvents: HydratedDocument<IVaxEvent>[], type: "infection" | "death" | "severe") {
const thisStat = getSeriesData(vaxEvents, type).reduce((a, b) => [...a, ...b], []).sort((a, b) => +new Date(a.date) - +new Date(b.date));

if (!thisStat.length) return 0;

if (+new Date(thisStat[thisStat.length - 1].date) < +new Date()) {
return "<" + thisStat[thisStat.length - 1].VE.toPrecision(3);
}
Expand Down Expand Up @@ -278,6 +280,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
if (!session) return { redirect: { permanent: false, destination: "/signin" } };

try {
mongoose.set("strictQuery", false);

await mongoose.connect(process.env.MONGODB_URL as string);

let thisUser = await UserModel.findOne({email: session.user.email});
Expand Down

1 comment on commit b57d4f7

@vercel
Copy link

@vercel vercel bot commented on b57d4f7 Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

boostontime – ./

boostontime.vercel.app
boostontime-wwsalmon.vercel.app
boostontime-git-main-wwsalmon.vercel.app

Please sign in to comment.