Get rid of duration

This commit is contained in:
Brandon Dyck 2020-03-31 22:40:06 -06:00
parent ab3aaaea24
commit da4cbc4c50
2 changed files with 3 additions and 9 deletions

View File

@ -136,7 +136,6 @@ func pageDoCreate(name, description string, earliest, latest time.Time) h.Term {
Description: description, Description: description,
EarliestDate: earliest, EarliestDate: earliest,
LatestDate: latest, LatestDate: latest,
Duration: 1,
}) })
if err != nil { if err != nil {
return h.Text(err.Error()) return h.Text(err.Error())

View File

@ -63,7 +63,6 @@ const schema = `
description TEXT NOT NULL, description TEXT NOT NULL,
earliest_date DATE NOT NULL, earliest_date DATE NOT NULL,
latest_date DATE NOT NULL, latest_date DATE NOT NULL,
duration INTEGER NOT NULL,
UNIQUE (alpha_id) UNIQUE (alpha_id)
); );
@ -94,7 +93,6 @@ type CreateEventCommand struct {
Name string Name string
Description string Description string
EarliestDate, LatestDate time.Time EarliestDate, LatestDate time.Time
Duration int
} }
type CreateEventResult struct { type CreateEventResult struct {
@ -118,8 +116,8 @@ func (s *Store) CreateEvent(ctx context.Context, cmd CreateEventCommand) (result
} }
const query = ` const query = `
INSERT INTO event(alpha_id, admin_code, name, description, earliest_date, latest_date, duration) INSERT INTO event(alpha_id, admin_code, name, description, earliest_date, latest_date)
VALUES (?, ?, ?, ?, ?, ?, ?);` VALUES (?, ?, ?, ?, ?, ?);`
err = sqlitex.Exec(conn, query, nil, err = sqlitex.Exec(conn, query, nil,
alphaID, alphaID,
adminCode, adminCode,
@ -127,7 +125,6 @@ func (s *Store) CreateEvent(ctx context.Context, cmd CreateEventCommand) (result
cmd.Description, cmd.Description,
cmd.EarliestDate.Format(dateFmt), cmd.EarliestDate.Format(dateFmt),
cmd.LatestDate.Format(dateFmt), cmd.LatestDate.Format(dateFmt),
cmd.Duration,
) )
if err != nil { if err != nil {
return return
@ -146,7 +143,6 @@ type GetEventResult struct {
Name string Name string
Description string Description string
EarliestDate, LatestDate time.Time EarliestDate, LatestDate time.Time
Duration int
} }
func (s *Store) GetEvent(ctx context.Context, query GetEventQuery) (GetEventResult, error) { 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) defer s.pool.Put(conn)
const dbQuery = ` const dbQuery = `
SELECT name, description, earliest_date, latest_date, duration SELECT name, description, earliest_date, latest_date
FROM event FROM event
WHERE alpha_id = ?;` WHERE alpha_id = ?;`
var result GetEventResult var result GetEventResult
@ -167,7 +163,6 @@ func (s *Store) GetEvent(ctx context.Context, query GetEventQuery) (GetEventResu
result.Description = stmt.ColumnText(1) result.Description = stmt.ColumnText(1)
earliestDateString := stmt.ColumnText(2) earliestDateString := stmt.ColumnText(2)
latestDateString := stmt.ColumnText(3) latestDateString := stmt.ColumnText(3)
result.Duration = stmt.ColumnInt(4)
var err error var err error
result.EarliestDate, err = time.Parse(dateFmt, earliestDateString) result.EarliestDate, err = time.Parse(dateFmt, earliestDateString)