Skip to content

Commit

Permalink
Merge pull request #14 from satyawikananda/fix/hospital
Browse files Browse the repository at this point in the history
fix(hospital): fix available bed in type 2
  • Loading branch information
satyawikananda authored Oct 17, 2021
2 parents 892310a + 44d2121 commit 52b4f21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/scrape/hospitals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export const getHospitalList = async ({
: 0

if (type == 2) {
$(el).find(".col-md-4").each((_, el) => {
const totalBeds: number = +$(el).find(".card-body > div:nth-child(1)").text().trim()
const bedClass: string = $(el).find(".card-body > div:nth-child(2)").text().trim()
const roomName: string = $(el).find(".card-body > div:nth-child(3)").text().trim()
const info: string = capitalizeStr($(el).find(".card-footer > div:nth-child(1)").text().trim())
$(el).find(".card").each((_, el) => {
const bedClass: string = $(el).find("div.card-body > div > div.col-md-7 > div > div > table > tbody:nth-child(1) > tr > td:nth-child(1)").text().trim()
const roomName: string = $(el).find("div.card-body > div > div.col-md-7 > div > div > table > tbody:nth-child(1) > tr > td:nth-child(2)").text().trim()
const totalBeds: number = +$(el).find("div.card-body > div > div.col-md-7 > div > div > table > tbody:nth-child(1) > tr > td:nth-child(3)").text().trim().replace("Tersedia", "").replace("bed kosong", "")
const info: string = capitalizeStr($(el).find("div.card-body > div > div.col-md-7 > div > div > table > tbody:nth-child(1) > tr > td:nth-child(4)").text().trim())
beds.push({
available: totalBeds,
bed_class: bedClass,
Expand All @@ -90,7 +90,6 @@ export const getHospitalList = async ({
address,
phone,
available_beds: beds,
info
})
} else {
hospitals.push({
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface HospitalsList {
phone: string | null
bed_availability?: number
available_beds?: BedsList[] | null
info: string | null
info?: string | null
queue?: number
}

Expand Down

1 comment on commit 52b4f21

@vercel
Copy link

@vercel vercel bot commented on 52b4f21 Oct 17, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.