Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dbc148b
updated travis ci badges & iter0 doc
junyu-w Oct 8, 2016
79445f8
updated code climate badge & iter0 doc
junyu-w Oct 8, 2016
089e1eb
added pivotal tracker project url
junyu-w Oct 8, 2016
703b0be
iter 1: cucumber
Shuotong Oct 14, 2016
cc649b2
Merge remote-tracking branch 'upstream/develop' into develop
junyu-w Oct 15, 2016
ac82d6f
added status of both main repo and forked repo to readme
junyu-w Oct 15, 2016
982f2a3
Merge branch 'cucumber' into develop
junyu-w Oct 15, 2016
a3ada8b
added heroku staging url
junyu-w Oct 15, 2016
b3e3256
revise cukes
Shuotong Oct 21, 2016
d406b7c
update _form to use gem's credentials method
Shuotong Oct 21, 2016
4a32792
remove irrelevant features
Shuotong Oct 21, 2016
d348357
change credentials strings to symbols
Shuotong Oct 25, 2016
5700756
change unless to if not
Shuotong Oct 25, 2016
fcb1f53
change if not back to unless
Shuotong Oct 25, 2016
13b2654
move logic from view to controller
Shuotong Oct 26, 2016
739fd3a
change intern to to_sym
Shuotong Oct 26, 2016
b8ca10c
merges to develop
tansaku Nov 2, 2016
d8a4ffc
updated gems
junyu-w Nov 2, 2016
306eef6
change hash to ruby style and remove redundant lines
Shuotong Nov 20, 2016
a0c599c
move logic from view to controller: check repondency to credentials m…
Shuotong Nov 20, 2016
8d99a3c
Merge branch 'config' of github.com:DrakeW/projectscope into config
Shuotong Nov 20, 2016
fc6b85b
change styling according to codeclimate report
Shuotong Nov 20, 2016
a6c1797
add klass method in config model and change logic accordingly
Shuotong Dec 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Main Repo Status:

<a href="https://codeclimate.com/github/AgileVentures/projectscope_mvp"><img src="https://codeclimate.com/github/AgileVentures/projectscope_mvp/badges/gpa.svg" /></a>
<a href="https://travis-ci.org/AgileVentures/projectscope_mvp"><img src="https://travis-ci.org/AgileVentures/projectscope_mvp.svg?branch=master"></a>

CS169 Group Forked Repo Status:

<a href="https://codeclimate.com/github/DrakeW/projectscope"><img src="https://codeclimate.com/github/DrakeW/projectscope/badges/gpa.svg" /></a>
<a href="https://travis-ci.org/DrakeW/projectscope"><img src="https://travis-ci.org/DrakeW/projectscope.svg?branch=develop"></a>

# MVP dashboard for ProjectScope

A dashboard to show project metrics such as those supported by gems like
Expand Down
29 changes: 27 additions & 2 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
class ProjectsController < ApplicationController
include ProjectsHelper
before_action :set_project, only: [:show, :edit, :update, :destroy]

before_action :set_project_metrics, only: [:show, :edit, :new]
before_action :init_existed_configs, only: [:show, :edit, :new]
http_basic_authenticate_with name: "cs169", password: ENV['PROJECTSCOPE_PASSWORD']

# GET /projects
# GET /projects.json

def index
@projects = Project.all
@metric_names = ProjectMetrics.metric_names
Expand All @@ -24,6 +26,15 @@ def new

# GET /projects/1/edit
def edit
setup_metric_configs(@project)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice if I remove this all the tests still pass, and everything still works - surplus to requirement perhaps

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. I've done some tests as well. And I think this line is redundant. This function is already called when rendering _form.html. And also we no longer need to include ProjectsHelper then.

@project.configs.each do |config|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I can remove all this code as well and everything still works ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop here checks whether certain credentials has already been given value. In _form.html, it first displays all the existed credentials and adds fields for credentials that haven't been configured. The cucumber test would pass, and everything still works if we remove this part. But on the edit page, for example, if we already have an url for codeclimate, it still provides an empty field to config url. I hope that makes sense. I should probably modify the cucumber for edit page to test this scenario.

name = config.metric_name
if @project_metrics[name].respond_to?(:credentials)
config.options.each_pair do |key,val|
@existed_configs[name] << key.intern

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think key.to_sym is more straightforward than key.intern, but they do the same thing anyways

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will change to key.to_sym.

end
end
end
end

# POST /projects
Expand Down Expand Up @@ -73,6 +84,20 @@ def set_project
@project = Project.includes(:configs).find(params[:id])
end

def set_project_metrics
@project_metrics = {}
ProjectMetrics.metric_names.each do |name|
@project_metrics[name] = ProjectMetrics.class_for name
end
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly more rubyish version:

  def set_project_metrics
    @project_metrics = ProjectMetrics.metric_names.inject({}) do |hash, name|
      hash[name] = ProjectMetrics.class_for name; hash
    end
  end

