Add Scrape History #15

Merged
SoXX merged 8 commits from dev/scrape-history into main 2024-10-15 10:46:41 +00:00
2 changed files with 30 additions and 0 deletions
Showing only changes of commit 4312cbdff5 - Show all commits

View File

@ -0,0 +1,19 @@
package models
import (
"time"
)
type ScrapeHistory struct {
ScrapeTaskID string `json:"scrape_task_id" gorm:"primaryKey"`
UserSourceID string `json:"user_source_id" gorm:""`
CreatedAt time.Time `json:"created_at" gorm:""`
FinishedAt time.Time `json:"finished_at" gorm:"null"`
Error string `json:"error" gorm:"null"`
AddedPosts int `json:"added_posts" gorm:"not null"`
DeletedPosts int `json:"deleted_posts" gorm:"not null"`
}
func (ScrapeHistory) TableName() string {
return "ScrapeHistory"
}

View File

@ -0,0 +1,11 @@
package models
import "testing"
func TestScrapeHistory_TableName(t *testing.T) {
scrapeHistory := ScrapeHistory{}
expectedTableName := "ScrapeHistory"
if tableName := scrapeHistory.TableName(); tableName != expectedTableName {
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
}
}