Add guest count API
This commit is contained in:
parent
7d49e8a7ed
commit
4622ad8d59
@ -16,6 +16,16 @@ private let df: DateFormatter = {
|
||||
return df
|
||||
}()
|
||||
|
||||
func guestCount() -> Int {
|
||||
registeredGuests
|
||||
.reduce([]) { $0 + $1.components(separatedBy: "+") }
|
||||
.reduce([]) { $0 + $1.components(separatedBy: "-") }
|
||||
.reduce([]) { $0 + $1.components(separatedBy: "und ") }
|
||||
.reduce([]) { $0 + $1.components(separatedBy: "&") }
|
||||
//.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
.count
|
||||
}
|
||||
|
||||
|
||||
func add(guest: String) -> String {
|
||||
registeredGuests.insert(guest)
|
||||
|
@ -12,16 +12,13 @@ private func register(_ req: Request, isAttending: Bool) -> String {
|
||||
}
|
||||
|
||||
func routes(_ app: Application) throws {
|
||||
app.get { req in
|
||||
|
||||
app.get("festival", "api", "ping") { req in
|
||||
return "It works!"
|
||||
}
|
||||
|
||||
app.get("festival", "api", "hello") { req in
|
||||
return "It works!"
|
||||
}
|
||||
|
||||
app.get("hello") { req in
|
||||
return "It works!"
|
||||
app.get("festival", "api", "count") { req in
|
||||
return "\(guestCount())"
|
||||
}
|
||||
|
||||
app.post("festival", "api", "register") { req -> String in
|
||||
|
Loading…
Reference in New Issue
Block a user