Changed test URLs to read URLs, added string for empty personal plan

This commit is contained in:
Deniz Duezgoeren
2019-07-22 14:32:38 +02:00
parent e04d458b8b
commit 7ba1f17fba
2 changed files with 82 additions and 2 deletions
+11 -2
View File
@@ -34,8 +34,8 @@ class DataFetcher {
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
DispatchQueue(label: "work-queue").async {
let foodUrl = "https://djd4rkn355.github.io/food_test.html"
let url = "https://djd4rkn355.github.io/subst_test.html"
let foodUrl = "https://djd4rkn355.github.io/food.html"
let url = "https://djd4rkn355.github.io/subst.html"
Alamofire.request(url).responseString { response in
if let html = response.result.value {
Alamofire.request(foodUrl).responseString { response in
@@ -54,6 +54,7 @@ class DataFetcher {
var info = ""
var infoList = [String]()
var menuList = [String]()
var isPersonalEmpty = true
do {
let doc = try SwiftSoup.parse(html)
@@ -112,6 +113,7 @@ class DataFetcher {
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
date <- mDate, time <- mTime, room <- mRoom)
_ = try db.run(insertPersonal)
isPersonalEmpty = false
}
}
} else if courses != nil && courses != "" && classes != nil && classes != "" {
@@ -123,6 +125,7 @@ class DataFetcher {
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
date <- mDate, time <- mTime, room <- mRoom)
_ = try db.run(insertPersonal)
isPersonalEmpty = false
}
}
}
@@ -130,6 +133,12 @@ class DataFetcher {
}
if isPersonalEmpty {
personalSubst.append(SubstModel(group: NSLocalizedString("personal_plan_empty", comment: ""), course: "", additional: "", date: "", time: "", room: ""))
let insertPersonal = personal.insert(group <- NSLocalizedString("personal_plan_empty", comment: ""), course <- "", additional <- "", date <- "", time <- "", room <- "")
_ = try db.run(insertPersonal)
}
let pi: Elements = try doc.select("p")
for item in pi {