-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeatmapActivityItem.swift
More file actions
44 lines (39 loc) · 1.26 KB
/
Copy pathHeatmapActivityItem.swift
File metadata and controls
44 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// HeatmapActivityItem.swift
// DevLogPresentation
//
// Created by opfic on 3/2/26.
//
import Foundation
import DevLogCore
import DevLogDomain
public struct HeatmapActivityItem: Identifiable, Hashable, Comparable {
public var id: String { todoId }
public let todoId: String
public let title: String
public let number: Int
public let category: TodoCategory
public let activityKinds: [ActivityKind]
public let isDeleted: Bool
public var activityKindItems: [ActivityKindItem] {
let orderedKinds: [ActivityKind] = [.created, .completed, .deleted]
return orderedKinds.compactMap { activityKind in
if activityKinds.contains(activityKind) {
return ActivityKindItem(from: activityKind)
}
return nil
}
}
init?(todo: Todo, activityKinds: [ActivityKind]) {
guard let number = todo.number else { return nil }
self.todoId = todo.id
self.title = todo.title
self.number = number
self.category = todo.category
self.activityKinds = activityKinds
self.isDeleted = todo.deletedAt != nil
}
public static func < (lhs: HeatmapActivityItem, rhs: HeatmapActivityItem) -> Bool {
lhs.number < rhs.number
}
}