- Install Docker Desktop
- Download Go 1.19
- Clone the repo
git clone [email protected]:taiwan-voting-guide/backend.git
cd backend
- 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
- Copy env file
cp .env.example .env
# copy google client id from slack #tech
- Start the server
go run main.go
- Init politicians testing
./scripts/init_politicians.sh
- (optional) Download pgAdmin
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": "中國國民黨"
}
}
}
}
- Wired db connection/schema error: Try pulling the latest master and re-init pg.