Git Product home page Git Product logo

backend's Introduction

Backend

Setup Development Environment

  1. Install Docker Desktop
  2. Download Go 1.19
  3. Clone the repo
git clone [email protected]:taiwan-voting-guide/backend.git
cd backend
  1. Setup postgres
docker run \
-v `pwd`/init.sql:/docker-entrypoint-initdb.d/init.sql:ro \
--name pg \
-e POSTGRES_USER=backend_user \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=tvg \
-p 5432:5432 \
-d postgres
  1. Copy env file
cp .env.example .env
# copy google client id from slack #tech
  1. Start the server
go run main.go
  1. Init politicians testing
./scripts/init_politicians.sh
  1. (optional) Download pgAdmin

Staging APIs

Create a staging record

table: This refers to the target table to be processed.

searchBy: These are the fields used to search the target table. If the data already exists in the target table, a create record is created. If not, an update record is created.

fields: These are the individual fields used for the target table. If a field is a reference to another table, the reference's ID is searched for and replaced.

POST /workspace/staging

{
    "table": "parties",
    "searchBy": {
        "name": "**進步黨" 
    },
    "fields": {
        "name": "**進步黨",
        "chairman": "賴清德",
        "established_date": "2012-12-12",
        "filing_date": "2012-12-12",
        "main_office_address": "kkkkkkkk",
        "mailing_address": "aaaaaaaaaa",
        "phone_number": "091123321",
        "status": "三小"
    }
}
POST /workspace/staging

{
    "table": "politicians",
    "searchBy": {
        "name": "許淑華",
        "birthdate": "1975-05-22"
    },
    "fields": {
        "name": "許淑華",
        "birthdate": "1975-05-22",
        "sex": "female",
        "current_party_id": {
            "table": "parties",
            "searchBy": {
                "name": "中國國民黨"
            }
        }
    }
}

Troubleshoot

  1. Wired db connection/schema error: Try pulling the latest master and re-init pg.

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.