Documentation
¶
Overview ¶
api package contains the Newshound API.
Index ¶
- func FindAlertByID(ctx context.Context, db *mgo.Database, alertID string) (newshound.NewsAlert, error)
- func FindAlertHtmlByID(ctx context.Context, db *mgo.Database, alertID string) (string, error)
- func FindAlertsByDate(ctx context.Context, db *mgo.Database, start time.Time, end time.Time) ([]newshound.NewsAlertLite, error)
- func FindEventByID(ctx context.Context, db *mgo.Database, eventID string) (event newshound.NewsEvent, err error)
- func FindEventsByDate(ctx context.Context, db *mgo.Database, start time.Time, end time.Time) (events []newshound.NewsEvent, err error)
- func FindEventsByDateReverse(ctx context.Context, db *mgo.Database, start time.Time, end time.Time) (events []newshound.NewsEvent, err error)
- func FindOrderedAlerts(ctx context.Context, db *mgo.Database, alertIDs []string) ([]newshound.NewsAlertLite, error)
- func NewService() (server.MixedService, error)
- type AlertWeekInfo
- type AlertsPerHourResult
- type AvgAlertsPerWeek
- type AvgAlertsReport
- type AvgAlertsValue
- type AvgEventsPerWeek
- type AvgEventsReport
- type AvgEventsValue
- type Config
- type EventAttendReport
- type EventAttendValue
- type EventAttendance
- type EventWeekInfo
- type SenderInfo
- type TagArrayResult
- type TagInfo
- type TimeframeID
- type WeekInfoID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAlertByID ¶
func FindAlertByID(ctx context.Context, db *mgo.Database, alertID string) (newshound.NewsAlert, error)
FindAlertByID accepts a News Alert ID and returns the full version of that New Alert's information.
func FindAlertHtmlByID ¶
FindAlertHtmlByID accepts a News Alert ID and just the body of the given News Alert.
func FindAlertsByDate ¶
func FindAlertsByDate(ctx context.Context, db *mgo.Database, start time.Time, end time.Time) ([]newshound.NewsAlertLite, error)
FindByDate will accept a date range and return any News Alerts that occured within it. News Alert information returned will be of the 'lite' form without the raw and scrubbed bodies.
func FindEventByID ¶
func FindEventByID(ctx context.Context, db *mgo.Database, eventID string) (event newshound.NewsEvent, err error)
FindEventByID accepts a News Event ID and returns the full information for that Event.
func FindEventsByDate ¶
func FindEventsByDate(ctx context.Context, db *mgo.Database, start time.Time, end time.Time) (events []newshound.NewsEvent, err error)
FindByDate accepts a start and end date and returns all the News Events that occured in that timeframe.
func FindEventsByDateReverse ¶
func FindEventsByDateReverse(ctx context.Context, db *mgo.Database, start time.Time, end time.Time) (events []newshound.NewsEvent, err error)
FindByDateReverse accepts a start and end date and returns all the News Events that occured in that timeframe order by time desc.
func FindOrderedAlerts ¶
func FindOrderedAlerts(ctx context.Context, db *mgo.Database, alertIDs []string) ([]newshound.NewsAlertLite, error)
FindByDate accepts a slice of News Alert IDs and returns a chronologically ordered list of the 'lite' version of News Alerts.
func NewService ¶
func NewService() (server.MixedService, error)
Types ¶
type AlertWeekInfo ¶
type AlertWeekInfo struct { Id WeekInfoID `json:"_id" bson:"_id"` Value struct { Alerts int `json:"alerts"` TagMap map[string]int64 `json:"tag_map"bson:"tag_map"` } `json:"value"` }
AlertWeekInfo holds the 'alerts per week' counts for a particular sender.
type AlertsPerHourResult ¶
type AlertsPerHourResult struct { ID WeekInfoID `json:"_id" bson:"_id"` Value struct { Hours map[string]int64 `json:"hours"` } }
AlertsPerHourResult is used as a helper struct to pull 'alerts per hour' information from the database.
type AvgAlertsPerWeek ¶
type AvgAlertsPerWeek struct { ID TimeframeID `json:"id"bson:"_id"` Value AvgAlertsValue `json:"value"bson:"value"` }
type AvgAlertsReport ¶
type AvgAlertsReport struct { Sender string `json:"sender"` Values map[string]AvgAlertsValue `json:"values"` }
func GetAlertsPerWeek ¶
func GetAlertsPerWeek(db *mgo.Database) ([]AvgAlertsReport, error)
type AvgAlertsValue ¶
type AvgEventsPerWeek ¶
type AvgEventsPerWeek struct { ID TimeframeID `json:"id"bson:"_id"` Value AvgEventsValue `json:"value"bson:"value"` }
type AvgEventsReport ¶
type AvgEventsReport struct { Sender string `json:"sender"` Values map[string]AvgEventsValue `json:"values"` }
func GetEventsPerWeek ¶
func GetEventsPerWeek(db *mgo.Database) ([]AvgEventsReport, error)
type AvgEventsValue ¶
type AvgEventsValue struct { AvgEvents float64 `json:"avg_events"bson:"avg_events"` TotalEvents int64 `json:"total_events"bson:"total_events"` TotalRank int64 `json:"total_rank"bson:"total_rank"` AvgRank float64 `json:"avg_rank"bson:"avg_rank"` TotalTimeLapsed int64 `json:"total_time_lapsed"bson:"total_time_lapsed"` AvgTimeLapsed float64 `json:"avg_time_lapsed"bson:"avg_time_lapsed"` }
type Config ¶
type Config struct { DBURL string `envconfig:"DB_URL"` DBUser string `envconfig:"DB_USER"` DBPassword string `envconfig:"DB_PASSWORD"` }
func (*Config) MgoSession ¶
type EventAttendReport ¶
type EventAttendReport struct { Sender string `json:"sender"` Values map[string]EventAttendValue `json:"values"` }
func GetEventAttendance ¶
func GetEventAttendance(db *mgo.Database) ([]EventAttendReport, error)
type EventAttendValue ¶
type EventAttendance ¶
type EventAttendance struct { ID TimeframeID `json:"id"bson:"_id"` Value EventAttendValue `json:"value"bson:"value"` }
type EventWeekInfo ¶
type EventWeekInfo struct { Id WeekInfoID `json:"_id" bson:"_id"` Value struct { TotalEvents int64 `json:"total_events"bson:"total_events"` TotalRank int64 `json:"total_rank"bson:"total_rank"` AvgRank float64 `json:"avg_rank"bson:"avg_rank"` TotalTimeLapsed int64 `json:"total_time_lapsed"bson:"total_time_lapsed"` AvgTimeLapsed float64 `json:"avg_time_lapsed"bson:"avg_time_lapsed"` } `json:"value"bson:"value"` }
EventWeekInfo holds the 'events per week' counts for a particular sender.
type SenderInfo ¶
type SenderInfo struct { AlertsPerWeek []AlertWeekInfo `json:"alerts_per_week"bson:"alerts_per_week"` EventsPerWeek []EventWeekInfo `json:"events_per_week"bson:"events_per_week"` TagArray []TagInfo `json:"tag_array"bson:"tag_array"` AlertsPerHour []int64 `json:"alerts_per_hour"bson:"alerts_per_hour"` }
SenderInfo is a struct for containing the Sender Info report for the past 3 months.
func FindSenderInfo ¶
func FindSenderInfo(db *mgo.Database, sender string) (senderInfo SenderInfo, err error)
FindSenderInfo returns the full Sender Info report for the given sender over the past 3 months.
type TagArrayResult ¶
type TagArrayResult struct { Value struct { TagArray []TagInfo `bson:"tag_array"` } }
TagArrayResult is used as a helper to pull 'top tags' information from the database.
type TimeframeID ¶
type WeekInfoID ¶
type WeekInfoID struct { Sender string `json:"sender"` WeekStart time.Time `json:"week_start"bson:"week_start"` }
WeekInfoID is used as a helper to pull 'alerts per week' and 'events per week' info from the database.