Skip to content

Commit

Permalink
Add db grooming
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrisbattarbee committed Apr 10, 2024
1 parent 642c0c0 commit f5c5b33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions scraper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f5c5b33

Please sign in to comment.