Skip to content

Commit

Permalink
Merge pull request #442 from ertush/hotfix
Browse files Browse the repository at this point in the history
Added a check for has edits to see that latest_update_id is not missi…
  • Loading branch information
ertush authored Aug 7, 2024
2 parents 35b9441 + 68cd020 commit 4b39cf8
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions pages/facilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,18 +938,20 @@ export async function getServerSideProps(ctx) {
if (ctx?.query[flt]) {
query[flt] = ctx?.query[flt]
url = url + "&" + flt + "=" + ctx?.query[flt]

}


})




let current_url = url + '&page_size=100'
if (ctx?.query?.page) {
url = `${url}&page=${ctx.query.page}`
}

console.log({url})


try {
Expand All @@ -970,18 +972,23 @@ export async function getServerSideProps(ctx) {
Array.isArray(facilities?.results) &&
facilities?.results.length > 0
) {

if(ctx?.query?.has_edits) {
facilities = { results: facilities?.results?.filter(({latest_update}) => latest_update !== null), ...facilities }
}

return {
props: {
facilities: facilities?.results,
next: facilities?.next,
previous: facilities?.previous,
facilities: facilities?.results ?? null,
next: facilities?.next ?? null,
previous: facilities?.previous ?? null,
filters,
path: ctx.asPath || '/facilities',
current_url,
current_page: facilities?.current_page,
total_pages: facilities?.total_pages,
count: facilities?.count,
page_size: facilities?.page_size,
current_page: facilities?.current_page ?? null,
total_pages: facilities?.total_pages ?? null,
count: facilities?.count ?? null,
page_size: facilities?.page_size ?? null,
query,
token,
}
Expand Down

0 comments on commit 4b39cf8

Please sign in to comment.