Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Update for 2021 season #12

Merged
merged 3 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
on: push
name: Go Actions
name: build
jobs:
go-test:
go-pipeline:
name: Go Test
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/checkout@master
- name: tests
uses: shoukoo/golang-pipeline/go1.12/test@master
uses: shoukoo/golang-pipeline/go1.13/test@master
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Go 76ers

[![Go Report Card](https://goreportcard.com/badge/grahamplata/sixers)](https://goreportcard.com/report/grahamplata/sixers)

# Go 76ers
A Simple command line tool for my favorite team.

## Current cli

Expand Down Expand Up @@ -29,6 +31,36 @@ Flags:
Use "sixers [command] --help" for more information about a command.
```

## Commands

### Next

```bash
sixers next
10,9 8 76ers! There is a game @ 7:00 PM ET
```

### Record

```bash
sixers record
Wins: 2 Losses: 1 Win pct: 0.667
```

### Schedule

```bash
sixers schedule
--------- ---------------------- ------------- ------------- ------------------------
Game Date Home Away Winner
--------- ---------------------- ------------- ------------- ------------------------
1 December 23, 2020 PHI: 113 WAS: 107 Philadelphia 76ers

2 December 26, 2020 NYK: 89 PHI: 109 Philadelphia 76ers

3 December 27, 2020 CLE: 118 PHI: 94 Cleveland Cavaliers
```

## Running tests

```bash
Expand Down
1 change: 0 additions & 1 deletion cmd/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ var scheduleCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(scheduleCmd)
// Here you will define your flags and configuration settings.
scheduleCmd.Flags().StringP("year", "y", "", "The year of the season you would like to query")
}
17 changes: 7 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
Copyright © 2019 Graham Plata <graham.plata@gmail.com>
*/

package config

import (
Expand All @@ -6,18 +10,12 @@ import (
"github.com/logrusorgru/aurora"
)

/*
Copyright © 2019 Graham Plata <graham.plata@gmail.com>
*/

// API Configuration
////////////////////////////////////////////////////////////

// APIURL is the base endpoint string
const APIURL string = "https://www.balldontlie.io/api/v1/games"

// Team Configuration
////////////////////////////////////////////////////////////

// TeamID is the sixers team id from the api
const TeamID int = 23
Expand All @@ -26,13 +24,12 @@ const TeamID int = 23
var SixersLogo string = fmt.Sprintf("%d%ders", aurora.Bold(aurora.Red(7)), aurora.Bold(aurora.Blue(6)))

// Date Time Configuration
////////////////////////////////////////////////////////////

// YearFormat year format
const YearFormat = "2006"
const YearFormat string = "2006"

// LayoutISO year format
const LayoutISO = "2006-01-02"
const LayoutISO string = "2006-01-02"

// LayoutUS year format
const LayoutUS = "January 2, 2006"
const LayoutUS string = "January 2, 2006"
18 changes: 5 additions & 13 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func Next() {
for _, v := range results.Data {
if v.Status != "Final" {
gameTime := strings.TrimRight(v.Time, " ")
nextResponse := fmt.Sprintf("10,9 8 %s! There is a game currently @ %s %+s\n", config.SixersLogo, v.Status, gameTime)
nextResponse := fmt.Sprintf("10,9 8 %s! There is a game @ %s %+s", config.SixersLogo, v.Status, gameTime)
fmt.Println(nextResponse)
break
}
}
}
Expand All @@ -36,7 +37,6 @@ func Record(cmd *cobra.Command) {
if yearFlag.Value.String() == "" {
requestParams.Year = time.Now().Format(config.YearFormat)
} else {
// TODO add format check
requestParams.Year = yearFlag.Value.String()
}

Expand All @@ -61,7 +61,6 @@ func Record(cmd *cobra.Command) {
losses := fmt.Sprintf("%s %d", aurora.Red("Losses:"), (gameCount - winRecord))
pct := fmt.Sprintf("%s %.3f", aurora.Yellow("Win pct:"), (float64(winRecord) / float64(gameCount)))
final := fmt.Sprintf("%s %s %s", wins, losses, pct)

fmt.Println(final)
}

Expand All @@ -76,7 +75,6 @@ func Schedule(cmd *cobra.Command) {
if yearFlag.Value.String() == "" {
requestParams.Year = time.Now().Format(config.YearFormat)
} else {
// TODO add format check
requestParams.Year = yearFlag.Value.String()
}

Expand All @@ -92,16 +90,10 @@ func Schedule(cmd *cobra.Command) {
away := fmt.Sprintf("%s: %v", v.VisitorTeam.Abbreviation, v.VisitorTeamScore)

if v.VisitorTeamScore != 0 || v.HomeTeamScore != 0 {
if v.HomeTeam.ID == config.TeamID {
if v.HomeTeamScore > v.VisitorTeamScore {
winner = v.HomeTeam.FullName
}
} else {
if v.HomeTeamScore < v.VisitorTeamScore {
winner = v.HomeTeam.FullName
}
}
winner = v.VisitorTeam.FullName
if v.HomeTeamScore > v.VisitorTeamScore {
winner = v.HomeTeam.FullName
}
}

game := []string{gameNum, formattedTime, home, away, winner}
Expand Down