Skip to content

Commit 106187f

Browse files
committed
refactor: rename sorting functions for clarity and consistency
1 parent 90a2f5a commit 106187f

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

config/default/tasks.js

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,7 @@ function getPriorityCategory(score) {
5555
return '';
5656
}
5757

58-
function calculateAge(birthDate) {
59-
const today = new Date();
60-
const birth = new Date(birthDate);
61-
62-
let age = today.getFullYear() - birth.getFullYear();
63-
const monthDiff = today.getMonth() - birth.getMonth();
64-
65-
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
66-
age--;
67-
}
68-
69-
return age;
70-
}
71-
72-
7358
module.exports = [
74-
7559
//ANC Home Visit: 12, 20, 26, 30, 34, 36, 38, 40 weeks (Known LMP)
7660
{
7761
name: 'anc.pregnancy_home_visit.known_lmp',
@@ -119,10 +103,10 @@ module.exports = [
119103
},
120104
resolvedIf: checkTaskResolvedForHomeVisit,
121105
priority: function(contact, report) {
106+
console.warn('CONTACT', contact);
122107
console.warn('REPORT', report);
123108
const taskTypeScore = 8;
124-
const age = calculateAge(contact.contact.date_of_birth);
125-
const individualScore = (age > 35 || age < 2) ? 2 : 0;
109+
const individualScore = 2;
126110
const score = taskTypeScore + individualScore;
127111
return {
128112
level: score,
@@ -161,12 +145,11 @@ module.exports = [
161145

162146
},
163147
priority: function(contact, report) {
164-
console.warn('CONTACT MARY', contact);
165-
console.warn('REPORT MARY', report);
166-
const score = 6;
148+
console.warn('CONTACT', contact);
149+
console.warn('REPORT', report);
167150
return {
168-
level: 'high',
169-
label: getPriorityCategory(score),
151+
level: 'medium',
152+
label: '',
170153
};
171154
},
172155
actions: [{

webapp/src/ts/reducers/tasks.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const initialState = {
1515
};
1616

1717

18-
const orderByDueDateAndPriority7 = (t1, t2) => {
18+
const orderByDueDateAndPriority1 = (t1, t2) => {
1919
const lhs = t1?.dueDate;
2020
const rhs = t2?.dueDate;
2121

@@ -58,9 +58,7 @@ const orderByDueDateAndPriority7 = (t1, t2) => {
5858
* 4. For equal priority, sort by due date (earlier first)
5959
* 5. Tasks without due dates appear last
6060
*/
61-
const orderByDueDateAndPriority3 = (t1, t2) => {
62-
console.log('DATE 1', t1?.dueDate)
63-
console.log('DATE 2', t2?.dueDate)
61+
const orderByDueDateAndPriority2 = (t1, t2) => {
6462

6563
const p1 = t1?.priority ?? 0;
6664
const p2 = t2?.priority ?? 0;

0 commit comments

Comments
 (0)