Search + lastXMin Filter + dynamic text size

This commit is contained in:
relikd
2020-05-13 01:37:50 +02:00
parent 9485d7e9b5
commit 8424c161b9
25 changed files with 865 additions and 211 deletions

View File

@@ -1,10 +1,16 @@
import Foundation
extension GroupedDomain {
/// Return new `GroupedDomain` by adding `total` and `blocked` counts. Set `lastModified` to the maximum of the two.
static func +(a: GroupedDomain, b: GroupedDomain) -> Self {
GroupedDomain(domain: a.domain, total: a.total + b.total, blocked: a.blocked + b.blocked,
lastModified: max(a.lastModified, b.lastModified), options: a.options ?? b.options )
}
/// Return new `GroupedDomain` by subtracting `total` and `blocked` counts.
static func -(a: GroupedDomain, b: GroupedDomain) -> Self {
GroupedDomain(domain: a.domain, total: a.total - b.total, blocked: a.blocked - b.blocked,
lastModified: a.lastModified, options: a.options )
}
}
extension Array where Element == GroupedDomain {
@@ -26,7 +32,9 @@ extension Recording {
}
extension Timestamp {
/// - Returns: Time string with format `yyyy-MM-dd HH:mm:ss`
func asDateTime() -> String { dateTimeFormat.string(from: self) }
func toDate() -> Date { Date(timeIntervalSince1970: Double(self)) }
static func now() -> Timestamp { Timestamp(Date().timeIntervalSince1970) }
static func past(minutes: Int) -> Timestamp { now() - Timestamp(minutes * 60) }
}