Skip to content

Commit

Permalink
feat(models): add Completion model and update Tracker with it
Browse files Browse the repository at this point in the history
  • Loading branch information
Clm-Roig committed Mar 17, 2022
1 parent ae401d4 commit 5848602
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/models/Completion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* A Completions is a measure of an action accomplished in order to fulfill a Tracker.
*
* @interface Completion
* @member {number} quantity amount of something (= unit) measured (ex: 10)
* @member {string} unit individual thing to measure (ex: "squats")
*/
export default interface Completion {
quantity: number;
unit: string;
}
23 changes: 20 additions & 3 deletions src/models/Tracker.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import Completion from './Completion';
import TrackerEntry from './TrackerEntry';
import TrackerStatus from './TrackerStatus';

/**
* A Tracker describes an objective which needs to be accomplished on a daily basis.
* To keep tracker of the objective, the trackers references TrackerEntries.
*
* @interface Tracker
* @member {string} id a v4 uuid
* @member {string} beginDate when the completions start (can be in the past or the future)
* @member {string?} dateHidden when not undefined, specify which day the tracker is ignored. The next day, it's automatically set to "undefined".
* @member {number?} duration number of days the tracker is active since beginDate
* @member {string} endDate when the Tracker is over
* @member {TrackerEntry[]} entries TrackerEntries related to this Tracker
* @member {string} name
* @member {number?} remainingDays computed attribute describing the number of days before the tracker is over
* @member {Completion[]} requiredCompletions objectives to complete the tracker
* @member {TrackerStatus} status @see TrackerStatus
*/
export default interface Tracker {
id: string; // uuid v4
id: string;
beginDate: string;
dateHidden?: string;
defaultQuantity?: number;
duration?: number;
endDate?: string;
entries: TrackerEntry[];
name: string;
remainingDays?: number;
requiredCompletions: Completion[];
status: TrackerStatus;
unit?: string;
}
16 changes: 14 additions & 2 deletions src/models/TrackerEntry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import Completion from './Completion';

/**
* A TrackerEntry is multiple Completions achieved on a precise date
*
* @interface TrackerEntry
* @member {string} id a v4 uuid
* @member {Completion[]} completions actions done, can't be empty
* @member {string} date when the entry was completed
* @member {string} trackerId Tracker the entry is attached to
*/
export default interface TrackerEntry {
id: string; // uuid v4
id: string;
completions: Completion[];
date: string;
quantity: number;
trackerId: string;
}

0 comments on commit 5848602

Please sign in to comment.