Minor clean up
This commit is contained in:
4
db/db.go
4
db/db.go
@@ -25,11 +25,7 @@ type News struct {
|
|||||||
Author string `json:"by"`
|
Author string `json:"by"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
Score int `json:"score"`
|
Score int `json:"score"`
|
||||||
Parent int `json:"parent"`
|
|
||||||
Comments int `json:"descendants"`
|
|
||||||
Category string `json:"type"`
|
Category string `json:"type"`
|
||||||
Delete bool `json:"delete"`
|
|
||||||
Dead bool `json:"dead"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DynamoDBDescribeTableAPI interface {
|
type DynamoDBDescribeTableAPI interface {
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func HackernewsTable() string {
|
||||||
|
return "hacker_news_table"
|
||||||
|
}
|
||||||
|
|
||||||
|
func HackernewsTemplate() string {
|
||||||
|
return "hackernews_template"
|
||||||
|
}
|
||||||
|
|
||||||
func GetTopNewsIds(url string) (response []string) {
|
func GetTopNewsIds(url string) (response []string) {
|
||||||
fmt.Println("Retrieving news...")
|
fmt.Println("Retrieving news...")
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ func Handler(ctx context.Context) (string, error) {
|
|||||||
fetchSize, _ := strconv.Atoi(os.Getenv("FETCH_SIZE"))
|
fetchSize, _ := strconv.Atoi(os.Getenv("FETCH_SIZE"))
|
||||||
|
|
||||||
var newsBatch []db.News
|
var newsBatch []db.News
|
||||||
table := "news_table"
|
table := hackernews.HackernewsTable()
|
||||||
|
htmlTemplate := hackernews.HackernewsTable()
|
||||||
|
|
||||||
cfg, err := config.LoadDefaultConfig(context.TODO())
|
cfg, err := config.LoadDefaultConfig(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -64,7 +65,7 @@ func Handler(ctx context.Context) (string, error) {
|
|||||||
|
|
||||||
todayNews, _ := db.ReadTodayNews(newsTable, int(timeStart.Unix()), int(timeEnd.Unix()))
|
todayNews, _ := db.ReadTodayNews(newsTable, int(timeStart.Unix()), int(timeEnd.Unix()))
|
||||||
|
|
||||||
t, err := template.ParseFiles("mail/index.gohtml")
|
t, err := template.ParseFiles(fmt.Sprintf("assets/%v.gohtml", htmlTemplate))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user