public PostScraper(ConnectionSettings settings, string defaultIndex, PageScraper pageScraper, GraphClient graphClient) : base(settings, defaultIndex, i => { // We need to tell Elasticsearch explicitly that this field is a geopoint. return(i.Mappings(ms => ms.Map <ScrapedPost>(m => m.Properties(p => { return p.GeoPoint(g => g.Name("geoPoint")); })))); }) { PageScraper = pageScraper; GraphClient = graphClient; }
public void UpdateMetadata(ScrapedPost post, string pageName) { // Update the database with the new post. Location location = post.Place?.Location; if (location != null) { post.GeoPoint = $"{location.Latitude},{location.Longitude}"; } else { post.GeoPoint = null; } ScrapedPage scrapedPage = PageScraper.Closest(p => p.Name, pageName, post.CreatedTime); post.Page = scrapedPage; post.LastScraped = DateTime.Now; if (post.Scraped == DateTime.MinValue) { post.Scraped = post.LastScraped; } }