• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

asartalo / diligence / 8476200316

29 Mar 2024 02:01AM UTC coverage: 92.831%. First build
8476200316

push

github

web-flow
chore: merge pull request #34 from asartalo/sqlite3

Diligent implementation using sqlite3 and MVP features

1046 of 1126 new or added lines in 56 files covered. (92.9%)

1282 of 1381 relevant lines covered (92.83%)

2.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/lib/models/modified_task.dart
1
// Diligence - A Task Management App
2
//
3
// Copyright (C) 2024 Wayne Duran <asartalo@gmail.com>
4
//
5
// This program is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free Software
7
// Foundation, either version 3 of the License, or (at your option) any later
8
// version.
9
//
10
// This program is distributed in the hope that it will be useful, but WITHOUT
11
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License along with
15
// this program. If not, see <https://www.gnu.org/licenses/>.
16

17
import 'package:flutter/foundation.dart' show immutable;
18

19
import 'persisted_task.dart';
20
import 'task.dart';
21
import 'task_commons.dart';
22

23
bool sameTime(DateTime? a, DateTime? b) {
5✔
24
  if (a == null && b == null) return true;
25
  if (a == null || b == null) return false;
26

NEW
27
  return a.isAtSameMomentAs(b);
×
28
}
29

30
@immutable
31
class ModifiedTask with TaskCommons implements Task {
32
  final PersistedTask originalTask;
33
  final _modifiedFields = <String>{};
34

35
  @override
3✔
36
  int get id => originalTask.id;
6✔
37

38
  @override
39
  final int? parentId;
40

41
  @override
42
  final DateTime? doneAt;
43

44
  @override
3✔
45
  bool get done => doneAt != null;
3✔
46

47
  @override
48
  final String name;
49

50
  @override
51
  final String? details;
52

NEW
53
  @override
×
NEW
54
  String get uid => originalTask.uid;
×
55

56
  @override
57
  final bool expanded;
58

59
  @override
2✔
60
  DateTime get createdAt => originalTask.createdAt;
4✔
61

62
  @override
63
  final DateTime updatedAt;
64

65
  ModifiedTask({
5✔
66
    this.parentId,
67
    this.doneAt,
68
    this.name = '',
69
    this.details,
70
    this.expanded = false,
71
    required this.originalTask,
72
  }) : updatedAt = DateTime.now() {
5✔
73
    _checkModifications(
5✔
74
      originalTask,
5✔
75
      parentId: parentId,
5✔
76
      doneAt: doneAt,
5✔
77
      name: name,
5✔
78
      details: details,
5✔
79
      expanded: expanded,
5✔
80
    );
81
  }
82

83
  @override
3✔
84
  ModifiedTask copyWith({
85
    int? id,
86
    int? parentId,
87
    bool? done,
88
    DateTime? doneAt,
89
    String? uid,
90
    String? name,
91
    String? details,
92
    bool? expanded,
93
    DateTime? createdAt,
94
    DateTime? updatedAt,
95
  }) {
96
    return ModifiedTask(
3✔
97
      originalTask: originalTask,
3✔
98
      parentId: parentId ?? this.parentId,
3✔
99
      doneAt: normalizedDoneAt(done, doneAt),
3✔
100
      name: name ?? this.name,
3✔
101
      details: normalizedDetails(details),
3✔
102
      expanded: expanded ?? this.expanded,
3✔
103
    );
104
  }
105

106
  void _checkModifications(
5✔
107
    Task original, {
108
    int? parentId,
109
    DateTime? doneAt,
110
    String? name,
111
    String? details,
112
    bool? expanded,
113
  }) {
114
    if (parentId != original.parentId) _modifiedFields.add('parentId');
12✔
115
    if (!sameTime(doneAt, original.doneAt)) _modifiedFields.add('doneAt');
16✔
116
    if (name != original.name) _modifiedFields.add('name');
20✔
117
    if (details != original.details) _modifiedFields.add('details');
16✔
118
    if (expanded != original.expanded) _modifiedFields.add('expanded');
14✔
119
  }
120

121
  Set<String> modifiedFields() {
3✔
122
    return _modifiedFields;
3✔
123
  }
124

125
  bool isModified(String field) {
3✔
126
    return modifiedFields().contains(field);
6✔
127
  }
128

129
  bool hasToggledDone() {
2✔
130
    return isModified('doneAt');
2✔
131
  }
132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc