This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function upload_table { | |
| t=$1 | |
| s=$2 | |
| start_date=$3 | |
| end_date=$4 | |
| while [ "$start_date" != "$end_date" ]; do | |
| upload_day "$t" "$s" "$start_date" | |
| start_date=$(date -d "$start_date+1 days" +%Y-%m-%d) | |
| done | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| function upload_day { | |
| table=$1 | |
| sel=$2 | |
| day=$3 | |
| next_day=$(date -d "$day+1 days" +%Y-%m-%d) | |
| bq_suffix=$(date -d "$day" +%Y%m%d) | |
| echo "Uploading $table: $day..." | |
| psql <yourdbname> -c "\\copy (select $sel from $table where created_at >= '$day' and created_at < '$next_day') TO '$table-$day.csv' WITH CSV HEADER" | |
| gzip $table-$day.csv | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $ sudo su - postgres | |
| $ psql yourdbname | |
| yourdbname=> create index transactions_created_at on transactions (created_at); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from flask import request, Response | |
| import requests | |
| def _proxy(*args, **kwargs): | |
| resp = requests.request( | |
| method=request.method, | |
| url=request.url.replace(request.host_url, 'new-domain.com'), | |
| headers={key: value for (key, value) in request.headers if key != 'Host'}, | |
| data=request.get_data(), | |
| cookies=request.cookies, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package gql | |
| import ( | |
| "fmt" | |
| "github.com/graphql-go/graphql" | |
| ) | |
| // ExecuteQuery runs our graphql queries | |
| func ExecuteQuery(query string, schema graphql.Schema) *graphql.Result { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package server | |
| import ( | |
| "encoding/json" | |
| "net/http" | |
| "github.com/masterxavierfox/go-graphql-api/gql" | |
| "github.com/go-chi/render" | |
| "github.com/graphql-go/graphql" | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package gql | |
| import "github.com/graphql-go/graphql" | |
| // User describes a graphql object containing a User | |
| var User = graphql.NewObject( | |
| graphql.ObjectConfig{ | |
| Name: "User", | |
| Fields: graphql.Fields{ | |
| "id": &graphql.Field{ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package gql | |
| import ( | |
| "github.com/masterxavierfox/go-graphql-api/postgres" | |
| "github.com/graphql-go/graphql" | |
| ) | |
| // Resolver struct holds a connection to our database | |
| type Resolver struct { | |
| db *postgres.Db | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package gql | |
| import ( | |
| "github.com/masterxavierfox/go-graphql-api/postgres" | |
| "github.com/graphql-go/graphql" | |
| ) | |
| // Root holds a pointer to a graphql object | |
| type Root struct { | |
| Query *graphql.Object | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package postgres | |
| import ( | |
| "database/sql" | |
| "fmt" | |
| // postgres driver | |
| _ "github.com/lib/pq" | |
| ) |