Plan stuff. Log stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.7 KiB

4 years ago
  1. /**
  2. * Data about an time period.
  3. */
  4. export default class Period {
  5. /** The ID of the Period. */
  6. id : string;
  7. /** The ID of the owning user. */
  8. userId : string;
  9. /** The inclusive start time. */
  10. from : Date;
  11. /** The exclusive end date. */
  12. to : Date;
  13. /** The name of the time period, usually generated.*/
  14. name : string;
  15. /**
  16. * Tags used to explain the goals being out of the ordinary. For example,
  17. * if leaving for a vacation where hobbies are best put on hold.
  18. */
  19. tags : string[];
  20. /** The goals set for this time period. */
  21. goals : PeriodGoal[];
  22. /** Logged activities during this time period. */
  23. logs : PeriodLog[];
  24. }
  25. /**
  26. * A goal set during the period.
  27. */
  28. export class PeriodGoal {
  29. /** The ID of the PeriodGoal. */
  30. id : string
  31. /** The activity ID associated with the goal. */
  32. activityId : string
  33. /** The point count for the goal. 1000 is usually considered an hour's work. */
  34. pointCount : number
  35. /** Optional sub-goals. */
  36. subGoals : PeriodSubGoal[];
  37. }
  38. /**
  39. * Optional sub-goals so that the user can award more points on important
  40. * activities and not use up all the points on time-sinking guilty pleasures.
  41. */
  42. export class PeriodSubGoal {
  43. /** The ID of the PeriodSubGoal. */
  44. id : string;
  45. /** A short name of the sub goal. */
  46. name : string;
  47. /** The multiplier applied to the score. 1.10 = 10% better. */
  48. multiplier : number;
  49. }
  50. /**
  51. * A logged activity during this time period.
  52. */
  53. export class PeriodLog {
  54. /** The ID of the PeriodLog. */
  55. id : string;
  56. /** The ID of the PeriodLog. */
  57. date : Date;
  58. /** The ID of the sub-activity performed (see goal for activity id) */
  59. subActivityId : string;
  60. /** The ID of the goal. */
  61. goalId : string;
  62. /** The applicable sub goal, or `null` if none. */
  63. subGoalId : string;
  64. /** A description of the activity performed. */
  65. description : string;
  66. /** The amount of units done. */
  67. amount : number
  68. /** The calculated score and its breakdown. */
  69. score : PeriodLogScore
  70. }
  71. /**
  72. * The PeriodLogScore is a score for the log. This may not reflect the
  73. * latest numbers.
  74. */
  75. export class PeriodLogScore {
  76. /** The amount of activity done (e.g number of words or minutes). */
  77. amount : number;
  78. /** The score that's worth. */
  79. activityScore : number;
  80. /** The subgoal multiplier in effect. */
  81. subGoalMultiplier : number;
  82. /** The daily bonus, or 0 if not applicable. */
  83. dailyBonus : number;
  84. /** The total score. */
  85. total : number;
  86. }
  87. export interface PeriodUpdate {
  88. setFrom?: Date
  89. setTo?: Date
  90. setName?: string
  91. addLog?: PeriodLog
  92. removeLog?: string
  93. addGoal?: PeriodGoal
  94. replaceGoal?: PeriodGoal
  95. removeGoal?: string
  96. addTag?: string
  97. removeTag?: String
  98. }