From b8e0e74f73f8c723682635df0fc89d94f904ff35 Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Sat, 5 Mar 2016 10:24:26 +0100 Subject: [PATCH] Fix #2 (removing unaired LPs from Sitemap) --- gparser/sitemap.go | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/gparser/sitemap.go b/gparser/sitemap.go index 876c51f..6940458 100644 --- a/gparser/sitemap.go +++ b/gparser/sitemap.go @@ -40,17 +40,17 @@ func GenerateSitemap() { temp.ChangeFreq = "hourly" temp.Priority = 1.0 uset.Url = append(uset.Url, temp) - temp.Location = config.C.SiteUrl + "/lets-play" + temp.Location = config.C.SiteUrl + "/lets-play/" temp.LastMod = time.Now() temp.ChangeFreq = "monthly" temp.Priority = 0.75 uset.Url = append(uset.Url, temp) - temp.Location = config.C.SiteUrl + "/testet" + temp.Location = config.C.SiteUrl + "/testet/" temp.LastMod = time.Now() temp.ChangeFreq = "monthly" temp.Priority = 0.75 uset.Url = append(uset.Url, temp) - temp.Location = config.C.SiteUrl + "/zeige" + temp.Location = config.C.SiteUrl + "/zeige/" temp.LastMod = time.Now() temp.ChangeFreq = "yearly" temp.Priority = 0.75 @@ -65,12 +65,14 @@ func genLPs(uset *urlset) { var LPs []database.LetsPlay database.Db.Where("aired IS NOT NULL").Find(&LPs) for _, LP := range LPs { - var temp URL - temp.Location = config.C.SiteUrl + "/lets-play/" + LP.Slug.String - temp.LastMod = LP.Aired - temp.ChangeFreq = "daily" - temp.Priority = 0.5 - uset.Url = append(uset.Url, temp) + if LP.Aired.IsZero() == false { + var temp URL + temp.Location = config.C.SiteUrl + "/lets-play/" + LP.Slug.String + "/" + temp.LastMod = LP.Aired + temp.ChangeFreq = "daily" + temp.Priority = 0.5 + uset.Url = append(uset.Url, temp) + } } } @@ -79,7 +81,7 @@ func genLTs(uset *urlset) { database.Db.Find(<s) for _, LT := range LTs { var temp URL - temp.Location = config.C.SiteUrl + "/testet/" + LT.Slug.String + temp.Location = config.C.SiteUrl + "/testet/" + LT.Slug.String + "/" temp.LastMod = LT.Aired temp.ChangeFreq = "never" temp.Priority = 0.5 @@ -91,13 +93,15 @@ func genEPs(uset *urlset) { var EPs []database.Episode database.Db.Find(&EPs) for _, EP := range EPs { - var LP database.LetsPlay - database.Db.Model(&EP).Related(&LP) - var temp URL - temp.Location = config.C.SiteUrl + "/lets-play/" + LP.Slug.String + "/" + EP.Slug.String - temp.LastMod = EP.Aired - temp.ChangeFreq = "never" - temp.Priority = 0.5 - uset.Url = append(uset.Url, temp) + if EP.Aired.IsZero() == false { + var LP database.LetsPlay + database.Db.Model(&EP).Related(&LP) + var temp URL + temp.Location = config.C.SiteUrl + "/lets-play/" + LP.Slug.String + "/" + EP.Slug.String + "/" + temp.LastMod = EP.Aired + temp.ChangeFreq = "never" + temp.Priority = 0.5 + uset.Url = append(uset.Url, temp) + } } }