@molochko-dev/data 1.4.35 → 1.4.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,7 @@ const date_1 = require("../helpers/date");
|
|
|
8
8
|
const filtered = filter(animals, eventType)
|
|
9
9
|
|
|
10
10
|
*/
|
|
11
|
-
class
|
|
11
|
+
class AnimalEventFilter {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.status = enums_1.COW_STATUS;
|
|
14
14
|
this.defaultCowAge = 12;
|
|
@@ -40,7 +40,9 @@ class AnimalEcentFilter {
|
|
|
40
40
|
this.status.FRESH,
|
|
41
41
|
]);
|
|
42
42
|
const ageOk = this.ageFilter(animal, this.defaultCowAge);
|
|
43
|
-
|
|
43
|
+
if (genderOk && statusOk && ageOk) {
|
|
44
|
+
return animal;
|
|
45
|
+
}
|
|
44
46
|
});
|
|
45
47
|
return result;
|
|
46
48
|
}
|
|
@@ -49,7 +51,9 @@ class AnimalEcentFilter {
|
|
|
49
51
|
const genderOk = this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow);
|
|
50
52
|
const statusOk = this.statusFilter(animal, [this.status.DRY, this.status.PREGNANT]);
|
|
51
53
|
const ageOk = this.ageFilter(animal, this.defaultCowAge);
|
|
52
|
-
|
|
54
|
+
if (genderOk && statusOk && ageOk) {
|
|
55
|
+
return animal;
|
|
56
|
+
}
|
|
53
57
|
});
|
|
54
58
|
return result;
|
|
55
59
|
}
|
|
@@ -67,7 +71,9 @@ class AnimalEcentFilter {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
const statusOk = this.statusFilter(animal, availableStatus);
|
|
70
|
-
|
|
74
|
+
if (genderOk && statusOk && ageOk) {
|
|
75
|
+
return animal;
|
|
76
|
+
}
|
|
71
77
|
});
|
|
72
78
|
return result;
|
|
73
79
|
}
|
|
@@ -79,7 +85,9 @@ class AnimalEcentFilter {
|
|
|
79
85
|
const genderOk = this.genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow);
|
|
80
86
|
const statusOk = this.statusFilter(animal, [this.status.DRY]);
|
|
81
87
|
const ageOk = this.ageFilter(animal, this.defaultCowAge);
|
|
82
|
-
|
|
88
|
+
if (genderOk && statusOk && ageOk) {
|
|
89
|
+
return animal;
|
|
90
|
+
}
|
|
83
91
|
});
|
|
84
92
|
return result;
|
|
85
93
|
}
|
|
@@ -114,8 +122,8 @@ class AnimalEcentFilter {
|
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
}
|
|
125
|
+
const f = new AnimalEventFilter();
|
|
117
126
|
function filter(animals, eventType) {
|
|
118
|
-
const f = new AnimalEcentFilter();
|
|
119
127
|
return f.filter(animals, eventType);
|
|
120
128
|
}
|
|
121
129
|
exports.filter = filter;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ const filtered = filter(animals, eventType)
|
|
|
8
8
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class AnimalEventFilter {
|
|
12
12
|
status = COW_STATUS;
|
|
13
13
|
defaultCowAge = 12;
|
|
14
14
|
|
|
@@ -52,7 +52,9 @@ class AnimalEcentFilter {
|
|
|
52
52
|
this.status.FRESH,
|
|
53
53
|
]);
|
|
54
54
|
const ageOk = this.ageFilter(animal, this.defaultCowAge);
|
|
55
|
-
|
|
55
|
+
if (genderOk && statusOk && ageOk) {
|
|
56
|
+
return animal;
|
|
57
|
+
}
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
return result;
|
|
@@ -64,7 +66,9 @@ class AnimalEcentFilter {
|
|
|
64
66
|
const statusOk = this.statusFilter(animal, [this.status.DRY, this.status.PREGNANT]);
|
|
65
67
|
const ageOk = this.ageFilter(animal, this.defaultCowAge);
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
if (genderOk && statusOk && ageOk) {
|
|
70
|
+
return animal;
|
|
71
|
+
}
|
|
68
72
|
});
|
|
69
73
|
return result;
|
|
70
74
|
}
|
|
@@ -85,7 +89,9 @@ class AnimalEcentFilter {
|
|
|
85
89
|
}
|
|
86
90
|
const statusOk = this.statusFilter(animal, availableStatus);
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
if (genderOk && statusOk && ageOk) {
|
|
93
|
+
return animal;
|
|
94
|
+
}
|
|
89
95
|
});
|
|
90
96
|
return result;
|
|
91
97
|
}
|
|
@@ -100,7 +106,9 @@ class AnimalEcentFilter {
|
|
|
100
106
|
const statusOk = this.statusFilter(animal, [this.status.DRY]);
|
|
101
107
|
const ageOk = this.ageFilter(animal, this.defaultCowAge);
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
if (genderOk && statusOk && ageOk) {
|
|
110
|
+
return animal;
|
|
111
|
+
}
|
|
104
112
|
});
|
|
105
113
|
return result;
|
|
106
114
|
}
|
|
@@ -139,7 +147,8 @@ class AnimalEcentFilter {
|
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
|
|
150
|
+
const f = new AnimalEventFilter();
|
|
151
|
+
|
|
142
152
|
export function filter<T extends BaseAnimal>(animals: T[], eventType: EVENT_TYPES_ENUM) {
|
|
143
|
-
const f = new AnimalEcentFilter();
|
|
144
153
|
return f.filter(animals, eventType);
|
|
145
154
|
}
|