- Language: Ruby
- Framework: sinatra
- PSQL
ruby rtchallenge.rb
ENV['USER']='user'
user to login withENV['USER_PW']='password1'
password to login withENV['PT_TOKEN']='d133a1b130e414e794958136fd6e8a76'
ENV['PT_PROJECTS']='2088251, 2088250'
pivotal projectsENV['RELEASE_LABEL']=''
Name of current release tag by PM.
- user:
- pw:
- set those above-stated environment variables at the command line; you can check them via irb
- launch postgresql
CREATE DATABASE rtchallenge;
rake db:migrate
bundle init
if not done already
Ch-ch-changes:
- separate controllers/routes into home_, product_owner_, release_, and sprint_
- return JSON from API endpoints
- created additional controllers for functionality around product owners and releases
- known issues with ^above^: release endpoints not connecting to database properly, though a release table was added
- no more generating views in helpers
- extracted css into its own file, also added bootstrap
- use
layout.erb
in which all other views are populated so we can stay DRY - separated views into /home, /product_owners, and /sprint_releases subdirectories
- added headers for clarity of what a user is looking at in these tables
- created a navigable home page
- added functionality to create, edit, and delete product owners
- known issue with the ^above^: edit and delete routes not working properly, but an effort was made
- added unique constraint to
POID
field - added a
release
table and model with the intent to allow a user to set the current release so that therelease_label
environment variable, among other things, could be set - known issue with the ^above^: was not able to access the release table via the api. May have botched migration.
- separate into auth_, general_, label_, pivotal_, and sprint_
- condensed and simplified logic around getting stories/owners to populate the original table
- renamed functions/variables for clarity. ex:
owners
toproduct_owners
,update_users
topopulate_owners
,release_tix_html
toget_combined_stories_and_owners
- include '/projects/' in the pivotal_url variable, because it was appended every time anyway
-
moved virtually everything out of
rtchallenge.rb
and turned it into a module -
added spaces within functions for increased readability
-
created a
base_url
variable to replacerequest.host_with_port
-
added documentation, which you're reading
-
DOCUMENTATION of the original program:
-
The '/' endpoint directs to the
home.erb
template. (It first checks whether a user is authorized, which will be covered later in this doc.) -
That in turn calls the
generate_home
helper method, which simply callsrelease_tix_html
, which outputs an HTML list of stories - their url, name, owners, current state, and points. -
The
stories
data it uses comes from a call toget_release_tickets
. -
get_release_tickets
utilizes alabel
variable output fromget_release_label
-- which is populated by the label fromENV['RELEASE_LABEL']
and a project id fromENV['PT_PROJECTS']
. It iterates over the project ids in the labels, and uses each id and label name to populate a query to the Pivotal/projects/
endpoint. Thestory
data returned from each of those calls is inserted into astories
array which theget_release_tickets
method returns, as stated in the above step.
-
The home page has a link to the
/update_sprint
endpoint, which callsupdate_current_iteration
. -
update_current_iteration
first callsupdate_users
. -
update_users
iterates over the elements inENV['PT_PROJECTS']
, and uses theid
s therein to make calls to the Pivotal/projects
endpoint. Those calls returnownerDatum
, which createsOwner
records in the Postgres database, if they don't already exist. -
update_current_iteration
then populates aprojects
variables withENV['PT_PROJECTS']
, which is iterated over, and used to populate aurl
variable with a call to the Pivotal/projects/
endpoint, which retrieves astories
variable. -
That
stories
variable is iterated over, and a call toadd_label(project, story, ENV['RELEASE_LABEL'])
is made, which makes a post request to add a lavel the Pivotal/projects/
endpoint, iflabel_present?
returns false.
- Both of the endpoints first utilize the
protected!
function, which callsauthorized?
, which checks credentials based on the[ENV['USER']
andENV['USER_PW']
environment variables.