Documentation ¶
Index ¶
- Variables
- func AddUrlParams(urls []string, queryString string) []string
- func CalculateTimeInterval(articles []*mc.TopArticle, session *mgo.Session)
- func FormatChartbeatUrls(endPoint string, sites []string, apiKey string) ([]string, error)
- func GetHostFromParams(inputUrl string) (string, error)
- func GetQuickStats(url string) (*m.QuickStats, error)
- func GetRecents(url string) (*m.RecentResp, error)
- func GetTopGeo(url string) (*m.TopGeo, error)
- func GetTopPages(url string) (*mc.TopPages, error)
- func SortQuickStats(quickStats []*m.QuickStats) []*m.QuickStats
- func SortTopArticles(articles []*mc.TopArticle) []*mc.TopArticle
- type Beat
- type ByVisits
- type ChartbeatApi
- type ChartbeatFetch
- type ChartbeatUrl
- type QuickStatsSort
- type Quickstats
- type Recent
- type Referrers
- type TopGeo
- type TopPages
- type TrafficSeries
Constants ¶
This section is empty.
Variables ¶
var QuickStatsApi = ChartbeatApi{ ChartbeatUrl{"live/quickstats/v4", "all_platforms=1&loyalty=1"}, "quickstats", Quickstats{}, }
var RecentApi = ChartbeatApi{ ChartbeatUrl{"live/recent/v3", ""}, "recent", Recent{}, }
var ReferrersApi = ChartbeatApi{ ChartbeatUrl{"live/referrers/v3", ""}, "referrers", Referrers{}, }
var TopGeoApi = ChartbeatApi{ ChartbeatUrl{"live/top_geo/v1", ""}, "topgeo", TopGeo{}, }
var TopPagesApi = ChartbeatApi{ ChartbeatUrl{"live/toppages/v3", "all_platforms=1&loyalty=1"}, "popular", TopPages{}, }
TODO add back visits calculations
var TrafficSeriesApi = ChartbeatApi{ ChartbeatUrl{"historical/traffic/series", ""}, "traffic-series", TrafficSeries{}, }
* The beats
Functions ¶
func AddUrlParams ¶
Add query string to the end of the each url in an array of urls. Expects that some url params are already added
AddUrlParam(["http://google.com?test=123", "http://yahoo.com?test=abc"], "test2=added")
Result:
["http://google.com?test=123&test2=added", "http://yahoo.com?test=abc&test2=added"]
func CalculateTimeInterval ¶
func CalculateTimeInterval(articles []*mc.TopArticle, session *mgo.Session)
func FormatChartbeatUrls ¶
Format chartbeat URLs based on a chartbeat API endpoint
Format: http://api.chartbeat.com/<endPoint>/?apikey=<key>&host=<site[i]>&
Example endPoint (NOTE no starting or ending slashes): live/toppages/v3
func GetHostFromParams ¶
Chartbeat queries have a GET parameter "host", which represents the host we're getting data on. Pull the host from the url and return it. Return host (e.g. freep.com) Return "" if we don't find one
func GetQuickStats ¶
func GetQuickStats(url string) (*m.QuickStats, error)
func GetRecents ¶
func GetRecents(url string) (*m.RecentResp, error)
func GetTopPages ¶
Given a URL for the api.chartbeat.com/live/toppages/v3 API, get the data and read the response
func SortQuickStats ¶
func SortQuickStats(quickStats []*m.QuickStats) []*m.QuickStats
func SortTopArticles ¶
func SortTopArticles(articles []*mc.TopArticle) []*mc.TopArticle
Types ¶
type ChartbeatApi ¶
type ChartbeatApi struct { Url ChartbeatUrl MapiEndpoints string // comma-separated list of mapi endpoints to hit e.g. "quickstats,toppages,traffic-series" Fetch ChartbeatFetch // Interface in fetch/chartbeat/ that will fetch the chartbeat info }
ChartbeatApi to be used in the chartbeat package
func (ChartbeatApi) Run ¶
func (c ChartbeatApi) Run(session *mgo.Session, apiKey, gnapiDomain string, sites []string)
type ChartbeatFetch ¶
type ChartbeatUrl ¶
type ChartbeatUrl struct { ChartbeatEndpoint string // https://api.chartbeat.com API endpoint ChartbeatParams string // Urls params for chartbeat url, "" to specify none }
type QuickStatsSort ¶
type QuickStatsSort []*m.QuickStats
func (QuickStatsSort) Len ¶
func (q QuickStatsSort) Len() int
func (QuickStatsSort) Less ¶
func (q QuickStatsSort) Less(i, j int) bool
func (QuickStatsSort) Swap ¶
func (q QuickStatsSort) Swap(i, j int)
type Quickstats ¶
type Quickstats struct{}
type TrafficSeries ¶
type TrafficSeries struct { Data struct { Start int `json:"start"` End int `json:"end"` // frequency is the data sample interval in minutes Frequency int `json:"frequency"` // Michigan.com Freep *m.TrafficSeriesIn `json:"freep.com"` DetroitNews *m.TrafficSeriesIn `json:"detroitnews.com"` BattleCreek *m.TrafficSeriesIn `json:"battlecreekenquirer.com"` Hometown *m.TrafficSeriesIn `json:"hometownlife.com"` Lansing *m.TrafficSeriesIn `json:"lansingstatejournal.com"` Livingston *m.TrafficSeriesIn `json:"livingstondaily.com"` Herald *m.TrafficSeriesIn `json:"thetimesherald.com"` // Usat UsaToday *m.TrafficSeriesIn `json:"usatoday.com"` // Tennessean Tennessean *m.TrafficSeriesIn `json:"tennessean.com"` // Central Ohio omg why are there so many sites help Mansfield *m.TrafficSeriesIn `json:"mansfieldnewsjournal.com"` Newark *m.TrafficSeriesIn `json:"newarkadvocate.com"` Zanesville *m.TrafficSeriesIn `json:"zanesvilletimesrecorder.com"` Chillicothe *m.TrafficSeriesIn `json:"chillicothegazette.com"` Lancaster *m.TrafficSeriesIn `json:"lancastereaglegazette.com"` Marion *m.TrafficSeriesIn `json:"marionstar.com"` TheNewsMessenger *m.TrafficSeriesIn `json:"thenews-messenger.com"` Coshocton *m.TrafficSeriesIn `json:"coshoctontribune.com"` Bucyrus *m.TrafficSeriesIn `json:"bucyrustelegraphforum.com"` PortClinton *m.TrafficSeriesIn `json:"portclintonnewsherald.com"` // Central Ohio omg why are there so many sites help DesMoines *m.TrafficSeriesIn `json:"desmoinesregister.com"` PressCitizen *m.TrafficSeriesIn `json:"press-citizen.com"` Juice *m.TrafficSeriesIn `json:"dmjuice.com"` HawkCentral *m.TrafficSeriesIn `json:"hawkcentral.com"` } `json:"data"` }
func (TrafficSeries) Fetch ¶
func (h TrafficSeries) Fetch(urls []string, session *mgo.Session) m.Snapshot
func (*TrafficSeries) GetSeries ¶
func (h *TrafficSeries) GetSeries() *m.TrafficSeriesIn
func (*TrafficSeries) SignalMapi ¶
func (h *TrafficSeries) SignalMapi()
func (*TrafficSeries) String ¶
func (h *TrafficSeries) String() string