Update algorithm and API documentation for smoking tracking app
- Enhanced the algorithm documentation to clarify the calculation of smoking intervals, including default values and edge cases. - Updated API documentation to reflect changes in response formats, including the addition of `exceeded_yesterday` and adjustments to time formatting to RFC3339. - Improved descriptions of user profile management and AI suggestions in the product documentation, ensuring consistency across all related files. - Removed outdated sequence diagram and UI documentation files to streamline project resources.
This commit is contained in:
@@ -21,6 +21,7 @@ type nextSmokeTimeUnifiedResponse struct {
|
||||
TodayCount int `json:"today_count"`
|
||||
Resisted int `json:"resisted_count"`
|
||||
Reduced int `json:"reduced_from_yesterday"`
|
||||
Exceeded bool `json:"exceeded_yesterday"`
|
||||
TimeNodes []string `json:"time_nodes,omitempty"`
|
||||
Advice string `json:"advice,omitempty"`
|
||||
Default nextSmokeDefaultResponse `json:"default"`
|
||||
@@ -84,7 +85,7 @@ func (h *SmokeHandler) GetNextSmokeTime(c *gin.Context) {
|
||||
if t == nil {
|
||||
return ""
|
||||
}
|
||||
return t.In(time.Local).Format(dateTimeLayout)
|
||||
return t.In(time.Local).Format(time.RFC3339)
|
||||
}
|
||||
|
||||
formatTimeString := func(value string) string {
|
||||
@@ -93,10 +94,10 @@ func (h *SmokeHandler) GetNextSmokeTime(c *gin.Context) {
|
||||
return ""
|
||||
}
|
||||
if t, err := time.Parse(time.RFC3339, value); err == nil {
|
||||
return t.In(time.Local).Format(dateTimeLayout)
|
||||
return t.In(time.Local).Format(time.RFC3339)
|
||||
}
|
||||
if t, err := time.ParseInLocation(dateTimeLayout, value, time.Local); err == nil {
|
||||
return t.In(time.Local).Format(dateTimeLayout)
|
||||
return t.In(time.Local).Format(time.RFC3339)
|
||||
}
|
||||
return value
|
||||
}
|
||||
@@ -137,6 +138,7 @@ func (h *SmokeHandler) GetNextSmokeTime(c *gin.Context) {
|
||||
TodayCount: homeSummary.TodayCount,
|
||||
Resisted: homeSummary.ResistedCount,
|
||||
Reduced: homeSummary.ReducedFromYesterday,
|
||||
Exceeded: homeSummary.ExceededYesterday,
|
||||
Default: formatDefault(defaultSuggestion),
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ type SmokeHomeSummary struct {
|
||||
TodayCount int
|
||||
ResistedCount int
|
||||
ReducedFromYesterday int
|
||||
ExceededYesterday bool
|
||||
}
|
||||
|
||||
// DashboardWeeklyStat 表示某一天的抽烟支数以及是否为今天。
|
||||
@@ -290,9 +291,7 @@ func (s *SmokeLogService) HomeSummary(ctx context.Context, uid int, asOf time.Ti
|
||||
}
|
||||
|
||||
reduced := int(yesterdayCount - todayCount)
|
||||
if reduced < 0 {
|
||||
reduced = 0
|
||||
}
|
||||
exceeded := reduced < 0
|
||||
|
||||
var lastSmokeAt *time.Time
|
||||
var last smokemodel.SmokeLog
|
||||
@@ -315,6 +314,7 @@ func (s *SmokeLogService) HomeSummary(ctx context.Context, uid int, asOf time.Ti
|
||||
TodayCount: int(todayCount),
|
||||
ResistedCount: int(resistedCount),
|
||||
ReducedFromYesterday: reduced,
|
||||
ExceededYesterday: exceeded,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user