You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #13: Sort item list by when to buy urgency (#35)
* created comparePurchaseUrgency function
Co-authored-by: Falak <[email protected]>
* added urgency status to list item check box
Co-authored-by: Falak <[email protected]>
* cleaned up pseudo code from firebase.ts and implemented overdue logic for buying status
Co-authored-by: Falak <[email protected]>
* update the shopping list api readme to include the new comparePurchaseUrgency info
* update readme to be more descriptive of the objects used as parameters
* removed buy from status for consistency, moved some grouping of logic
* cleaning up with guard clauses for the status checks added an inactive check for item2
* Small spellckeck correction in readme
* updated api readme to reflect the two daysSinceLastActivity
---------
Co-authored-by: Falak <[email protected]>
Co-authored-by: Falak Zahra <[email protected]>
|`user.name`|`string`| The name of the user returned in an object by Firebase Authentication. |
16
+
|`user.email`|`string`| The email of the user returned in an object by Firebase Authentication. |
17
+
|`user.uid`|`string`| The uid of the user returned in an object by Firebase Authentication. |
16
18
17
19
### `createList`
18
20
@@ -46,24 +48,50 @@ This function takes user-provided data and uses it to create a new item in the F
46
48
47
49
#### Note
48
50
49
-
**`daysUntilNextPurchase` is not added to the item directly**. It is used alomngside the `getFutureDate` utility function to create a new _JavaScript Date_ that represents when we think the user will buy the item again.
51
+
**`daysUntilNextPurchase` is not added to the item directly**. It is used alongside the `getFutureDate` utility function to create a new _JavaScript Date_ that represents when we think the user will buy the item again.
50
52
51
53
### `updateItem`
52
54
53
55
This function takes user-provided data and uses it to update an exiting item in the Firestore database.
|`listPath`|`string`| The Firestore path of the list to which the item will be added. |
60
+
|`item.id`|`string`| A unique identifier of the item generated by firebase when it is added to the database. |
61
+
|`item.name`|`string`| The name of the item. |
62
+
|`item.dateLastPurchased`|`FirebaseTimestamp` or `null`| The date the item was last purchased, `null` when item first added. |
63
+
|`item.dateNextPurchased`|`FirebaseTimestamp`| The date the item is predicted to be purchased by next. |
64
+
|`item.totalPurchases`|`number`| The total number of times the item has been purchased. |
65
+
|`item.dateCreated`|`FirebaseTimestamp`| The date the item was added to the user's list. |
59
66
60
67
### `deleteItem`
61
68
62
69
🚧 To be completed! 🚧
63
70
71
+
### `comparePurchaseUrgency`
72
+
73
+
This function compares two item objects to determine their priority order for sorting. It evaluates `item1DaysSinceLastActivity` and `item2DaysSinceLastActivity` and uses both with `item1.dateNextPurchased` and `item2.dateNextPurchased` to establish the order urgency.
|`item1`|`object`| The first item being compared to the second item. |
78
+
|`item2`|`object`| The second item being compared to the first item. |
79
+
|`item1.id`|`string`| A unique identifier of the item generated by firebase when it is added to the database. |
80
+
|`item1.name`|`string`| The name of the item. |
81
+
|`item1.dateLastPurchased`|`FirebaseTimestamp` or `null`| The date the item was last purchased, `null` when item first added. |
82
+
|`item1.dateNextPurchased`|`FirebaseTimestamp`| The date the item is predicted to be purchased by next. |
83
+
|`item1.totalPurchases`|`number`| The total number of times the item has been purchased. |
84
+
|`item1.dateCreated`|`FirebaseTimestamp`| The date the item was added to the user's list. |
85
+
|`item2.id`|`string`| A unique identifier of the item generated by firebase when it is added to the database. |
86
+
|`item2.name`|`string`| The name of the item. |
87
+
|`item2.dateLastPurchased`|`FirebaseTimestamp` or `null`| The date the item was last purchased, `null` when item first added. |
88
+
|`item2.dateNextPurchased`|`FirebaseTimestamp`| The date the item is predicted to be purchased by next. |
89
+
|`item2.totalPurchases`|`number`| The total number of times the item has been purchased. |
90
+
|`item2.dateCreated`|`FirebaseTimestamp`| The date the item was added to the user's list. |
91
+
64
92
## The shape of the the data
65
93
66
-
When we request a shopping list, it is sent to us as an array of objects with a specific shape – a specific arrangeement of properties and the kinds of data those properties can hold. This table describes the shape of the items that go into the shopping list.
94
+
When we request a shopping list, it is sent to us as an array of objects with a specific shape – a specific arrangement of properties and the kinds of data those properties can hold. This table describes the shape of the items that go into the shopping list.
0 commit comments