diff options
author | Matthew Lemon <y@yulqen.org> | 2024-02-12 16:50:26 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-02-12 16:50:26 +0000 |
commit | f7d5e262ac8c6903d71f38f52ae53ab5f65f0769 (patch) | |
tree | 07492208aa10832bf7ee5a87e39f6db389e0c63d /internal/models/engagement.go | |
parent | b64bb5cc7971092e76929a1cbabfafc813a8eb96 (diff) |
Method to format an EngagementStrategy for rendering
The objective is to render a link to the ES in the Operations table.
Only the start year and end year are required for it to make sense.
Diffstat (limited to '')
-rw-r--r-- | internal/models/engagement.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/models/engagement.go b/internal/models/engagement.go index 26b468a..87e0786 100644 --- a/internal/models/engagement.go +++ b/internal/models/engagement.go @@ -2,6 +2,8 @@ package models import ( "database/sql" + "fmt" + "strconv" "time" ) @@ -12,6 +14,12 @@ type EngagementStrategy struct { Operation Operation } +func (es *EngagementStrategy) FormatForTable() string { + startYear := strconv.Itoa(es.ValidFrom.Year()) + endYear := strconv.Itoa(es.ValidTo.Year()) + return fmt.Sprintf("%s-%s", startYear, endYear) +} + type EngagementStrategyModel struct { DB *sql.DB } |