Minor clean up

This commit is contained in:
Riccardo
2022-07-30 13:35:14 +02:00
parent 9f5d892e5b
commit 61b13de6ec
4 changed files with 11 additions and 6 deletions

View File

@@ -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 {

View File

@@ -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...")

View File

@@ -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)
} }