// Append a new interval onto the end of article.Visits func addHourInterval(article *m.Article, currentTime time.Time, currentVisits int) { // Round down newInterval := &m.TimeInterval{ currentVisits, currentTime, } currentLength := len(article.Visits) newVisits := make([]m.TimeInterval, currentLength+1, currentLength+1) for i := 0; i < currentLength; i++ { newVisits[i] = article.Visits[i] } newVisits[currentLength] = *newInterval article.Visits = newVisits }
func (a *ArticleIn) Process(article *m.Article) error { extractedSection := e.ExtractSectionInfo(a.Doc) sections := make([]string, len(extractedSection.Sections)) for i, section := range extractedSection.Sections { sections[i] = section } article.Source = a.Site article.ArticleId = a.ArticleId article.Headline = e.ExtractTitleFromDocument(a.Doc) article.Subheadline = e.ExtractSubheadlineFromDocument(a.Doc) article.Section = extractedSection.Section article.Subsection = extractedSection.Subsection article.Sections = sections article.Created_at = time.Now() article.Updated_at = time.Now() article.Timestamp = e.ExtractTimestamp(a.Doc) article.Url = a.Url article.Photo = e.ExtractPhotoInfo(a.Doc) return nil }