see http://stackoverflow.com/a/9434319/316729 for more alternatives

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Thanks for your suggestion. I've modified my code accordingly.

def init_existed_configs
@existed_configs = {}
ProjectMetrics.metric_names.each do |name|
@existed_configs[name] = []
end
end

# Never trust parameters from the scary internet, only allow the white list through.
def project_params
# Grab new option keys/vals from params, and incorporate them into
Expand Down
25 changes: 17 additions & 8 deletions app/views/projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,24 @@
= text_field_tag field_name, val, :disabled => @readonly
%br
- unless @readonly
= link_to 'Add new', '', :class => 'add'
.field.new
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
\ :
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
%br
- if @project_metrics[name].respond_to?(:credentials)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like you were moving this logic into the controller, but then it wasn't removed from here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I will pass a hash mapping from the project metrics name to whether it responds to credentials method.

- @project_metrics[name].credentials.each do |cred|
-unless @existed_configs[name].include?(cred)
.field.new
= label_tag "project[configs_attributes][#{index}][new][]", "#{cred}", :id => nil, :class => 'newf'
\ :
= hidden_field_tag "project[configs_attributes][#{index}][new][]", "#{cred}", :id => nil, :class => 'newf'
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => "#{name}_#{cred}", :class => 'newf'
- else
= link_to 'Add new', '', :class => 'add'
.field.new
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
\ :
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
%br

:javascript
$('.add').click(function() { $(this).closest('fieldset').append($('.new')[0].outerHTML); return(false); } )
:javascript
$('.add').click(function() { $(this).closest('fieldset').append($('.new')[0].outerHTML); return(false); } )

- unless @readonly
.actions
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
t.text "encrypted_raw_data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "encrypted_raw_data_iv"
t.float "score"
t.text "image"
t.string "encrypted_raw_data_iv"
end

add_index "metric_samples", ["project_id", "metric_name"], name: "index_metric_samples_on_project_id_and_metric_name"
Expand Down
37 changes: 31 additions & 6 deletions features/add_project_with_config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,39 @@ Feature: add project and its config/credentials info
When I follow "New Project"
And I fill in "Name" with "Test Project"
And I enter new "Code Climate" config values:
| key | value |
| token | 12345 |
| login | fox |
| key | value |
| url | a.com |
| channel | 12345 |
| token | 555 |
And I enter new "Github" config values:
| key | value |
| url | b.com |
And I enter new "Slack" config values:
| key | value |
| channel | 1 |
| token | 5 |
And I enter new "Pivotal Tracker" config values:
| key | value |
| project | la |
| token | 444 |
And I enter new "Slack Trends" config values:
| key | value |
| channel | 1 |
| token | 5 |
And I press "Create Project"
Then there should be a project "Test Project" with config values:
| metric_name | key | value |
| code_climate | token | 12345 |
| code_climate | login | fox |
| metric_name | key | value |
| code_climate | url | a.com |
| code_climate | channel | 12345 |
| code_climate | token | 555 |
| github | url | b.com |
| slack | channel | 1 |
| slack | token | 5 |
| slack_trends | channel | 1 |
| slack_trends | token | 5 |
| pivotal_tracker | project | la |
| pivotal_tracker | token | 444 |




12 changes: 2 additions & 10 deletions features/step_definitions/project_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@

When /^I enter new "(.*)" config values/ do |metric, table|
fieldset_id = metric.downcase.gsub(' ', '_') # "Code Climate" => "code_climate"
(table.hashes.length - 1).times do
within "##{fieldset_id}" do
click_link 'Add new'
end
end
idx = 0
all_inputs = page.all("fieldset##{fieldset_id} .newf")
table.hashes.each do |h|
all_inputs[idx].set h['key']
all_inputs[idx+1].set h['value']
idx += 2
credential = h['key']
fill_in("#{fieldset_id}_#{credential}", :with => h['value'])
end
end

Expand Down
26 changes: 26 additions & 0 deletions iterations/iter0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Iteration 0

Entry video
---
URL: https://youtu.be/0qMtzclG9Is

Development Environment Setup Screencast
---
Junyu Wang: https://youtu.be/pPfSiQsZm5I

Jiacheng Wu: https://youtu.be/x8AOtKAzmaQ

Shuotong Wu: http://youtu.be/-65Oz8VtzDw?hd=1

Yibing Chen: https://youtu.be/U1Z-9KzoL7c

Jiawei Jiang: https://youtu.be/ClqYbe2Ipnc

Pivotal Tracker Project
---
URL: https://www.pivotaltracker.com/n/projects/1886749

Heroku
---
URL: https://projectscope-cs169-junyu.herokuapp.com/