From da4cbc4c50af4e32a44006264ee4734f3d08132a Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Tue, 31 Mar 2020 22:40:06 -0600 Subject: [PATCH] Get rid of duration --- http/server.go | 1 - store.go | 11 +++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/http/server.go b/http/server.go index 1b91368..5f728a4 100644 --- a/http/server.go +++ b/http/server.go @@ -136,7 +136,6 @@ func pageDoCreate(name, description string, earliest, latest time.Time) h.Term { Description: description, EarliestDate: earliest, LatestDate: latest, - Duration: 1, }) if err != nil { return h.Text(err.Error()) diff --git a/store.go b/store.go index 44d2b27..79e902b 100644 --- a/store.go +++ b/store.go @@ -63,7 +63,6 @@ const schema = ` description TEXT NOT NULL, earliest_date DATE NOT NULL, latest_date DATE NOT NULL, - duration INTEGER NOT NULL, UNIQUE (alpha_id) ); @@ -94,7 +93,6 @@ type CreateEventCommand struct { Name string Description string EarliestDate, LatestDate time.Time - Duration int } type CreateEventResult struct { @@ -118,8 +116,8 @@ func (s *Store) CreateEvent(ctx context.Context, cmd CreateEventCommand) (result } const query = ` - INSERT INTO event(alpha_id, admin_code, name, description, earliest_date, latest_date, duration) - VALUES (?, ?, ?, ?, ?, ?, ?);` + INSERT INTO event(alpha_id, admin_code, name, description, earliest_date, latest_date) + VALUES (?, ?, ?, ?, ?, ?);` err = sqlitex.Exec(conn, query, nil, alphaID, adminCode, @@ -127,7 +125,6 @@ func (s *Store) CreateEvent(ctx context.Context, cmd CreateEventCommand) (result cmd.Description, cmd.EarliestDate.Format(dateFmt), cmd.LatestDate.Format(dateFmt), - cmd.Duration, ) if err != nil { return @@ -146,7 +143,6 @@ type GetEventResult struct { Name string Description string EarliestDate, LatestDate time.Time - Duration int } func (s *Store) GetEvent(ctx context.Context, query GetEventQuery) (GetEventResult, error) { @@ -154,7 +150,7 @@ func (s *Store) GetEvent(ctx context.Context, query GetEventQuery) (GetEventResu defer s.pool.Put(conn) const dbQuery = ` - SELECT name, description, earliest_date, latest_date, duration + SELECT name, description, earliest_date, latest_date FROM event WHERE alpha_id = ?;` var result GetEventResult @@ -167,7 +163,6 @@ func (s *Store) GetEvent(ctx context.Context, query GetEventQuery) (GetEventResu result.Description = stmt.ColumnText(1) earliestDateString := stmt.ColumnText(2) latestDateString := stmt.ColumnText(3) - result.Duration = stmt.ColumnInt(4) var err error result.EarliestDate, err = time.Parse(dateFmt, earliestDateString)