Fix NULL handling for nullable integer columns in getFeed
TTLMinutes, UpdateFreq, ErrorCount, ItemCount, and NoUpdate columns can be NULL in the database. Use pointer types and handle them properly to avoid scan errors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -251,6 +251,7 @@ func (c *Crawler) getFeed(feedURL string) (*Feed, error) {
|
||||
var etag, lastModified, updatePeriod, lastError, sourceURL, sourceHost, tld *string
|
||||
var avgPostFreqHrs *float64
|
||||
var publishStatus, publishAccount *string
|
||||
var ttlMinutes, updateFreq, errorCount, itemCount, noUpdate *int
|
||||
|
||||
err := c.db.QueryRow(`
|
||||
SELECT url, type, category, title, description, language, site_url,
|
||||
@@ -267,11 +268,11 @@ func (c *Crawler) getFeed(feedURL string) (*Feed, error) {
|
||||
&feed.URL, &feed.Type, &category, &title, &description, &language, &siteURL,
|
||||
&feed.DiscoveredAt, &lastCrawledAt, &nextCrawlAt, &lastBuildDate,
|
||||
&etag, &lastModified,
|
||||
&feed.TTLMinutes, &updatePeriod, &feed.UpdateFreq,
|
||||
&feed.Status, &feed.ErrorCount, &lastError, &lastErrorAt,
|
||||
&ttlMinutes, &updatePeriod, &updateFreq,
|
||||
&feed.Status, &errorCount, &lastError, &lastErrorAt,
|
||||
&sourceURL, &sourceHost, &tld,
|
||||
&feed.ItemCount, &avgPostFreqHrs, &oldestItemDate, &newestItemDate,
|
||||
&feed.NoUpdate,
|
||||
&itemCount, &avgPostFreqHrs, &oldestItemDate, &newestItemDate,
|
||||
&noUpdate,
|
||||
&publishStatus, &publishAccount,
|
||||
)
|
||||
|
||||
@@ -297,17 +298,32 @@ func (c *Crawler) getFeed(feedURL string) (*Feed, error) {
|
||||
feed.LastBuildDate = TimeValue(lastBuildDate)
|
||||
feed.ETag = StringValue(etag)
|
||||
feed.LastModified = StringValue(lastModified)
|
||||
if ttlMinutes != nil {
|
||||
feed.TTLMinutes = *ttlMinutes
|
||||
}
|
||||
feed.UpdatePeriod = StringValue(updatePeriod)
|
||||
if updateFreq != nil {
|
||||
feed.UpdateFreq = *updateFreq
|
||||
}
|
||||
if errorCount != nil {
|
||||
feed.ErrorCount = *errorCount
|
||||
}
|
||||
feed.LastError = StringValue(lastError)
|
||||
feed.LastErrorAt = TimeValue(lastErrorAt)
|
||||
feed.SourceURL = StringValue(sourceURL)
|
||||
feed.SourceHost = StringValue(sourceHost)
|
||||
feed.TLD = StringValue(tld)
|
||||
if itemCount != nil {
|
||||
feed.ItemCount = *itemCount
|
||||
}
|
||||
if avgPostFreqHrs != nil {
|
||||
feed.AvgPostFreqHrs = *avgPostFreqHrs
|
||||
}
|
||||
feed.OldestItemDate = TimeValue(oldestItemDate)
|
||||
feed.NewestItemDate = TimeValue(newestItemDate)
|
||||
if noUpdate != nil {
|
||||
feed.NoUpdate = *noUpdate
|
||||
}
|
||||
if publishStatus != nil {
|
||||
feed.PublishStatus = *publishStatus
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user