diff options
author | Matthew Lemon <y@yulqen.org> | 2024-04-23 11:16:38 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-04-23 11:16:38 +0100 |
commit | 0f951dcf029d4af284467543a3afdf5bf6581a20 (patch) | |
tree | a48384210cdc168e3bd3ccff6d6d516eeed9e748 /internal/models/engagement.go | |
parent | 8b084e9fe7a5f3a04c32daf9a24f7f2cf67300f9 (diff) |
switched to Django
Diffstat (limited to '')
-rw-r--r-- | internal/models/engagement.go | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/internal/models/engagement.go b/internal/models/engagement.go deleted file mode 100644 index 87e0786..0000000 --- a/internal/models/engagement.go +++ /dev/null @@ -1,54 +0,0 @@ -package models - -import ( - "database/sql" - "fmt" - "strconv" - "time" -) - -type EngagementStrategy struct { - ID int - ValidFrom time.Time - ValidTo time.Time - 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 -} - -func (m *EngagementStrategyModel) GetForOperation(id int) ([]EngagementStrategy, error) { - stmt := `SELECT id, valid_from, valid_to FROM engagement_strategies -WHERE operation_id = ?` - rows, err := m.DB.Query(stmt, id) - if err != nil { - return nil, err - } - - defer rows.Close() - - var esses []EngagementStrategy - - for rows.Next() { - var es EngagementStrategy - err = rows.Scan(&es.ID, &es.ValidFrom, &es.ValidTo) - if err != nil { - return nil, err - } - - esses = append(esses, es) - } - - if err = rows.Err(); err != nil { - return nil, err - } - - return esses, nil -} |