Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
B
bloclink
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 0
    • Merge Requests 0
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

and though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here

  • Confidential and Proprietary
  • BlocPower
  • bloclink
  • Merge Requests
  • !50

Closed
Opened Aug 13, 2019 by Tillie Kottmann@deletescapeOwner
  • Report abuse
Report abuse

Pptx generation CRUD

  • Overview 10
  • Commits 32
  • Changes 15

Created by: john525

Definitions used in this PR: submission - save questionnaire results to database calculation - calculate criteria/scores and/or cost estimates, save to database report file generation - generates PPTX file from calculated scores (does not download the file, or move it anywhere). report record generation - creates a database record which saves the (local filesystem) path of the pptx presentation, and records the time at which the pptx was generated

Report generation endpoints do NOT download the report file. They just return a json response that tells you where you can find the file

This PR adds a view ReportView which performs report file generation and report record generation. This view implements "create" and "read" methods (e.g. POST and GET), which respectively allow you to

  1. create a report (report file and record generation) for a building by sending a POST request with a building ID (only works if the building already has questionnaire answers, scores/criteria/oppurtunities, and cost estimates saved in the database). Returns a "report ID" from the report record generation
  2. send a GET request with building ID, and get a JSON response containing the path to the most recently generated pptx file (inside the bloclink container)

To test:

  1. Checkout this branch in bloclink repository (DO NOT SKIP THIS STEP!!!) and checkout the branch "bloclink_improvements" in development (ALSO DO NOT SKIP THIS STEP!!!)
  2. Make sure your postgres container is named "postgres" (or postgresql, or something similar. any name is fine as long as it is consistent)
  3. Go inside the container (docker exec -it postgres psql -U postgres) and create a user blocpower (make sure this user has a password, even if it is just "password" -- otherwise bloclink will not be able to connect), a database "bloclink", and a database "eng", both owned by blocpower user:
-- Create user
create user blocpower with password ‘blocpower12345’ superuser login;
-- Create DBs
create database bloclink with owner=blocpower;
create database eng with owner=blocpower;
  1. Make sure your bloclink .env file has a link to BLOCLINK_DB and ENGINEERING_DB that points to this postgres container (the hostname should be the container name from part 2, with username and password from part 3) 4b. Check your docker-compose.yml file in development. Bloclink dockerfile should be: "./microservices/bloclink/config/local/bloclink.Dockerfile" and it should also have a build arg "github_token: ${GITHUB_TOKEN}"

  2. Destroy and rebuild bloclink container (docker-compose rm -fs bloclink && docker-compose build bloclink && docker-compose up -d) to get latest bpengine (if that doesn't work, you can either try destroying and rebuilding with no cache, or you can pip install the latest bpengine version 0.7.1 from github and pip install django rest framework v3.10.2 inside the container to avoid the length rebuilding process)

  3. Bash inside the bloclink container, make and run the migrations for app "pna" (python manage.py makemigrations pna && python manage.py migrate pna --database engineering_db) Then run psql inside your postgres container. Run the scripts from the pna branch of oltp that contain insert operations (these are the ones that populate our "possible_answer" tables and other tables that are generally fixed, do not run the scripts that actually create tables because django orm already did this)

  4. Now with the psql shell, create dummy building data, e.g. insert fake questionnaire submissions for the HVAC questions and insert fake scores into the score table, for some specific building ID (e.g. 1234)

  5. Then run curl -XPOST http://0.0.0.0:5410/buildings/1234/pna/generatepna/ (on your host machine terminal) which should return a JSON response with a report ID

  6. Then open http://0.0.0.0:5410/buildings/1234/pna/generatepna/?report_id=XXX in your browser (replacing XXX with the ID you just got)

  7. Then find the file at that path in your bloclink container, use docker cp to copy it to your host machine filesystem, and make sure the pptx looks accurate/correctly formatted

What we need to add moving forward: submission, calculation need to upload generated report file from container to S3, and return that link instead of a local path, so the user can download it

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Reference: exconfidential/blocpower/bloclink!50
Source branch: pptx_generation