gva

package
v0.0.0-...-f06591a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TZ = func() *time.Location {
	l, err := time.LoadLocation("America/New_York")
	if err != nil {
		log.Panicln("cannot load location America/New_York:", err)
	}
	return l
}()

TZ is Eastern Time.

Functions

This section is empty.

Types

type Date

type Date struct {
	// contains filtered or unexported fields
}

Date is a date type with no time.

func NewDate

func NewDate(t time.Time) Date

NewDate creates a new Date from a time.

func ParseDate

func ParseDate(str string, loc *time.Location) (Date, error)

ParseDate parses a string of format "July 4, 2022".

func Today

func Today() Date

Today returns the current Date.

func (Date) Add

func (d Date) Add(duration time.Duration) Date

Add returns d + duration. If duration is less than 24h (1d), then it does nothing.

func (Date) After

func (d Date) After(other Date) bool

After returns true if d > other.

func (Date) AsTime

func (d Date) AsTime(clock time.Time) time.Time

AsTime converts the date into a Time using the clock within the time. The given clock time's timezone is used for the returned time.

func (Date) Before

func (d Date) Before(other Date) bool

Before returns true if d < other.

func (Date) Eq

func (d Date) Eq(other Date) bool

Eq returns true if d == other.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

type MassShootingRecord

type MassShootingRecord struct {
	IncidentID   int
	IncidentDate Date
	State        string
	CityCounty   string
	Address      string
	NoKilled     int
	NoInjured    int
	IncidentURL  string
	SourceURL    string
}

MassShootingRecord is a single record within a mass shootings record table.

func MassShootingsOnDate

func MassShootingsOnDate(ctx context.Context, scraper MassShootingsScraper, date Date) ([]MassShootingRecord, error)

MassShootingsOnDate fetches the list of all mass shooting records within the given day by automatically paginating the getter.

type MassShootingsScraper

type MassShootingsScraper interface {
	MassShootings(ctx context.Context, i int) ([]MassShootingRecord, error)
}

MassShootingsScraper describes Scraper's MassShootings getter.

type Scraper

type Scraper struct {
	Client  *http.Client
	BaseURL *url.URL
}

func NewScraper

func NewScraper() *Scraper

NewScraper creates a new Scraper.

func (*Scraper) MassShootings

func (s *Scraper) MassShootings(ctx context.Context, page int) ([]MassShootingRecord, error)

MassShootings scrapes for the list of mass shootings.

func (*Scraper) MassShootingsOnDate

func (s *Scraper) MassShootingsOnDate(ctx context.Context, date Date) ([]MassShootingRecord, error)

MassShootingsOnDate returns a list of mass shooting records for the given date.

func (*Scraper) MassShootingsToday

func (s *Scraper) MassShootingsToday(ctx context.Context) ([]MassShootingRecord, error)

MassShootingsToday returns a list of mass shooting records for today.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL