luffykai / LM-PH2020

social housing map
0 stars 0 forks source link

Social housing map

How to Use

1. Covert to OCDS

node index.js convert_to_ocds --org 3.80.11 --c 1090212-B2

You should be able to see results like the following

{
  date: '1595376000000',
  id: 'TIQ-1-52845290',
  ocid: 'ocds-kj3ygj-TIQ-1-52845290',
  tag: 'tender',
  language: 'zh',
  initiationType: 'tender',
  buyer: { id: '3.80.11', name: '桃園市政府工務局' },
  parties: {
    additionalIdentifiers: { legalName: '桃園市政府住宅發展處住宅開發科' },
    address: {
      locality: '桃園市',
      region: '桃園區',
      postalCode: '330',
      countryName: '臺灣',
      streetAddress: '330桃園市桃園區力行路300號'
    },
    contactPoint: {
      name: '梁如中先生',
      telephone: '(03)3324700分機2216',
      faxNumber: '(03)3335772',
      email: '10021540@mail.tycg.gov.tw'
    }
  },
  tender: {
    id: '1090212-B2',
    title: '桃園市社會住宅(略)家具租賃服務案(詳附加說明)',
    mainProcurementCategory: 'goods',
    minValue: { currency: 'TWD', amount: '274,736,297元' },
    procurementMethod: 'open',
    awardCriteria: '最有利標',
    tenderPeriod: { startDate: '109/07/22', endDate: '109/07/30 09:00' },
    submissionMethod: 'written',
    submissionMethodDetails: '親送或寄達桃園市政府7樓工務局採購管理科收',
    eligibilityCriteria: '(一)廠商基本資格:\n' +
      '1.投標廠商應符合下列其中1項基本資格:\n' +
      '(1)家具及裝設品製造業(CN01010)\n' +
      '(2)家具、寢具、廚房器具、裝設品批發業(F105050) 。\n' +
      '2.本工程允許單獨投標或共同投標:\n' +
      '(1)單獨投標:符合本點所列其中1項廠商基本資格者得單獨投標。\n' +
      '(2)共同投標:代表廠商廠商須符合本點所列其中1項基本資格,得採共同投標。\n' +
      '(二)應檢附之文件:\n' +
      '因採購網字數限制,詳公告附加說明或投標須知'
  }
}

Some Great Examples

TODO: We should just turn these into tests

node index.js convert_to_ocds --org_id="3.95.29.3" --contract_id="P1080312"
node index.js convert_to_ocds --org_id="3.79" --contract_id="1070807C0140"
node index.js convert_to_ocds --org_id="3.79.56" --contract_id="1070717C0129-01"

2. Search for titles, filtered by unit IDs, and build a OC4IDS package.

# Example:
node index.js search_with_unit --pid '舊宗公共住宅案' --t '舊宗' --uid '3.79.56' '3.79'

# Example: use regex to filter projects
node index.js search_with_unit --pid '萬華區莒光住宅案' --t '萬華' --uid '3.79.56' '3.79' --r '莒光.*((公共)|(住宅))'

3. Covert to OC4IDS

node index.js convert_to_oc4ids --input data/example_oc4ids_input.json

This will write output output/example_oc4ids

4. Jest Test

Please make sure to install with npm first and run

npm run test

you'll see results like the following:

 PASS  tests/put.test.js
  ✓ put value into simple path (1 ms)
  ✓ put value into array
  ✓ put value into array with index
  ✓ put value into object in an array (1 ms)
  ✓ put value into object in an array, merging would work instead of creating new obj

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        1.181 s

5. Run Web App

One of the final result of this Hackathon project is a web app that demonstrates the ocds data of social housing projects.

1. Go to the app dir

cd app

2. Start the express.js server

DEBUG=app:* npm start

3. Visit LocalHost http://localhost:3000/ and check that you see LMAppRoot

While developing, we use babel to transform JSX React components to regular js files with the following command in the /app directory. This command will make sure that our React component files are compiled and that our js files are bundled into the corresponding html files.

npm run build

More information can be found here

6. Run projects on spreadsheet

A. Get a Firebase Admin SDK key

Visit this page

Name it lm-ph2020-firebase-adminsdk.json and store it in the directory with index.js.

B. Run command

node index.js search_list --input data/all_project_query_with_county.csv
node index.js search_list --update --input data/all_project_query_with_county.csv
node index.js search_single -p "興隆D2區社會住宅,3.79 3.79.56,興隆,D,taipei"
node index.js search_single --update -p "興隆D2區社會住宅,3.79 3.79.56,興隆,D,taipei"

Install

To add new dependency X: npm install --save X. And it will update package.json. Otherwise, just npm install to install all dependecies in package.json.

To deploy to GCP

1. Install gcloud CLI

Visit here and install Cloud SDK.

2. Login to get access to projects in GCP

gcloud auth login

3. Initialize and set the project to lm-ph2020

gcloud init

3. Deploy app

gcloud app deploy