Giter Site home page Giter Site logo

pigmice2733 / peregrine-backend Goto Github PK

View Code? Open in Web Editor NEW
19.0 9.0 4.0 1.4 MB

The future of FRC scouting

License: GNU General Public License v3.0

Go 97.78% Dockerfile 0.19% PLpgSQL 2.03%
go frc robotics postgresql frc-scouting docker json-api rest-api

peregrine-backend's People

Contributors

brendanburkhart avatar calebeby avatar dependabot-preview[bot] avatar fharding1 avatar ilmanzo avatar j10k11 avatar nathanjesudason avatar sahilsharma011 avatar simonporter007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

peregrine-backend's Issues

Add ETag and If-None-Match to tba package

The TBA API supports the ETag and If-None-Match HTTP headers. The TBA package should keep a map of URLs to ETags, send them in an If-None-Match HTTP header in any TBA request, set the ETag sent back, and handle a 304 Not Modified properly. You can take a look at the old code to sorta get an idea of what this would look like. The old code used If-Modified-Since which is a bit different but a similar idea.

@NathanJesudason @j10k11 do either of you want to attempt this now that you have peregrine setup locally? If it would be helpful, I can write the tests for this feature, so you can tell when you've got it working properly, or I can just pair program with one of you at robotics.

Remove leading eventKey from matchKey

For an event like 2018abca, all the match keys will start with 2018abca_ (e.g. 2018abca_qm2, 2018abca_qm6). The match keys should simply be the later part (qm2, qm6).

Firehose and caching for event and match TBA data

Right now almost every request involving matches requires a roundtrip request to TBA, there should be a time period (several hours probably) where the server will just respond with the data it already has, and during that period the data is updated via the TBA firehose.

Wrap store errors better

There are lots of very complex store functions that do not provide context to the errors they return. They should do that :)

Middleware for eventKey, matchKey, etc, etc.

So either:

  • We have a middleware that looks in mux.Vars for eventKey, matchKey, bla, bla, bla to update events, matches, bla, bla, bla.
  • We have a middleware where we specify dependencies on each route like ihttp.Update(fooHandler, ihttp.Deps{Events: true, Matches: false, Teams: true}) to update events, matches, bla, bla, bla.

Respond with empty arrays, not nil arrays

Example:

{
  "data": [
    {
      "id": 1,
      "username": "franklin",
      "firstName": "Franklin",
      "lastName": "Harding",
      "roles": {
        "isAdmin": true,
        "isVerified": true
      },
      "stars": null
    }
  ]
}

Separate test files

There are a lot of tests in api.test.js now, it might make sense to separate them, e.g.: events.test.js, matches.test.js, etc, etc.

Add context to ErrNoResults returns

We should be providing context when we return ErrNoResults (that's the whole point of it being a type rather than just an error value), like this:

return ErrNoResults(fmt.Errorf("event key %s does not exist", eventKey))

But we aren't doing that everywhere:

Add Windows steps to README.md

We should add steps on how to install PostgreSQL on Windows, manage it with pg_ctl, and use psql to create the peregrine database since most of the new Peregrine developers will be using (bleh) Windows. Also some specific steps on how to use install/use dep would be nice since you just download a single binary rather than install it.

  • Download/use dep to install dependencies
  • Install PostgreSQL on Windows
  • Manage PostgresSQL start/stop/restart with pg_ctl
  • Create the peregrine database with psql

Refactor New to Init

We have a stupid amount of arguments in New. We should probably refactor it so the user can construct the Server struct themselves and then call server.Init() or something.

Refresh tokens

We should add refresh tokens. This doesn't need to happen until after we get everything else done.

Add ability to delete/update manual events/matches

If events/matches are created, they can't currently be changed. Admins should be able to update or delete events on their realm. Additionally it should not be possible to create a manual event that replaces a TBA event, they need to have different names.

Fix issue with sql connection pool

It would seem we're leaking SQL connections. This is high priority and should be fixed soon.

Oct 24 00:44:52 centos-s-1vcpu-1gb-nyc1-01 peregrine[8771]: {"error":"pq: remaining connection slots are reserved for non-replication superuser connections","level":"error","msg":"retrieving event data","time":"2018-10-24T00:44:52Z"}
Oct 24 00:53:31 centos-s-1vcpu-1gb-nyc1-01 peregrine[8771]: {"admin":false,"body_size":22,"level":"info","method":"GET","msg":"got request","remote_addr":"REDACTED:42086","request_time":0.005135046,"start_time":1540342411,"status_code":500,"time":"2018-10-24T00:53:31Z","url":"/events","u
Oct 24 00:53:31 centos-s-1vcpu-1gb-nyc1-01 peregrine[8771]: {"error":"pq: remaining connection slots are reserved for non-replication superuser connections","level":"error","msg":"retrieving event data","time":"2018-10-24T00:53:31Z"}
Oct 24 00:54:15 centos-s-1vcpu-1gb-nyc1-01 peregrine[8771]: {"admin":false,"body_size":22,"level":"info","method":"GET","msg":"got request","remote_addr":"REDACTED:42450","request_time":0.004834191,"start_time":1540342455,"status_code":500,"time":"2018-10-24T00:54:15Z","url":"/events","u
Oct 24 00:54:15 centos-s-1vcpu-1gb-nyc1-01 peregrine[8771]: {"error":"pq: remaining connection slots are reserved for non-replication superuser connections","level":"error","msg":"retrieving event data","time":"2018-10-24T00:54:15Z"}
Oct 24 00:54:16 centos-s-1vcpu-1gb-nyc1-01 peregrine[8771]: {"admin":false,"body_size":19,"level":"info","method":"GET","msg":"got request","remote_addr":"REDACTED:42450","request_time":0.000034252,"start_time":1540342456,"status_code":404,"time":"2018-10-24T00:54:16Z","url":"/favicon.ic

https://www.reddit.com/r/golang/comments/4j5ysh/reliably_detect_databasesql_connection_leaks/

Use SQL JOINs for getting stars

Currently, we use a separate statement for getting user stars, but we could just use a JOIN, similar to what was just done for matches in this PR, and it would be both faster and more readable.

Removed deleted matches

If they aren't going to happen, tie-breaker matches are deleted from TBA. Deleted matches need to be removed from the database, but custom matches need to be left alone.

Move linting to CircleCI step

The GolangCI bot is pretty unreliable so we should stop using it and instead use circleci to run the golangci-lint cli tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.