Skip to content
This repository was archived by the owner on Feb 4, 2021. It is now read-only.

Commit d873ec3

Browse files
committed
Fix schema
1 parent c76ea7a commit d873ec3

File tree

4 files changed

+10
-34
lines changed

4 files changed

+10
-34
lines changed

app/server/entries_server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ func entryToResponse(entry *record.Entry, includeEmail bool, cfg *config.Config)
7979
Link: entry.Link,
8080
ImageUrl: entry.ImageURL,
8181
UpdatedAt: timeToResponse(entry.UpdatedAt),
82-
}
83-
if t := entry.PublishedAt; t.Valid {
84-
e.PublishedAt = timeToResponse(t.Time)
82+
PublishedAt: timeToResponse(entry.PublishedAt),
8583
}
8684
if r := entry.R; r != nil {
8785
e.Author = userToResponse(r.Author, includeEmail, cfg)

db/entries.schema

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ create_table :entries, force: :cascade do |t|
77
t.string :guid, null: false
88
t.string :image_url, null: false
99
t.references :blog, foreign_key: true, null: false
10-
t.datetime :published_at, null: true
10+
t.datetime :published_at, null: false
1111
t.timestamps
1212

1313
t.index [:guid], unique: true

infra/record/entries.go

Lines changed: 3 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/store/entry/entry_store.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"database/sql"
77
"encoding/base64"
88
"encoding/binary"
9+
"time"
910

1011
"github.com/mmcdole/gofeed"
1112
"github.com/pkg/errors"
12-
"github.com/volatiletech/null"
1313
"github.com/volatiletech/sqlboiler/boil"
1414
"github.com/volatiletech/sqlboiler/queries/qm"
1515

@@ -113,8 +113,10 @@ func (s *entryStoreImpl) CreateEntries(blog *record.Blog, feed *gofeed.Feed) (n
113113
if i := item.Image; i != nil {
114114
e.ImageURL = i.URL
115115
}
116-
if t := item.PublishedParsed; t != nil {
117-
e.PublishedAt = null.TimeFrom(t.In(boil.GetLocation()))
116+
if t := item.PublishedParsed; t == nil {
117+
e.PublishedAt = time.Now().In(boil.GetLocation())
118+
} else {
119+
e.PublishedAt = t.In(boil.GetLocation())
118120
}
119121

120122
err = e.Insert(s.ctx, tx, boil.Infer())

0 commit comments

Comments
 (0)