CovidTrackerFr / vitemadose-ios

Application iOS de l'outil ViteMaDose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Home percentage stats - Check total is not 0

victor-sarda opened this issue · comments

Description

Right now the home percentage cell doesn't check if the total amount of centres available is higher than 0. This can result into a crash (divide by zero)

Suggestion

    var pourcentage: Int? {
        // Prevent divide by zero crash
        guard total > 0 else {
            return nil
        }
        return (disponibles * 100) / total
    }

Percentage value would become optional so fallback text could be "-" (it should never happen)

Linked to #41