diff --git a/common/db/db.go b/common/db/db.go index ffeea26..a1b8ccb 100644 --- a/common/db/db.go +++ b/common/db/db.go @@ -234,3 +234,14 @@ func (d *DbClient) SeedStatusPages() error { } return nil } + +func (d *DbClient) DeleteStatusPage(background context.Context, url string) error { + if url == "" { + return errors.New("url cannot be empty") + } + result := d.db.Table(fmt.Sprintf("%s.%s", schemaName, statusPageTableName)).Where("url = ?", url).Delete(&api.StatusPage{}) + if result.Error != nil { + return result.Error + } + return nil +} diff --git a/scraper/main.go b/scraper/main.go index 948fbde..0e37263 100644 --- a/scraper/main.go +++ b/scraper/main.go @@ -6,6 +6,7 @@ import ( "github.com/metoro-io/statusphere/scraper/internal/scraper" "github.com/metoro-io/statusphere/scraper/internal/scraper/consumers" "github.com/metoro-io/statusphere/scraper/internal/scraper/consumers/dbconsumer" + "github.com/metoro-io/statusphere/scraper/internal/scraper/dbgroomer" "github.com/metoro-io/statusphere/scraper/internal/scraper/poller" "github.com/metoro-io/statusphere/scraper/internal/scraper/providers" "github.com/metoro-io/statusphere/scraper/internal/scraper/providers/atlassian" @@ -40,6 +41,8 @@ func main() { getter := dburlgetter.NewDBURLGetter(logger, dbClient) getter.Start() + dbGroomer := dbgroomer.NewDbGroomer(logger, dbClient) + dbGroomer.Groom() poller := poller.NewPoller(getter, scraper, []consumers.Consumer{ dbconsumer.NewDbConsumer(logger, dbClient), }, logger)