author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
332,109
22.12.2016 16:08:47
-19,080
b03c70f113a5f2594a04b2a10df6604a88f9f377
Added redirection option to fetch repo, commit and organization info.
[ { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -18,7 +18,7 @@ gem 'jquery-rails'\ngem 'turbolinks', '~>2.5'\ngem 'jbuilder', '~> 2.0'\ngem 'sdoc', '~> 0.4.0', group: :doc\n-gem 'github_api', '~> 0.13'\n+gem 'github_api', git: 'https://github.com/prasadsurase/github.git', branch: 'add-redirection-support'\ngem 'devise', '~> 3.5'\ngem 'highcharts-rails', '~> 4.2', '>= 4.2.5'\ngem 'bootstrap-datepicker-rails'\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -13,6 +13,19 @@ GIT\nspecs:\nrugged (0.25.0b8)\n+GIT\n+ remote: https://github.com/prasadsurase/github.git\n+ revision: a019aff34aa31a662c5e21439d8f81593dcba352\n+ branch: add-redirection-support\n+ specs:\n+ github_api (0.14.5)\n+ addressable (~> 2.4.0)\n+ descendants_tracker (~> 0.0.4)\n+ faraday (~> 0.8, < 0.10)\n+ faraday_middleware (= 0.10.0)\n+ hashie (>= 3.4)\n+ oauth2 (~> 1.0)\n+\nGIT\nremote: https://github.com/prasadsurase/ruby-git.git\nrevision: 1f26c1c4cc50f183a54ce1e42efcc3762fbdaaa1\n@@ -130,14 +143,10 @@ GEM\ni18n (~> 0.5)\nfaraday (0.9.2)\nmultipart-post (>= 1.2, < 3)\n+ faraday_middleware (0.10.0)\n+ faraday (>= 0.7.4, < 0.10)\nfont-awesome-rails (4.6.3.1)\nrailties (>= 3.2, < 5.1)\n- github_api (0.14.5)\n- addressable (~> 2.4.0)\n- descendants_tracker (~> 0.0.4)\n- faraday (~> 0.8, < 0.10)\n- hashie (>= 3.4)\n- oauth2 (~> 1.0)\nglobalid (0.3.7)\nactivesupport (>= 4.1.0)\nhaml (4.0.7)\n@@ -435,7 +444,7 @@ DEPENDENCIES\nfaker (~> 1.6.1)\nfont-awesome-rails\ngit!\n- github_api (~> 0.13)\n+ github_api!\nhaml\nhaml-rails\nhighcharts-rails (~> 4.2, >= 4.2.5)\n" }, { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -41,7 +41,7 @@ class Commit\nend\ndef info\n- @info ||= repository ? user.gh_client.repos.commits.get(repository.owner, repository.name, sha) : nil\n+ @info ||= repository ? user.gh_client.repos.commits.get(repository.owner, repository.name, sha, { redirection: true }) : nil\nend\ndef max_rating\n" }, { "change_type": "MODIFY", "old_path": "app/models/organization.rb", "new_path": "app/models/organization.rb", "diff": "@@ -45,7 +45,7 @@ class Organization\nend\ndef info\n- @info ||= GITHUB.orgs.get(github_handle)\n+ @info ||= GITHUB.orgs.get(github_handle, {redirection: true})\nend\ndef self.setup(github_handle, admin)\n" }, { "change_type": "MODIFY", "old_path": "app/models/repository.rb", "new_path": "app/models/repository.rb", "diff": "@@ -56,7 +56,7 @@ class Repository\nend\ndef info\n- @info ||= GITHUB.repos.get(owner, name)\n+ @info ||= GITHUB.repos.get(owner, name, {redirection: true})\nend\ndef self.add_new(params, user)\n" }, { "change_type": "MODIFY", "old_path": "test/models/repository_test.rb", "new_path": "test/models/repository_test.rb", "diff": "@@ -44,4 +44,11 @@ class RepositoryTest < ActiveSupport::TestCase\nassert_not_equal Repository.count, Repository.required.count\nend\n+ test 'info should retrieve repository information' do\n+ repo = create :repository, name: 'mongoid-history', owner: 'aq1018', source_url: 'https://github.com/aq1018/mongoid-history'\n+ info = repo.info\n+ refute info.redirect?\n+ assert info.success?\n+ end\n+\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added redirection option to fetch repo, commit and organization info.
332,109
25.12.2016 18:18:51
-19,080
59c958a97f26463e9782a6989180ad32e569e07f
Added a small react component
[ { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -38,6 +38,7 @@ gem 'rollbar'\ngem 'mongoid-paranoia'\ngem 'mongoid-paperclip', require: 'mongoid_paperclip'\ngem 'stripe'\n+gem 'react-rails'\ngroup :development, :test do\ngem 'byebug'\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -75,6 +75,10 @@ GEM\narel (6.0.3)\nautoprefixer-rails (6.4.0.1)\nexecjs\n+ babel-source (5.8.35)\n+ babel-transpiler (0.7.0)\n+ babel-source (>= 4.0, < 6)\n+ execjs (~> 2.0)\nbcrypt (3.1.11)\nbinding_of_caller (0.7.2)\ndebug_inspector (>= 0.0.1)\n@@ -321,6 +325,13 @@ GEM\nrake (11.2.2)\nrdoc (4.2.2)\njson (~> 1.4)\n+ react-rails (1.10.0)\n+ babel-transpiler (>= 0.7.0)\n+ coffee-script-source (~> 1.8)\n+ connection_pool\n+ execjs\n+ railties (>= 3.2)\n+ tilt\nredcarpet (3.3.4)\nredis (3.3.1)\nredis-actionpack (5.0.0)\n@@ -470,6 +481,7 @@ DEPENDENCIES\npry-nav\nquiet_assets\nrails (= 4.2.5)\n+ react-rails\nredcarpet\nredis-rails\nrollbar\n" }, { "change_type": "MODIFY", "old_path": "app/assets/javascripts/application.js", "new_path": "app/assets/javascripts/application.js", "diff": "//= require bootstrap-typeahead\n//= require bootstrap2-toggle\n//= require jquery.shorten\n+//= require react\n+//= require react_ujs\n+//= require components\n//= require_tree .\nfunction onDocReady(){\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components.js", "diff": "+//= require_tree ./components\n" }, { "change_type": "ADD", "old_path": "app/assets/javascripts/components/.gitkeep", "new_path": "app/assets/javascripts/components/.gitkeep", "diff": "" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%section.content-header\n%h1 User Profile\n-= render 'celebrity_box' if current_user && current_user.celebrity\n+= react_component 'CelebrityBox', { type: 'info', title: '', message: t('user.celebrity_signup') } if current_user && current_user.celebrity\n%section.content\n.row\n.col-sm-4\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added a small react component
332,109
26.12.2016 15:05:32
-19,080
7c652f83f537032eedbad83075e5865fcdd8fc9b
Added reactjs component for Points tile on dashboard page.
[ { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components/points_tile.js.jsx", "diff": "+var PointsTile = React.createClass({\n+\n+ render: function() {\n+ return (\n+ <div className={`small-box ${this.props.color}`}>\n+ <div className=\"inner\">\n+ <h3>{ this.props.points }</h3>\n+ <p>{ this.props.title }</p>\n+ </div>\n+ <div className=\"icon\">\n+ <i className={`ion ${this.props.logo}`}></i>\n+ </div>\n+ <a className=\"small-box-footer\" href={ this.props.path }>More info\n+ <i className=\"fa fa-arrow-circle-right\"></i>\n+ </a>\n+ </div>\n+ );\n+ }\n+});\n" }, { "change_type": "MODIFY", "old_path": "app/views/dashboard/index.html.haml", "new_path": "app/views/dashboard/index.html.haml", "diff": "= render 'celebrity_box' if current_user && current_user.celebrity\n%section.content\n.row\n- .col-lg-3.col-xs-4\n- .small-box.bg-aqua\n- .inner\n- %h3= format_points(current_user.total_points)\n- %p Points\n- .icon\n- %i.ion.ion-pie-graph\n- = link_to user_path(current_user), class: 'small-box-footer' do\n- More info\n- %i.fa.fa-arrow-circle-right\n- .col-lg-3.col-xs-4\n- .small-box.bg-green\n- .inner\n- %h3= current_user.commits_count\n- %p Commits\n- .icon\n- %i.ion.ion-stats-bars\n- = link_to activities_path(anchor: 'commits'), class: 'small-box-footer' do\n- More info\n- %i.fa.fa-arrow-circle-right\n- .col-lg-3.col-xs-4\n- .small-box.bg-yellow\n- .inner\n- %h3= current_user.activities_count\n- %p Activities\n- .icon\n- %i.ion.ion-chatboxes\n- = link_to activities_path(anchor: 'activities'), class: 'small-box-footer' do\n- More info\n- %i.fa.fa-arrow-circle-right\n+ .col-lg-3.col-xs-6\n+ = react_component 'PointsTile', { color: 'bg-aqua', title: 'Points', points: format_points(current_user.total_points),\n+ logo: 'ion-pie-graph', path: user_path(current_user) }\n+ .col-lg-3.col-xs-6\n+ = react_component 'PointsTile', { color: 'bg-green', title: 'Commits', points: current_user.commits_count,\n+ logo: 'ion-stats-bars', path: activities_path(anchor: 'commits')}\n+ .col-lg-3.col-xs-6\n+ = react_component 'PointsTile', { color: 'bg-yellow', title: 'Activities', points: current_user.activities_count,\n+ logo: 'ion-chatboxes', path: activities_path(anchor: 'activities') }\n.row\n.box-body\n#users-chart-container\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added reactjs component for Points tile on dashboard page.
332,109
27.12.2016 11:15:58
-19,080
741eb351e23a2e9a45c86a8c868c241713d4b240
Moved React Components to ES6
[ { "change_type": "MODIFY", "old_path": "app/assets/javascripts/components/celebrity_box.js.jsx", "new_path": "app/assets/javascripts/components/celebrity_box.js.jsx", "diff": "-var CelebrityBox = React.createClass({\n- render: function() {\n+class CelebrityBox extends React.Component {\n+ constructor(props){\n+ super(props);\n+ }\n+\n+ render() {\nreturn (\n<section>\n<div className=\"callout-info col-xs-12\">\n@@ -12,4 +16,4 @@ var CelebrityBox = React.createClass({\n</section>\n);\n}\n-});\n+}\n" }, { "change_type": "MODIFY", "old_path": "app/assets/javascripts/components/points_tile.js.jsx", "new_path": "app/assets/javascripts/components/points_tile.js.jsx", "diff": "-var PointsTile = React.createClass({\n+class PointsTile extends React.Component {\n+ constructor(props){\n+ super(props);\n+ }\n- render: function() {\n+ render(){\nreturn (\n<div className={`small-box ${this.props.color}`}>\n<div className=\"inner\">\n@@ -16,4 +19,4 @@ var PointsTile = React.createClass({\n</div>\n);\n}\n-});\n+}\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Moved React Components to ES6
332,109
27.12.2016 14:13:46
-19,080
5d46302495442d6b97cf2037d0b84fac4c584996
Added React for PointHistory on profile page.
[ { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -39,6 +39,8 @@ gem 'mongoid-paranoia'\ngem 'mongoid-paperclip', require: 'mongoid_paperclip'\ngem 'stripe'\ngem 'react-rails'\n+gem 'versionist'\n+gem 'active_model_serializers', '~> 0.10.0'\ngroup :development, :test do\ngem 'byebug'\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -55,6 +55,10 @@ GEM\nerubis (~> 2.7.0)\nrails-dom-testing (~> 1.0, >= 1.0.5)\nrails-html-sanitizer (~> 1.0, >= 1.0.2)\n+ active_model_serializers (0.10.3)\n+ actionpack (>= 4.1, < 6)\n+ activemodel (>= 4.1, < 6)\n+ jsonapi (= 0.1.1.beta2)\nactivejob (4.2.5)\nactivesupport (= 4.2.5)\nglobalid (>= 0.3.0)\n@@ -181,6 +185,8 @@ GEM\nrailties (>= 4.2.0)\nthor (>= 0.14, < 2.0)\njson (1.8.3)\n+ jsonapi (0.1.1.beta2)\n+ json (~> 1.8)\njwt (1.5.4)\nkaminari (0.17.0)\nactionpack (>= 3.0.0)\n@@ -418,6 +424,10 @@ GEM\nunf (0.1.4)\nunf_ext\nunf_ext (0.0.7.4)\n+ versionist (1.5.0)\n+ activesupport (>= 3)\n+ railties (>= 3)\n+ yard (~> 0.7)\nwarden (1.2.6)\nrack (>= 1.0)\nweb-console (2.3.0)\n@@ -436,11 +446,13 @@ GEM\nchronic (>= 0.6.3)\nxpath (2.0.0)\nnokogiri (~> 1.3)\n+ yard (0.9.5)\nPLATFORMS\nruby\nDEPENDENCIES\n+ active_model_serializers (~> 0.10.0)\nbootstrap-datepicker-rails\nbootstrap-sass (~> 3.3.6)\nbrakeman\n@@ -497,6 +509,7 @@ DEPENDENCIES\ntimecop\nturbolinks (~> 2.5)\nuglifier (>= 1.3.0)\n+ versionist\nweb-console (~> 2.0)\nwebmock\nwhenever\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components/points_history.js.jsx", "diff": "+class PointsHistory extends React.Component {\n+ constructor(props) {\n+ super(props);\n+ this.state = { transactions: [] };\n+ }\n+\n+ componentDidMount() {\n+ $.ajax({\n+ type: 'GET',\n+ url: '/transactions',\n+ dataType: 'JSON',\n+ success: (data) => { this.setState({ transactions: data }); },\n+ error: function(error){ alert('Error!'); },\n+ beforeSend: function(xhr){ xhr.setRequestHeader('Accept', 'application/vnd.codecuriosity.org; version=1'); }\n+ });\n+ }\n+\n+ total_points() {\n+ return this.state.transactions.reduce((function(prev, curr) {\n+ return prev + parseFloat(curr.points);\n+ }), 0);\n+ }\n+\n+ render() {\n+ return (\n+ <table className=\"table table-bordered\">\n+ <thead>\n+ <tr>\n+ <th className=\"col-xs-1\">#</th>\n+ <th className=\"col-xs-3\">Points</th>\n+ <th>Detail</th>\n+ <th>Date</th>\n+ </tr>\n+ </thead>\n+ <tbody>\n+ {\n+ this.state.transactions.map(function(transaction, index){\n+ return <PointsHistoryRow key={transaction.id} index={index + 1} points={transaction.points}\n+ details={transaction.transaction_type} label={transaction.type} date={transaction.created_at} coupon_code={transaction.coupon_code}\n+ redeem_request_retailer={transaction.redeem_request_retailer} />\n+ })\n+ }\n+ <tr>\n+ <td>\n+ <b>Total</b>\n+ </td>\n+ <td colSpan=\"4\">{ this.total_points() }</td>\n+ </tr>\n+ </tbody>\n+ </table>\n+ );\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components/points_history_row.js.jsx", "diff": "+class PointsHistoryRow extends React.Component {\n+ render() {\n+ return (\n+ <tr>\n+ <td>{ this.props.index }</td>\n+ <td>{ this.props.points }</td>\n+ <td className=\"transaction-detail\">\n+ <b>{ this.props.details }</b>\n+ <small className={`label ${this.props.label == 'credit' ? 'bg-green' : 'bg-red' }`}>{ this.props.label.toUpperCase() }</small>\n+ { this.props.coupon_code ? (<h5>Coupon Code:<i>{ this.props.coupon_code }</i></h5>) : (null) }\n+ { this.props.redeem_request_retailer ? (<small className='label bg-primary'> {this.props.redeem_request_retailer.toUpperCase()} </small>) : (null) }\n+ </td>\n+ <td>{ this.props.date }</td>\n+ </tr>\n+ );\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/controllers/v1/base_controller.rb", "diff": "+class V1::BaseController < ApplicationController\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/controllers/v1/transactions_controller.rb", "diff": "+class V1::TransactionsController < V1::BaseController\n+ before_action :authenticate_user!\n+\n+ def index\n+ @records_per_page = Kaminari.config.default_per_page\n+ render json: Transaction.where(user_id: current_user.id).desc(:created_at).page(params[:page]).per(@records_per_page)\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/presenters/v1/base_presenter.rb", "diff": "+class V1::BasePresenter\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/serializers/transaction_serializer.rb", "diff": "+class TransactionSerializer < ActiveModel::Serializer\n+ attributes :id, :points, :type, :transaction_type, :description, :created_at, :coupon_code, :redeem_request_retailer\n+\n+ def transaction_type\n+ object.transaction_type.humanize\n+ end\n+\n+ def created_at\n+ object.created_at.strftime('%d/%b/%Y %T')\n+ end\n+\n+ def redeem_request_retailer\n+ object.redeem_request.retailer if object.redeem_request?\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/_transactions.html.haml", "new_path": "app/views/users/_transactions.html.haml", "diff": "-%table.table.table-bordered\n- %thead\n- %tr\n- %th.col-xs-1 #\n- %th.col-xs-3 Points\n- %th Detail\n- %th Date\n- %tbody\n- = render partial: 'transaction', collection: @user.transactions.desc(:created_at)\n- %tr\n- %td\n- %b Total\n- %td{ colspan: 4 }= @user.total_points\n+= react_component 'PointsHistory'\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "Rails.application.routes.draw do\n+ api_version('module': 'V1', header: {name: 'Accept', value: 'application/vnd.codecuriosity.org; version=1'}) do\n+ resources :transactions, only: [:index]\n+ end\n+\ndevise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' },\nskip: [:sessions, :registrations, :passwords]\n" }, { "change_type": "ADD", "old_path": null, "new_path": "public/docs/v1/index.html", "diff": "+<!DOCTYPE html>\n+<html lang=\"en-US\">\n+ <head>\n+ <title>Documentation for v1</title>\n+ <link href=\"v1/style.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\">\n+ </head>\n+ <body>\n+ <div id=\"container\">\n+ <div id=\"operations\">\n+ <h3>API Operations</h3>\n+ </div>\n+ <div id=\"content\">\n+ <h1>Documentation for v1</h1>\n+ </div>\n+ </div>\n+ </body>\n+</html>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "public/docs/v1/style.css", "diff": "+body {margin: 0; background-color: #fff; color: #000; font-family: Arial,sans-serif;}\n+content {margin-left: 200px;}\n+content h1 {text-align: center;}\n+operations {float: left; width: 200px; border-right: 1px solid #ccc;}\n+operations h3 {text-align: center;}\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added React for PointHistory on profile page.
332,109
27.12.2016 15:59:02
-19,080
4ecc99a042ccad22b51c75a13be74a1ba44b31fd
Added test for TransactionSerializer
[ { "change_type": "ADD", "old_path": null, "new_path": "test/serializers/transaction_serializer_test.rb", "diff": "+require \"test_helper\"\n+\n+class TransactionSerializerTest < ActiveSupport::TestCase\n+ def setup\n+ super\n+ @redeem_request = create(:redeem_request, points: 50, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\n+ coupon_code: 'aitpune')\n+ @transaction = create(:transaction, transaction_type: 'redeem_points', type: :debit, redeem_request: @redeem_request, points: -50)\n+ end\n+\n+ test 'serialize the transaction' do\n+ serializer = TransactionSerializer.new(@transaction)\n+ data = serializer.serializable_hash\n+\n+ assert_equal @transaction.id, data[:id]\n+ assert_equal -50, data[:points]\n+ assert_equal 'debit', data[:type]\n+ assert_equal 'Redeem points', data[:transaction_type]\n+ assert_equal 'aitpune', data[:coupon_code]\n+ assert_equal 'other', data[:redeem_request_retailer]\n+ assert_equal @transaction.created_at.strftime('%d/%b/%Y %T'), data[:created_at]\n+ end\n+\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added test for TransactionSerializer
332,109
27.12.2016 16:15:43
-19,080
48fa67468fee36ca01e10186208bcf12718bc1a3
Updated the PhantomJS version for TravisCI
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -17,7 +17,19 @@ services:\n- mongodb\n- redis-server\n-cache: bundler\n+cache:\n+ bundler: true\n+ directories:\n+ - \"travis_phantomjs\"\n+\n+before_install:\n+ - \"phantomjs --version\"\n+ - \"export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH\"\n+ - \"phantomjs --version\"\n+ - \"if [ $(phantomjs --version) != '2.1.1' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi\"\n+ - \"if [ $(phantomjs --version) != '2.1.1' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi\"\n+ - \"if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi\"\n+ - \"phantomjs --version\"\nsudo: false\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Updated the PhantomJS version for TravisCI
332,109
28.12.2016 11:29:58
-19,080
32e59547b582bdae334cfc6dbfd11f639698aa16
Added test for transactions controller api
[ { "change_type": "ADD", "old_path": null, "new_path": "test/controllers/v1/transactions_controller_test.rb", "diff": "+require \"test_helper\"\n+\n+class V1::TransactionsControllerTest < ActionController::TestCase\n+ include Devise::TestHelpers\n+\n+ def setup\n+ super\n+ @request.env['Accept'] = 'application/vnd.codecuriosity.org; version=1'\n+ @goal = create :goal\n+ @user = create :user, auth_token: 'dah123rty', goal: @goal\n+ @round = create :round, :open\n+ @redeem_request = create(:redeem_request, points: 50, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\n+ coupon_code: 'aitpune', user: @user)\n+ @transaction = @redeem_request.transaction\n+ @transactions = FactoryGirl.create_list(:transaction, 3, type: 'credit', transaction_type: 'Round', points: 1, user: @user)\n+ assert_equal 4, @user.transactions.count\n+ end\n+\n+ test 'response is 401 for unauthenticated user' do\n+ get :index, format: :json\n+ assert_response 401\n+ end\n+\n+ test 'response is success for authenticated user' do\n+ sign_in @user\n+ get :index, format: :json\n+ assert_response :success\n+ end\n+\n+ test \"current user's transactions are retrieved\" do\n+ sign_in @user\n+ get :index, format: :json\n+ assert_not_empty response.body\n+ data = JSON.parse(response.body)\n+ assert_equal 4, data.size\n+ end\n+\n+ test 'doesnt retrieve transactions of other users' do\n+ user = create :user, auth_token: 'dah123', goal: @goal\n+ transactions = FactoryGirl.create_list(:transaction, 3, type: 'credit', transaction_type: 'Round', points: 1, user: user)\n+ sign_in @user\n+ assert_equal 4, @user.transactions.count\n+ assert_equal 3, user.transactions.count\n+ assert_equal 7, Transaction.count\n+ get :index, format: :json\n+ assert_not_empty response.body\n+ data = JSON.parse(response.body)\n+ assert_equal 4, data.size\n+ user.transactions.pluck(:id).each do |id|\n+ refute_includes data.collect{|i| i['id']}, id.to_s\n+ end\n+ end\n+\n+end\n" }, { "change_type": "MODIFY", "old_path": "test/serializers/transaction_serializer_test.rb", "new_path": "test/serializers/transaction_serializer_test.rb", "diff": "@@ -5,7 +5,7 @@ class TransactionSerializerTest < ActiveSupport::TestCase\nsuper\n@redeem_request = create(:redeem_request, points: 50, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\ncoupon_code: 'aitpune')\n- @transaction = create(:transaction, transaction_type: 'redeem_points', type: :debit, redeem_request: @redeem_request, points: -50)\n+ @transaction = @redeem_request.transaction\nend\ntest 'serialize the transaction' do\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added test for transactions controller api
332,109
28.12.2016 11:34:43
-19,080
0c83fbdf35da158130f71c60e73b7333c617d5b3
Fixed bug: user's total points arent displayed correctly
[ { "change_type": "MODIFY", "old_path": "app/assets/javascripts/components/points_history.js.jsx", "new_path": "app/assets/javascripts/components/points_history.js.jsx", "diff": "@@ -15,12 +15,6 @@ class PointsHistory extends React.Component {\n});\n}\n- total_points() {\n- return this.state.transactions.reduce((function(prev, curr) {\n- return prev + parseFloat(curr.points);\n- }), 0);\n- }\n-\nrender() {\nreturn (\n<table className=\"table table-bordered\">\n@@ -44,7 +38,7 @@ class PointsHistory extends React.Component {\n<td>\n<b>Total</b>\n</td>\n- <td colSpan=\"4\">{ this.total_points() }</td>\n+ <td colSpan=\"4\">{ this.props.total_points }</td>\n</tr>\n</tbody>\n</table>\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/_transactions.html.haml", "new_path": "app/views/users/_transactions.html.haml", "diff": "-= react_component 'PointsHistory'\n+= react_component 'PointsHistory', total_points: @user.total_points\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fixed bug: user's total points arent displayed correctly
332,109
28.12.2016 14:18:26
-19,080
2a8500c0ccd4a1a200c302fadbe9c9b4315b714a
Displayed all the transaction of the current user in points history page.
[ { "change_type": "MODIFY", "old_path": "app/controllers/v1/transactions_controller.rb", "new_path": "app/controllers/v1/transactions_controller.rb", "diff": "@@ -2,7 +2,6 @@ class V1::TransactionsController < V1::BaseController\nbefore_action :authenticate_user!\ndef index\n- @records_per_page = Kaminari.config.default_per_page\n- render json: Transaction.where(user_id: current_user.id).desc(:created_at).page(params[:page]).per(@records_per_page)\n+ render json: current_user.transactions.desc(:created_at)\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Displayed all the transaction of the current user in points history page.
332,109
29.12.2016 14:03:25
-19,080
3d8e56439d42868473ac797d3101e3d5b910d50d
Added react CelebrityBox component on dashboard
[ { "change_type": "MODIFY", "old_path": "app/views/dashboard/index.html.haml", "new_path": "app/views/dashboard/index.html.haml", "diff": "%section.content-header\n%h1\nDashboard\n-= render 'celebrity_box' if current_user && current_user.celebrity\n+= react_component 'CelebrityBox', { type: 'info', title: '', message: t('user.celebrity_signup') } if current_user && current_user.celebrity\n%section.content\n.row\n.col-lg-3.col-xs-6\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added react CelebrityBox component on dashboard
332,109
29.12.2016 14:24:25
-19,080
698eaa44025d722e142de79fb979f7cec8938a9d
Added React Component to display user's points history chart
[ { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components/user_points_chart.es6.jsx", "diff": "+class UserPointsChart extends React.Component {\n+ constructor(props) {\n+ super(props);\n+ }\n+\n+ componentDidMount() {\n+ userTrendChart(this.props.xAxis, this.props.commits, this.props.activities, this.props.points, this.props.username);\n+ }\n+\n+ render () {\n+ return (\n+ <div className='box-body'>\n+ <div id='users-chart-container'>\n+ </div>\n+ </div>\n+ );\n+ }\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "app/views/dashboard/index.html.haml", "new_path": "app/views/dashboard/index.html.haml", "diff": "= react_component 'PointsTile', { color: 'bg-yellow', title: 'Activities', points: current_user.activities_count,\nlogo: 'ion-chatboxes', path: activities_path(anchor: 'activities') }\n.row\n- .box-body\n- #users-chart-container\n-\n-\n-:javascript\n- userTrendChart(#{@xAxis}, #{@commits}, #{@activities}, #{@points}, #{@username});\n+ = react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/_subscription.html.haml", "new_path": "app/views/users/_subscription.html.haml", "diff": "%td= format_points(subscription.points)\n/\n%td= subscription.goal ? link_to(subscription.goal.name, goals_path) : '-'\n-:javascript\n- userTrendChart(#{@xAxis}, #{@commits}, #{@activities}, #{@points}, #{@username});\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "- if @show_transactions\n= render partial: 'share_button'\n.row\n- .box-body\n- #users-chart-container\n+ = react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n%table.table.table-bordered\n%thead\n%tr\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added React Component to display user's points history chart
332,109
29.12.2016 16:12:11
-19,080
a6bbe6e3dbe91d7757ad3fbecc41aa97ad036fb9
Added React Component for Subscription History on user's profile page
[ { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components/subscriptions_history.es6.jsx", "diff": "+class SubscriptionsHistory extends React.Component {\n+ constructor(props) {\n+ super(props);\n+ this.state = { subscriptions: [] };\n+ }\n+\n+ componentDidMount() {\n+ $.ajax({\n+ type: 'GET',\n+ url: '/subscriptions',\n+ data: {id: this.props.user_id },\n+ dataType: 'JSON',\n+ success: (data) => { this.setState({ subscriptions: data }); },\n+ error: function(error){ alert('Error!'); },\n+ beforeSend: function(xhr){ xhr.setRequestHeader('Accept', 'application/vnd.codecuriosity.org; version=1'); }\n+ });\n+ }\n+\n+ render () {\n+ return (\n+ <table className=\"table table-bordered\">\n+ <thead>\n+ <tr>\n+ <th className=\"col-xs-1\">#</th>\n+ <th>Name</th>\n+ <th className=\"col-xs-2\">Commits</th>\n+ <th className=\"col-xs-2\">Activities</th>\n+ <th className=\"col-xs-2\">Points</th>\n+ </tr>\n+ </thead>\n+ <tbody>\n+ {\n+ this.state.subscriptions.map(function(subscription, index){\n+ return <SubscriptionsHistoryRow key={subscription.id} index={index + 1} roundDate={subscription.round_date}\n+ commits={subscription.commits_count} activities={subscription.activities_count} points={subscription.points}/>\n+ })\n+ }\n+ </tbody>\n+ </table>\n+ );\n+ }\n+}\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/components/subscriptions_history_row.es6.jsx", "diff": "+class SubscriptionsHistoryRow extends React.Component {\n+ constructor(props) {\n+ super(props);\n+ }\n+\n+ render () {\n+ return (\n+ <tr>\n+ <td>{ this.props.index }</td>\n+ <td>{ this.props.roundDate }</td>\n+ <td>{ this.props.commits }</td>\n+ <td>{ this.props.activities }</td>\n+ <td>{ this.props.points }</td>\n+ </tr>\n+ );\n+ }\n+}\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/controllers/v1/subscriptions_controller.rb", "diff": "+class V1::SubscriptionsController < V1::BaseController\n+ def index\n+ user = User.find params[:id]\n+ render json: user.subscriptions.where(:created_at.gt => Date.parse(\"Feb 2016\")).desc(:created_at)\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/serializers/subscription_serializer.rb", "diff": "+class SubscriptionSerializer < ActiveModel::Serializer\n+ attributes :id, :round_date, :commits_count, :activities_count, :points\n+\n+ def round_date\n+ object.round.from_date.strftime(\"%b %Y\")\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "= render partial: 'share_button'\n.row\n= react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n- %table.table.table-bordered\n- %thead\n- %tr\n- %th.col-xs-1 #\n- %th Name\n- %th.col-xs-2 Commits\n- %th.col-xs-2 Activities\n- %th.col-xs-2 Points\n- %tbody\n- = render partial: 'subscription', collection: @subscriptions.reverse\n- .tab-pane#wallet\n- = render 'transactions'\n+ = react_component 'SubscriptionsHistory', { user_id: @user.id }\n- if logged_in_user?\n.tab-pane#settings\n= render 'settings'\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -2,6 +2,7 @@ Rails.application.routes.draw do\napi_version('module': 'V1', header: {name: 'Accept', value: 'application/vnd.codecuriosity.org; version=1'}) do\nresources :transactions, only: [:index]\n+ resources :subscriptions, only: [:index]\nend\ndevise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' },\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added React Component for Subscription History on user's profile page
332,109
29.12.2016 17:20:55
-19,080
75d42d4f3e1b950a51754c75bee6c70dd72506ea
Added test cases for Subscriptions api and serializer
[ { "change_type": "ADD", "old_path": null, "new_path": "test/controllers/v1/subscriptions_controller_test.rb", "diff": "+require \"test_helper\"\n+\n+class V1::SubscriptionsControllerTest < ActionController::TestCase\n+ include Devise::TestHelpers\n+\n+ def setup\n+ super\n+ @request.env['Accept'] = 'application/vnd.codecuriosity.org; version=1'\n+ @round = create :round, :open\n+ @goal = create :goal\n+ @user = create :user, auth_token: 'dah123rty', goal: @goal\n+ @subscription = @user.subscriptions.last\n+ assert_equal 1, @user.subscriptions.count\n+ end\n+\n+ test 'response is success' do\n+ get :index, format: :json, id: @user.id\n+ assert_response :success\n+ end\n+\n+ test \"current user's subscriptions are retrieved\" do\n+ get :index, format: :json, id: @user.id\n+ assert_not_empty response.body\n+ data = JSON.parse(response.body)\n+ assert_equal 1, data.size\n+ @user.subscriptions.pluck(:id).each do |id|\n+ assert_includes data.collect{|i| i['id']}, id.to_s\n+ end\n+ end\n+\n+ test 'doesnt retrieve subscriptions of other users' do\n+ user = create :user, auth_token: 'dah123', goal: @goal\n+ assert_equal 1, user.subscriptions.count\n+ assert_equal 2, Subscription.count\n+ get :index, format: :json, id: user.id\n+ assert_not_empty response.body\n+ data = JSON.parse(response.body)\n+ assert_equal 1, data.size\n+ @user.subscriptions.pluck(:id).each do |id|\n+ refute_includes data.collect{|i| i['id']}, id.to_s\n+ end\n+ end\n+\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/serializers/subscription_serializer_test.rb", "diff": "+require \"test_helper\"\n+\n+class SubscriptionSerializerTest < ActiveSupport::TestCase\n+ def setup\n+ super\n+ create :round, :open\n+ user = create(:user)\n+ @subscription = create(:subscription, user: user, round: Round.opened)\n+ create(:commit, user: user)\n+ create(:activity, user: user)\n+ @subscription.update_points\n+ end\n+\n+ test 'serialize the subscription' do\n+ serializer = SubscriptionSerializer.new(@subscription)\n+ data = serializer.serializable_hash\n+\n+ assert_equal @subscription.id, data[:id]\n+ assert_equal @subscription.points, data[:points]\n+ assert_equal @subscription.commits_count, data[:commits_count]\n+ assert_equal @subscription.activities_count, data[:activities_count]\n+ assert_equal @subscription.round.from_date.strftime(\"%b %Y\"), data[:round_date]\n+ end\n+\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added test cases for Subscriptions api and serializer
332,109
22.08.2017 19:49:15
-19,080
be830292799496ca6b0e812e15ecdf9c3da8f292
Updated react components to conditionality coupon codes.
[ { "change_type": "RENAME", "old_path": "app/assets/javascripts/components/points_history.js.jsx", "new_path": "app/assets/javascripts/components/points_history.es6.jsx", "diff": "@@ -8,6 +8,7 @@ class PointsHistory extends React.Component {\n$.ajax({\ntype: 'GET',\nurl: '/transactions',\n+ data: { id: this.props.user_id },\ndataType: 'JSON',\nsuccess: (data) => { this.setState({ transactions: data }); },\nerror: function(error){ alert('Error!'); },\n@@ -16,6 +17,12 @@ class PointsHistory extends React.Component {\n}\nrender() {\n+ var rows = [];\n+ this.state.transactions.map(function(transaction, index){\n+ rows.push(<PointsHistoryRow key={transaction.id} show_coupon_code={this.props.show_coupon_code} index={index + 1} points={transaction.points}\n+ details={transaction.transaction_type} label={transaction.type} date={transaction.created_at} coupon_code={transaction.coupon_code}\n+ redeem_request_retailer={transaction.redeem_request_retailer} />);\n+ }.bind(this));\nreturn (\n<table className=\"table table-bordered\">\n<thead>\n@@ -28,11 +35,7 @@ class PointsHistory extends React.Component {\n</thead>\n<tbody>\n{\n- this.state.transactions.map(function(transaction, index){\n- return <PointsHistoryRow key={transaction.id} index={index + 1} points={transaction.points}\n- details={transaction.transaction_type} label={transaction.type} date={transaction.created_at} coupon_code={transaction.coupon_code}\n- redeem_request_retailer={transaction.redeem_request_retailer} />\n- })\n+ rows\n}\n<tr>\n<td>\n" }, { "change_type": "RENAME", "old_path": "app/assets/javascripts/components/points_history_row.js.jsx", "new_path": "app/assets/javascripts/components/points_history_row.es6.jsx", "diff": "@@ -7,7 +7,7 @@ class PointsHistoryRow extends React.Component {\n<td className=\"transaction-detail\">\n<b>{ this.props.details }</b>\n<small className={`label ${this.props.label == 'credit' ? 'bg-green' : 'bg-red' }`}>{ this.props.label.toUpperCase() }</small>\n- { this.props.coupon_code ? (<h5>Coupon Code:<i>{ this.props.coupon_code }</i></h5>) : (null) }\n+ { this.props.show_coupon_code && this.props.coupon_code ? (<h5>Coupon Code:<i>{ this.props.coupon_code }</i></h5>) : (null) }\n{ this.props.redeem_request_retailer ? (<small className='label bg-primary'> {this.props.redeem_request_retailer.toUpperCase()} </small>) : (null) }\n</td>\n<td>{ this.props.date }</td>\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/v1/transactions_controller.rb", "new_path": "app/controllers/v1/transactions_controller.rb", "diff": "class V1::TransactionsController < V1::BaseController\n- before_action :authenticate_user!\n+ #before_action :authenticate_user!\ndef index\n- render json: current_user.transactions.desc(:created_at)\n+ user = User.find params[:id]\n+ render json: user.transactions.desc(:created_at)\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/_transactions.html.haml", "new_path": "app/views/users/_transactions.html.haml", "diff": "-= react_component 'PointsHistory', total_points: @user.total_points\n+= react_component 'PointsHistory', total_points: @user.total_points, user_id: @user.id.to_s, show_coupon_code: logged_in_user?\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": ".row\n= react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n= react_component 'SubscriptionsHistory', { user_id: @user.id }\n+ .tab-pane#wallet\n+ = render 'transactions'\n- if logged_in_user?\n.tab-pane#settings\n= render 'settings'\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Updated react components to conditionality coupon codes.
332,109
23.08.2017 13:45:16
-19,080
91b985d55cd2a2bdd89cd515fce89790b54649ed
Fixed some failing test cases.
[ { "change_type": "MODIFY", "old_path": "test/controllers/v1/transactions_controller_test.rb", "new_path": "test/controllers/v1/transactions_controller_test.rb", "diff": "@@ -9,27 +9,28 @@ class V1::TransactionsControllerTest < ActionController::TestCase\n@goal = create :goal\n@user = create :user, auth_token: 'dah123rty', goal: @goal\n@round = create :round, :open\n- @redeem_request = create(:redeem_request, points: 50, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\n+ @transaction = create(:transaction, type: 'credit', points: 500, user: @user, transaction_type: 'royalty_bonus')\n+ @redeem_request = create(:redeem_request, points: 100, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\ncoupon_code: 'aitpune', user: @user)\n@transaction = @redeem_request.transaction\n- @transactions = FactoryGirl.create_list(:transaction, 3, type: 'credit', transaction_type: 'Round', points: 1, user: @user)\n+ @transactions = FactoryGirl.create_list(:transaction, 2, type: 'credit', transaction_type: 'Round', points: 100, user: @user)\nassert_equal 4, @user.transactions.count\nend\n- test 'response is 401 for unauthenticated user' do\n- get :index, format: :json\n- assert_response 401\n+ test 'response is success for unauthenticated user' do\n+ get :index, format: :json, id: @user.id\n+ assert_response :success\nend\ntest 'response is success for authenticated user' do\nsign_in @user\n- get :index, format: :json\n+ get :index, format: :json, id: @user.id\nassert_response :success\nend\n- test \"current user's transactions are retrieved\" do\n+ test \"user's transactions are retrieved\" do\nsign_in @user\n- get :index, format: :json\n+ get :index, format: :json, id: @user.id\nassert_not_empty response.body\ndata = JSON.parse(response.body)\nassert_equal 4, data.size\n@@ -42,7 +43,7 @@ class V1::TransactionsControllerTest < ActionController::TestCase\nassert_equal 4, @user.transactions.count\nassert_equal 3, user.transactions.count\nassert_equal 7, Transaction.count\n- get :index, format: :json\n+ get :index, format: :json, id: @user.id\nassert_not_empty response.body\ndata = JSON.parse(response.body)\nassert_equal 4, data.size\n" }, { "change_type": "MODIFY", "old_path": "test/jobs/scoring_job_test.rb", "new_path": "test/jobs/scoring_job_test.rb", "diff": "@@ -22,19 +22,6 @@ class ScoringJobTest < ActiveJob::TestCase\nassert_enqueued_jobs 2\nend\n- test 'score commits' do\n- ScoringEngine.any_instance.expects(:calculate_score).returns(0).at_most(3)\n- create :commit, user: @user, repository: @repo, message: 'some random message', commit_date: Time.now, auto_score: nil\n- create :commit, user: @user, repository: @repo, message: 'random message', commit_date: Time.now, auto_score: nil\n- create :commit, user: @user, repository: @repo, message: 'some message', commit_date: Time.now, auto_score: nil\n- assert_equal 3, @repo.commits.count\n- ScoringJob.perform_now(@repo.id.to_s, @round.id.to_s, 'commits')\n- @repo.reload\n- @repo.commits.each do |commit|\n- refute_nil commit.auto_score\n- end\n- end\n-\ntest 'score activities' do\nmessage = 'some title and description of the issue'\ncreate_list(:activity, 3, description: message, event_type: 'issue', event_action: 'opened', auto_score: nil, user: @user)\n" }, { "change_type": "MODIFY", "old_path": "test/serializers/transaction_serializer_test.rb", "new_path": "test/serializers/transaction_serializer_test.rb", "diff": "@@ -3,8 +3,12 @@ require \"test_helper\"\nclass TransactionSerializerTest < ActiveSupport::TestCase\ndef setup\nsuper\n- @redeem_request = create(:redeem_request, points: 50, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\n- coupon_code: 'aitpune')\n+ @goal = create :goal\n+ @user = create :user, auth_token: 'dah123rty', goal: @goal\n+ @round = create :round, :open\n+ @transaction = create(:transaction, type: 'credit', points: 500, user: @user, transaction_type: 'royalty_bonus')\n+ @redeem_request = create(:redeem_request, points: 100, retailer: 'other', address: 'pune', gift_product_url: Faker::Internet.url,\n+ coupon_code: 'aitpune', user: @user)\n@transaction = @redeem_request.transaction\nend\n@@ -13,7 +17,7 @@ class TransactionSerializerTest < ActiveSupport::TestCase\ndata = serializer.serializable_hash\nassert_equal @transaction.id, data[:id]\n- assert_equal -50, data[:points]\n+ assert_equal -100, data[:points]\nassert_equal 'debit', data[:type]\nassert_equal 'Redeem points', data[:transaction_type]\nassert_equal 'aitpune', data[:coupon_code]\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fixed some failing test cases.
332,109
30.08.2017 15:41:21
-19,080
a460aeb6c68be48972d70721e553f30a269bfdf3
Fixed stripe errors
[ { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -518,4 +518,4 @@ RUBY VERSION\nruby 2.3.0p0\nBUNDLED WITH\n- 1.15.3\n+ 1.15.4\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/sponsorer_details_controller_test.rb", "new_path": "test/controllers/sponsorer_details_controller_test.rb", "diff": "require \"test_helper\"\n-require \"stripe_mock\"\nclass SponsorerDetailsControllerTest < ActionController::TestCase\nbefore(:all) do\nround = create(:round, :status => 'open')\n@user = create(:user, :auth_token => 'dah123rty')\n- StripeMock.start\n- end\n-\n- after(:all) do\n- StripeMock.stop\nend\ntest \"should not render index to not-logged in user\" do\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/stripe_controller_test.rb", "new_path": "test/controllers/stripe_controller_test.rb", "diff": "require \"test_helper\"\n-require \"stripe_mock\"\nclass StripeControllerTest < ActionController::TestCase\n-\n- def stripe_helper\n- StripeMock.create_test_helper\n- end\n-\n- def setup\n- StripeMock.start\n- @sponsorer = create(:sponsorer_detail)\n- end\n-\n- def teardown\n- StripeMock.stop\n- end\n-\ntest \"should update the subscription details when subscription is created\" do\nskip(\"test case yet to be completed\")\nend\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/v1/subscriptions_controller_test.rb", "new_path": "test/controllers/v1/subscriptions_controller_test.rb", "diff": "@@ -13,6 +13,10 @@ class V1::SubscriptionsControllerTest < ActionController::TestCase\nassert_equal 1, @user.subscriptions.count\nend\n+ def teardown\n+ super\n+ end\n+\ntest 'response is success' do\nget :index, format: :json, id: @user.id\nassert_response :success\n" }, { "change_type": "MODIFY", "old_path": "test/factories/sponsorer_details.rb", "new_path": "test/factories/sponsorer_details.rb", "diff": "@@ -7,7 +7,7 @@ FactoryGirl.define do\nassociation :user\nafter(:build) do |sponsor|\n- helper = StripeMock.create_test_helper\n+ helper = StripeMock.create_test_helper(:mock)\nhelper.create_plan(amount: 1000, name: 'base', id: 'base-individual', interval: 'month', currency: 'usd')\ntoken = helper.generate_card_token(last4: \"4242\")\ncustomer = Stripe::Customer.create(email: sponsor.user.email, plan: 'base-individual', source: token)\n" }, { "change_type": "MODIFY", "old_path": "test/models/sponsorer_detail_test.rb", "new_path": "test/models/sponsorer_detail_test.rb", "diff": "require \"test_helper\"\n-require 'stripe_mock'\nclass SponsorerDetailTest < ActiveSupport::TestCase\n-\n- def stripe_helper\n- StripeMock.create_test_helper\n- end\n-\n- def setup\n- StripeMock.start\n- end\n-\n- def teardown\n- StripeMock.stop\n- end\n-\ntest \"sponsorer type must be present in sponsorer_detail\" do\nsponsorer_detail = build(:sponsorer_detail, :sponsorer_type => nil)\nsponsorer_detail.valid?\n@@ -77,6 +63,7 @@ class SponsorerDetailTest < ActiveSupport::TestCase\nassert_equal 0, sponsorer_detail.payments.count\nassert_equal 0, user.transactions.count\nassert_equal 500, user.reload.points\n+ stripe_helper = StripeMock.create_test_helper(:mock)\nplan = stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\nsponsorer_detail.save_payment_details(plan, 10000, Time.now - 2.days)\nassert_equal 1, sponsorer_detail.payments.count\n" }, { "change_type": "MODIFY", "old_path": "test/models/stripe_response_handler_test.rb", "new_path": "test/models/stripe_response_handler_test.rb", "diff": "require \"test_helper\"\n-require 'stripe_mock'\nclass SponsorerDetailTest < ActiveSupport::TestCase\n- def stripe_helper\n- StripeMock.create_test_helper\n- end\n-\n- def setup\n- StripeMock.start\n- end\n-\n- def teardown\n- StripeMock.stop\n- end\n-\ntest 'when customer subscription is created then the subscription should be marked as active'\ntest 'when invoice payment is succeeded then payment should be recorded'\n" }, { "change_type": "MODIFY", "old_path": "test/test_helper.rb", "new_path": "test/test_helper.rb", "diff": "@@ -13,6 +13,7 @@ require \"rails/test_help\"\nrequire \"minitest/rails\"\nrequire \"webmock/minitest\"\nrequire \"mocha/mini_test\"\n+require 'stripe_mock'\n# To add Capybara feature tests add `gem \"minitest-rails-capybara\"`\n# to the test group in the Gemfile and uncomment the following:\n@@ -27,6 +28,8 @@ class ActionController::TestCase\ninclude Warden::Test::Helpers\ninclude ActiveJob::TestHelper\nWebMock.disable_net_connect!(allow: \"codeclimate.com\")\n+ before { StripeMock.start }\n+ after { StripeMock.stop }\ndef stub_get(path, endpoint = Github.endpoint.to_s)\nstub_request(:get, endpoint + path)\n@@ -38,8 +41,14 @@ class ActiveSupport::TestCase\ninclude FactoryGirl::Syntax::Methods\nWebMock.disable_net_connect!(allow: \"codeclimate.com\")\nDatabaseCleaner.strategy = :truncation\n- before { DatabaseCleaner.start }\n- after { DatabaseCleaner.clean }\n+ before do\n+ DatabaseCleaner.start\n+ StripeMock.start\n+ end\n+ after do\n+ DatabaseCleaner.clean\n+ StripeMock.stop\n+ end\nend\nclass ActionDispatch::IntegrationTest\n@@ -51,4 +60,6 @@ class ActionDispatch::IntegrationTest\nCapybara::Poltergeist::Driver.new(app, timeout: 1.minute, phantomjs_options: ['--load-images=no'])\nend\nWebMock.allow_net_connect!(allow: \"codeclimate.com\")\n+ before { StripeMock.start }\n+ after { StripeMock.stop }\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fixed stripe errors
332,093
29.08.2017 18:37:00
-19,080
3b56af0252423d33bdb0e532ae6875946e569c76
Added amount field in transaction and added rake task to populate it
[ { "change_type": "MODIFY", "old_path": "app/assets/javascripts/components/points_history.es6.jsx", "new_path": "app/assets/javascripts/components/points_history.es6.jsx", "diff": "@@ -20,6 +20,7 @@ class PointsHistory extends React.Component {\nvar rows = [];\nthis.state.transactions.map(function(transaction, index){\nrows.push(<PointsHistoryRow key={transaction.id} show_coupon_code={this.props.show_coupon_code} index={index + 1} points={transaction.points}\n+ amount={transaction.amount}\ndetails={transaction.transaction_type} label={transaction.type} date={transaction.created_at} coupon_code={transaction.coupon_code}\nredeem_request_retailer={transaction.redeem_request_retailer} />);\n}.bind(this));\n@@ -28,7 +29,8 @@ class PointsHistory extends React.Component {\n<thead>\n<tr>\n<th className=\"col-xs-1\">#</th>\n- <th className=\"col-xs-3\">Points</th>\n+ <th className=\"col-xs-2\">Points</th>\n+ <th className=\"col-xs-2\">Amount($)</th>\n<th>Detail</th>\n<th>Date</th>\n</tr>\n@@ -41,7 +43,7 @@ class PointsHistory extends React.Component {\n<td>\n<b>Total</b>\n</td>\n- <td colSpan=\"4\">{ this.props.total_points }</td>\n+ <td colSpan=\"1\">{ this.props.total_points }</td>\n</tr>\n</tbody>\n</table>\n" }, { "change_type": "MODIFY", "old_path": "app/assets/javascripts/components/points_history_row.es6.jsx", "new_path": "app/assets/javascripts/components/points_history_row.es6.jsx", "diff": "@@ -4,6 +4,7 @@ class PointsHistoryRow extends React.Component {\n<tr>\n<td>{ this.props.index }</td>\n<td>{ this.props.points }</td>\n+ <td>{ \"$\" + Math.abs(this.props.amount) }</td>\n<td className=\"transaction-detail\">\n<b>{ this.props.details }</b>\n<small className={`label ${this.props.label == 'credit' ? 'bg-green' : 'bg-red' }`}>{ this.props.label.toUpperCase() }</small>\n" }, { "change_type": "MODIFY", "old_path": "app/models/transaction.rb", "new_path": "app/models/transaction.rb", "diff": "@@ -8,6 +8,7 @@ class Transaction\nfield :points , type: Integer, default: 0\nfield :transaction_type, type: String\nfield :description, type: String\n+ field :amount, type: Float, default: 0.0\nbelongs_to :user\nbelongs_to :subscription\n@@ -25,6 +26,7 @@ class Transaction\nend\nafter_create :update_user_total_points\n+ after_create :set_amount\ndef credit?\ntype == 'credit'\n@@ -54,4 +56,11 @@ class Transaction\nTransaction.where(transaction_type: 'redeem_points').sum(:points).abs\nend\n+ def set_amount\n+ if user.is_sponsorer\n+ set(amount: points.to_f/SUBSCRIPTIONS['individual'])\n+ else\n+ set(amount: points.to_f/SUBSCRIPTIONS['free'])\n+ end\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "app/serializers/transaction_serializer.rb", "new_path": "app/serializers/transaction_serializer.rb", "diff": "class TransactionSerializer < ActiveModel::Serializer\n- attributes :id, :points, :type, :transaction_type, :description, :created_at, :coupon_code, :redeem_request_retailer\n+ attributes :id, :points, :type, :transaction_type, :description, :created_at, :coupon_code, :redeem_request_retailer, :amount\ndef transaction_type\nobject.transaction_type.humanize\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/tasks/set_amount.rake", "diff": "+namespace :set_amount do\n+ # task to populate amount field in transaction\n+ desc \"set amount field for all transactions\"\n+ task set_amount_for_transactions: :environment do\n+\n+ # transactions before 2nd of august\n+ Transaction.where(:created_at.lt => DateTime.parse('02/08/2017')).each do |transaction|\n+ transaction.set(amount: transaction.points.to_f/REDEEM['one_dollar_to_points'])\n+ end\n+\n+ #transactions after and on 2nd of august\n+ Transaction.where(:created_at.gte => DateTime.parse('02/08/2017')).each do |transaction|\n+ flag = true\n+ # transaction creation time lies in between any active sponsorship then set amount\n+ # according to subscription.\n+ transaction.user.sponsorer_details.each do |sponsorer_detail|\n+ if transaction.created_at >= sponsorer_detail.subscribed_at && transaction.created_at <= sponsorer_detail.subscription_expires_at\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS[sponsorer_detail.sponsorer_type.downcase])\n+ flag = false\n+ end\n+ end\n+ # transaction time doesn't lies in between any active sponsorship then it is carried\n+ # out during free plan\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS['free']) if flag\n+ end\n+\n+ Transaction.where(:created_at.gte => DateTime.parse('01/08/2017'), transaction_type: 'royalty_bonus').each do |transaction|\n+ # take the very first sponsor plan taken by user and check whether it is taken within\n+ # a month after sign up\n+ if transaction.user.sponsorer_details.any? && transaction.user.sponsorer_details.asc(:created_at).first.created_at - transaction.user.created_at <= 1.month\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS[sponsorer_detail.sponsorer_type.downcase])\n+ else\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS['free'])\n+ end\n+ end\n+ # To keep up with the records of redeem requests all redeem transaction between 1st and\n+ # 2nd of August are done as per their subscription plan. As all redeem requests between\n+ # mentioned time are from free plan the amount assigned is $1:20 points\n+ Transaction.where(transaction_type: 'redeem_points', :created_at.gte => DateTime.parse('01/08/2017'), :created_at.lt => DateTime.parse('02/08/2017')).each do |transaction|\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS['free'])\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/lib/tasks/set_amount_test.rb", "diff": "+require 'test_helper'\n+\n+class TransactionAmountCheck < ActiveSupport::TestCase\n+ def setup\n+ @user = create :user\n+ CodeCuriosity::Application.load_tasks\n+ Rake::Task['set_amount:set_amount_for_transactions'].reenable\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction before 2nd August 2017 and transaction type is redeem points\" do\n+ transaction = create :transaction, transaction_type: 'redeem_points', type: 'debit', created_at: DateTime.parse(\"11/04/2017\"), points: 200, user: @user\n+ run_rake_task\n+ assert_equal -20, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction before 2nd August 2017 and transaction type is round points\" do\n+ transaction = create :transaction, transaction_type: 'Round', type: 'credit', created_at: DateTime.parse(\"12/02/2017\"), points: 50, user: @user\n+ run_rake_task\n+ assert_equal 5, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction before 2nd August 2017 and transaction type is royalty bonus\" do\n+ transaction = create :transaction, transaction_type: 'royalty_bonus', type: 'credit', created_at: DateTime.parse(\"13/07/2017\"), points: 300, user: @user\n+ run_rake_task\n+ assert_equal 30, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction before 2nd August 2017 and transaction type is goal bonus\" do\n+ transaction = create :transaction, transaction_type: 'GoalBonus', type: 'credit', created_at: DateTime.parse(\"11/07/2017\"), points: 20, user: @user\n+ run_rake_task\n+ assert_equal 2, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:20 points when transaction on or after 2nd August 2017 and transaction type is round points and user on free plan\" do\n+ user = create :user, is_sponsorer: false\n+ transaction = create :transaction, transaction_type: 'Round', type: 'credit', created_at: DateTime.parse(\"11/08/2017\"), points: 20, user: user\n+ run_rake_task\n+ assert_equal 1, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:20 points when transaction on or after 2nd August 2017 and transaction type is goal bonus and user on free plan\" do\n+ user = create :user, is_sponsorer: false\n+ transaction = create :transaction, transaction_type: 'GoalBonus', type: 'credit', created_at: DateTime.parse(\"11/08/2017\"), points: 250, user: user\n+ run_rake_task\n+ assert_equal 12.5, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:20 points when transaction on or after 2nd August 2017 and transaction type is redeem points and user on free plan\" do\n+ user = create :user, is_sponsorer: false\n+ transaction = create :transaction, transaction_type: 'redeem_points', type: 'debit', created_at: DateTime.parse(\"11/08/2017\"), points: 200, user: user\n+ run_rake_task\n+ assert_equal -10, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction on or after 2nd August 2017 and transaction type is redeem points and user on paid plan\" do\n+ user = create :user, is_sponsorer: true\n+ sponsorer_detail = create :sponsorer_detail, user: user\n+ transaction = create :transaction, transaction_type: 'redeem_points', type: 'debit', created_at: DateTime.parse(\"11/08/2017\"), points: 200, user: user\n+ run_rake_task\n+ assert_equal -20, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction on or after 2nd August 2017 and transaction type is Round points and user on paid plan\" do\n+ user = create :user, is_sponsorer: true\n+ sponsorer_detail = create :sponsorer_detail, user: user\n+ transaction = create :transaction, transaction_type: 'Round', type: 'credit', created_at: DateTime.parse(\"11/08/2017\"), points: 200, user: user\n+ run_rake_task\n+ assert_equal 20, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction on or after 2nd August 2017 and transaction type is goal bonus and user on paid plan\" do\n+ user = create :user, is_sponsorer: true\n+ sponsorer_detail = create :sponsorer_detail, user: user\n+ transaction = create :transaction, transaction_type: 'GoalBonus', type: 'credit', created_at: DateTime.parse(\"11/08/2017\"), points: 250, user: user\n+ run_rake_task\n+ assert_equal 25, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:10 points when transaction is on or after 2nd August 2017 and transaction type is royalty points and user took subscription within a month after sign up\" do\n+ user = create :user, is_sponsorer: true, created_at: DateTime.parse(\"3/08/2017\")\n+ sponsorer_detail = create :sponsorer_detail, created_at: DateTime.parse(\"5/08/2017\"), user: user\n+ transaction = create :transaction, transaction_type: 'royalty_bonus', type: 'credit',\n+ created_at: DateTime.parse(\"3/08/2017\"), points: 500, user: user\n+ run_rake_task\n+ assert_equal 50, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:20 points when transaction is on or after 2nd August 2017 and transaction type is royalty points and user signed up and took subscription after 1 month\" do\n+ user = create :user, is_sponsorer: true, created_at: DateTime.parse(\"3/08/2017\")\n+ sponsorer_detail = create :sponsorer_detail, created_at: DateTime.parse(\"5/09/2017\"), user: user\n+ transaction = create :transaction, transaction_type: 'royalty_bonus', type: 'credit',\n+ created_at: DateTime.parse(\"3/08/2017\"), points: 500, user: user\n+ run_rake_task\n+ assert_equal 25, transaction.reload.amount\n+ end\n+\n+ test \"set transaction amount $1:20 points when transaction is between 1st August and 2nd August 2017 and transaction type is redeem points\" do\n+ transaction = create :transaction, transaction_type: 'redeem_points', type: 'debit', created_at: DateTime.parse(\"1/08/2017 08:30\"), points: 500, user: @user\n+ run_rake_task\n+ assert_equal -25, transaction.reload.amount\n+ end\n+\n+ private\n+\n+ def run_rake_task\n+ Rake::Task['set_amount:set_amount_for_transactions'].invoke\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "test/models/transaction_test.rb", "new_path": "test/models/transaction_test.rb", "diff": "@@ -82,4 +82,40 @@ class TransactionTest < ActiveSupport::TestCase\nassert_not_nil transaction.coupon_code\nend\n+ test \"set amount $1:10 points if user is active sponsorer during transaction with type redeem points\" do\n+ user = create :user, is_sponsorer: true\n+ transaction = create :transaction, transaction_type: 'redeem_points', type: 'debit', points: 200, user: user\n+ assert_equal -20, transaction.reload.amount\n+ end\n+\n+ test \"set amount $1:10 points if user is active sponsorer during transaction with type round\" do\n+ user = create :user, is_sponsorer: true\n+ transaction = create :transaction, transaction_type: 'Round', type: 'credit', points: 200, user: user\n+ assert_equal 20, transaction.reload.amount\n+ end\n+\n+ test \"set amount $1:10 points if user is active sponsorer during transaction with type goal bonus\" do\n+ user = create :user, is_sponsorer: true\n+ transaction = create :transaction, transaction_type: 'GoalBonus', type: 'credit', points: 200, user: user\n+ assert_equal 20, transaction.reload.amount\n+ end\n+\n+ test \"set amount $1:20 points if user is not an active sponsorer during transaction\" do\n+ user = create :user, is_sponsorer: false\n+ transaction = create :transaction, transaction_type: 'redeem_points', type: 'debit', points: 200, user: user\n+ assert_equal -10, transaction.reload.amount\n+ end\n+\n+ test \"set amount $1:20 points if user is active sponsorer during transaction with type round\" do\n+ user = create :user, is_sponsorer: false\n+ transaction = create :transaction, transaction_type: 'Round', type: 'credit', points: 200, user: user\n+ assert_equal 10, transaction.reload.amount\n+ end\n+\n+ test \"set amount $1:20 points if user is active sponsorer during transaction with type goal bonus\" do\n+ user = create :user, is_sponsorer: false\n+ transaction = create :transaction, transaction_type: 'GoalBonus', type: 'credit', points: 200, user: user\n+ assert_equal 10, transaction.reload.amount\n+ end\n+\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added amount field in transaction and added rake task to populate it
332,093
30.08.2017 13:51:51
-19,080
0d82f7ccba3cabeb4adec8840a379fa5d02c7482
Update royalty bonus amount if user takes subscription within a month after signup
[ { "change_type": "MODIFY", "old_path": "app/models/sponsorer_detail.rb", "new_path": "app/models/sponsorer_detail.rb", "diff": "@@ -35,6 +35,7 @@ class SponsorerDetail\nafter_create :update_user_as_sponsor\nafter_create :notify_user_and_admin\n+ after_create :update_royalty_bonus\nscope :organizations, -> { where(sponsorer_type: 'ORGANIZATION') }\nscope :individuals, -> { where(sponsorer_type: 'INDIVIDUAL') }\n@@ -67,4 +68,14 @@ class SponsorerDetail\nSponsorMailer.notify_admin(user_id.to_s, payment_plan, SPONSOR[sponsorer_type.downcase][payment_plan]).deliver_later\nend\n+ # update worth of royalty points of user if user took subscription within 1 month after\n+ # signup to code curiosity\n+ # first condition prevents transaction amount update when user create multiple subscriptions within 1 month after sign up\n+ def update_royalty_bonus\n+ if (user.sponsorer_details.count == 1) && (self.created_at - user.created_at <= 1.month) && (user.transactions.where(transaction_type: 'royalty_bonus').any?)\n+ transaction = user.transactions.find_by transaction_type: 'royalty_bonus'\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS[user.sponsorer_detail.sponsorer_type.downcase])\n+ end\n+ end\n+\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -223,7 +223,7 @@ class User\nend\ndef royalty_bonus_transaction\n- self.transactions.where(transaction_type: 'royalty_bonus').first\n+ self.transactions.where(transaction_type: 'royalty_bonus').asc(:created_at).first\nend\ndef reset_points\n" }, { "change_type": "MODIFY", "old_path": "test/models/sponsorer_detail_test.rb", "new_path": "test/models/sponsorer_detail_test.rb", "diff": "@@ -79,4 +79,19 @@ class SponsorerDetailTest < ActiveSupport::TestCase\nend\nend\n+ test \"must update royalty bonus amount for user if user took subscription within 1 month after sign up\" do\n+ user = create :user, created_at: DateTime.parse(\"01/09/2017\")\n+ transaction = create :transaction, created_at: DateTime.parse(\"01/09/2017\"), transaction_type: 'royalty_bonus', type: 'credit', points: 200, user: user\n+ assert_equal 10, transaction.reload.amount\n+ sponsorer_detail = create :sponsorer_detail, created_at: DateTime.parse(\"05/09/2017\"), sponsorer_type: 'INDIVIDUAL', user: user\n+ assert_equal 20, transaction.reload.amount\n+ end\n+\n+ test \"must not update royalty bonus amount for user if user took subscription after 1 month after sign up\" do\n+ user = create :user, created_at: DateTime.parse(\"01/09/2017\")\n+ transaction = create :transaction, created_at: DateTime.parse(\"01/09/2017\"), transaction_type: 'royalty_bonus', type: 'credit', points: 200, user: user\n+ assert_equal 10, transaction.reload.amount\n+ sponsorer_detail = create :sponsorer_detail, created_at: DateTime.parse(\"05/10/2017\"), sponsorer_type: 'INDIVIDUAL', user: user\n+ assert_equal 10, transaction.reload.amount\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "test/test_helper.rb", "new_path": "test/test_helper.rb", "diff": "@@ -31,6 +31,9 @@ class ActionController::TestCase\nbefore { StripeMock.start }\nafter { StripeMock.stop }\n+ before { StripeMock.start }\n+ after { StripeMock.stop }\n+\ndef stub_get(path, endpoint = Github.endpoint.to_s)\nstub_request(:get, endpoint + path)\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Update royalty bonus amount if user takes subscription within a month after signup
332,093
31.08.2017 12:05:25
-19,080
3c2e527f98de614e96f98c7d09e4b87ca1095d97
Refactored code and stripe mock added
[ { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -240,6 +240,6 @@ class User\nend\ndef sponsorer_detail\n- sponsorer_details.asc(:subscribed_at).last\n+ sponsorer_details.asc(:created_at).last\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "lib/tasks/set_amount.rake", "new_path": "lib/tasks/set_amount.rake", "diff": "@@ -28,7 +28,7 @@ namespace :set_amount do\n# take the very first sponsor plan taken by user and check whether it is taken within\n# a month after sign up\nif transaction.user.sponsorer_details.any? && transaction.user.sponsorer_details.asc(:created_at).first.created_at - transaction.user.created_at <= 1.month\n- transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS[sponsorer_detail.sponsorer_type.downcase])\n+ transaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS[transaction.user.sponsorer_detail.sponsorer_type.downcase])\nelse\ntransaction.set(amount: transaction.points.to_f/SUBSCRIPTIONS['free'])\nend\n" }, { "change_type": "MODIFY", "old_path": "test/factories/sponsorer_details.rb", "new_path": "test/factories/sponsorer_details.rb", "diff": "@@ -7,6 +7,7 @@ FactoryGirl.define do\nassociation :user\nafter(:build) do |sponsor|\n+ StripeMock.start\nhelper = StripeMock.create_test_helper(:mock)\nhelper.create_plan(amount: 1000, name: 'base', id: 'base-individual', interval: 'month', currency: 'usd')\ntoken = helper.generate_card_token(last4: \"4242\")\n@@ -16,6 +17,7 @@ FactoryGirl.define do\nsponsor.subscribed_at = Time.at(customer.subscriptions.data.first.created).to_datetime\nsponsor.subscription_expires_at = Time.at(customer.subscriptions.data.first.current_period_end).to_datetime\nsponsor.subscription_status = customer.subscriptions.data.first.status\n+ StripeMock.stop\nend\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "test/helpers/admin/subscriptions_helper_test.rb", "new_path": "test/helpers/admin/subscriptions_helper_test.rb", "diff": "@@ -6,7 +6,7 @@ class Admin::SubscriptionsHelperTest < ActionView::TestCase\ncreate(:sponsorer_detail, sponsorer_type: \"INDIVIDUAL\",subscription_status: 'active')\ncreate(:sponsorer_detail, sponsorer_type: \"INDIVIDUAL\",subscription_status: 'canceled')\ncreate(:sponsorer_detail, sponsorer_type: \"ORGANIZATION\",subscription_status: 'active')\n- assert_equal 255, total_subscription_amount\n+ assert_equal 260, total_subscription_amount\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "test/mailers/sponsor_mailer_test.rb", "new_path": "test/mailers/sponsor_mailer_test.rb", "diff": "require \"test_helper\"\nclass SponsorMailerTest < ActionMailer::TestCase\n+ include ActiveJob::TestHelper\n+\ntest \"whenever subscription is created mailer must send mail to user and admin\" do\nuser = create :user\ns = create :sponsorer_detail, payment_plan: \"base\", user: user\n+ clear_enqueued_jobs\n+ clear_performed_jobs\ns.send :notify_user_and_admin\nassert_enqueued_jobs 2\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/sponsorer_detail_test.rb", "new_path": "test/models/sponsorer_detail_test.rb", "diff": "require \"test_helper\"\nclass SponsorerDetailTest < ActiveSupport::TestCase\n+\ntest \"sponsorer type must be present in sponsorer_detail\" do\nsponsorer_detail = build(:sponsorer_detail, :sponsorer_type => nil)\nsponsorer_detail.valid?\n@@ -63,6 +64,7 @@ class SponsorerDetailTest < ActiveSupport::TestCase\nassert_equal 0, sponsorer_detail.payments.count\nassert_equal 0, user.transactions.count\nassert_equal 500, user.reload.points\n+ StripeMock.start\nstripe_helper = StripeMock.create_test_helper(:mock)\nplan = stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\nsponsorer_detail.save_payment_details(plan, 10000, Time.now - 2.days)\n@@ -71,6 +73,7 @@ class SponsorerDetailTest < ActiveSupport::TestCase\nassert_equal 1, user.transactions.where(points: 500, transaction_type: 'royalty_bonus', type: 'credit').count\nassert_equal 1, user.transactions.where(points: -500, transaction_type: 'redeem_points', type: 'debit').count\nassert_equal 0, user.reload.points\n+ StripeMock.stop\nend\ntest \"must save a new sponsorer with all params\" do\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -72,6 +72,7 @@ class UserTest < ActiveSupport::TestCase\nuser = create :user, github_user_since: Date.today - 6.months, created_at: Date.today - 3.months, points: 500\ncreate(:subscription, round: round, user: user)\ncreate(:sponsorer_detail, user: user, subscription_status: :canceled)\n+ sleep 1\nsponsorer_detail_2 = create(:sponsorer_detail, user: user, subscription_status: :canceled)\nassert_equal sponsorer_detail_2, user.sponsorer_detail\nend\n" }, { "change_type": "MODIFY", "old_path": "test/test_helper.rb", "new_path": "test/test_helper.rb", "diff": "@@ -31,9 +31,6 @@ class ActionController::TestCase\nbefore { StripeMock.start }\nafter { StripeMock.stop }\n- before { StripeMock.start }\n- after { StripeMock.stop }\n-\ndef stub_get(path, endpoint = Github.endpoint.to_s)\nstub_request(:get, endpoint + path)\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Refactored code and stripe mock added
332,109
01.09.2017 12:40:07
-19,080
ab3317629753243cba6fa3a96875cb7e30ee6e02
Added sidekiq web interface and feature to score commit once its created. Added sidekiq-status to display the sidekiq-web interface to admin users. Added feature to schedule commit scoring job once the commit is created.
[ { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -41,6 +41,7 @@ gem 'stripe'\ngem 'react-rails'\ngem 'versionist'\ngem 'active_model_serializers', '~> 0.10.0'\n+gem 'sidekiq-status'\ngroup :development, :test do\ngem 'byebug'\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -383,6 +383,8 @@ GEM\nconnection_pool (~> 2.2, >= 2.2.0)\nredis (~> 3.2, >= 3.2.1)\nsinatra (>= 1.4.7)\n+ sidekiq-status (0.6.0)\n+ sidekiq (>= 2.7)\nsimple_form (3.2.1)\nactionpack (> 4, < 5.1)\nactivemodel (> 4, < 5.1)\n@@ -501,6 +503,7 @@ DEPENDENCIES\nsass-rails (~> 5.0)\nsdoc (~> 0.4.0)\nsidekiq (~> 4.0)\n+ sidekiq-status\nsimple_form (~> 3.2.1)\nsimplecov\nspring\n" }, { "change_type": "MODIFY", "old_path": "app/jobs/activity_job.rb", "new_path": "app/jobs/activity_job.rb", "diff": "class ActivityJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\ninclude ActiveJobRetriesCount\nqueue_as :git\n" }, { "change_type": "MODIFY", "old_path": "app/jobs/commit_job.rb", "new_path": "app/jobs/commit_job.rb", "diff": "class CommitJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\ninclude ActiveJobRetriesCount\nqueue_as :git\n" }, { "change_type": "MODIFY", "old_path": "app/jobs/org_repos_job.rb", "new_path": "app/jobs/org_repos_job.rb", "diff": "class OrgReposJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\nqueue_as :git\nattr_accessor :org\n" }, { "change_type": "MODIFY", "old_path": "app/jobs/score_commit_job.rb", "new_path": "app/jobs/score_commit_job.rb", "diff": "class ScoreCommitJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\ninclude ActiveJobRetriesCount\n+ MAX_RETRY_COUNT = 10\nqueue_as :score\ndef perform(commit_id)\n" }, { "change_type": "MODIFY", "old_path": "app/jobs/scoring_job.rb", "new_path": "app/jobs/scoring_job.rb", "diff": "class ScoringJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\ninclude ActiveJobRetriesCount\nqueue_as :git\n" }, { "change_type": "MODIFY", "old_path": "app/jobs/user_repos_job.rb", "new_path": "app/jobs/user_repos_job.rb", "diff": "class UserReposJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\nqueue_as :git\nattr_accessor :user\n" }, { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -40,6 +40,8 @@ class Commit\nc.user.inc(commits_count: 1)\nend\n+ after_create :schedule_scoring_job\n+\ndef info\n@info ||= repository ? user.gh_client.repos.commits.get(repository.owner, repository.name, sha, { redirection: true }) : nil\nend\n@@ -50,6 +52,13 @@ class Commit\nprivate\n+ def schedule_scoring_job\n+ Sidekiq.logger.info \"Scoring for commit: #{id}, Round: #{round.from_date}\"\n+ ScoreCommitJob.set(wait: Random.new.rand(20).minutes).perform_later(id.to_s)\n+ rescue StandardError => e\n+ Sidekiq.logger.info \"Commit: #{id}, Error: #{e}\"\n+ end\n+\ndef set_round\n# FIXME: This code was added to address a corner case for commits appearing in next round\n# instead of the last month. However, it will impact scoring and bonus points. Keeping this\n" }, { "change_type": "ADD", "old_path": null, "new_path": "config/initializers/sidekiq.rb", "diff": "+require 'sidekiq'\n+require 'sidekiq-status'\n+\n+Sidekiq.configure_client do |config|\n+ config.client_middleware do |chain|\n+ # accepts :expiration (optional)\n+ chain.add Sidekiq::Status::ClientMiddleware, expiration: 30.minutes # default\n+ end\n+end\n+\n+Sidekiq.configure_server do |config|\n+ config.server_middleware do |chain|\n+ # accepts :expiration (optional)\n+ chain.add Sidekiq::Status::ServerMiddleware, expiration: 30.minutes # default\n+ end\n+ config.client_middleware do |chain|\n+ # accepts :expiration (optional)\n+ chain.add Sidekiq::Status::ClientMiddleware, expiration: 30.minutes # default\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "+require 'sidekiq/web'\n+require 'sidekiq-status/web'\n+\nRails.application.routes.draw do\n+ Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]\n+\napi_version('module': 'V1', header: {name: 'Accept', value: 'application/vnd.codecuriosity.org; version=1'}) do\nresources :transactions, only: [:index]\nresources :subscriptions, only: [:index]\n@@ -137,4 +142,7 @@ Rails.application.routes.draw do\nmount LetterOpenerWeb::Engine, at: \"/letter_opener\"\nend\n+ authenticate :user, lambda { |u| u.is_admin? } do\n+ mount Sidekiq::Web => '/sidekiq'\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/commit_test.rb", "new_path": "test/models/commit_test.rb", "diff": "require 'test_helper'\nclass CommitTest < ActiveSupport::TestCase\n+ include ActiveJob::TestHelper\ndef setup\nsuper\n@@ -64,4 +65,23 @@ class CommitTest < ActiveSupport::TestCase\nassert_equal commit_2.round, round_2\nend\n+ test 'commit scoring job is scheduled after the commit is created' do\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ assert_enqueued_jobs 0\n+ assert_enqueued_with(job: ScoreCommitJob) do\n+ create(:commit, message: Faker::Lorem.sentences, sha: 'eb0df748bbf084ca522f5ce4ebcf508d16169b96', repository: create(:repository, owner: 'joshsoftware', name: 'code-curiosity'))\n+ end\n+ end\n+\n+ test 'commit scoring job is not scheduled after the commit is updated' do\n+ commit = create(:commit, message: Faker::Lorem.sentences, sha: 'eb0df748bbf084ca522f5ce4ebcf508d16169b96', repository: create(:repository, owner: 'joshsoftware', name: 'code-curiosity'))\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ assert_enqueued_jobs 0\n+ assert_no_enqueued_jobs do\n+ commit.update({message: Faker::Lorem.sentences})\n+ end\n+ end\n+\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added sidekiq web interface and feature to score commit once its created. Added sidekiq-status to display the sidekiq-web interface to admin users. Added feature to schedule commit scoring job once the commit is created.
332,093
01.09.2017 14:26:42
-19,080
ce3494b831ff3966f67ddc19c2621334e5be1369
Score commits to zero if repository is absent
[ { "change_type": "MODIFY", "old_path": "app/jobs/score_commit_job.rb", "new_path": "app/jobs/score_commit_job.rb", "diff": "@@ -6,6 +6,7 @@ class ScoreCommitJob < ActiveJob::Base\ndef perform(commit_id)\ncommit = Commit.find(commit_id)\n+ if commit.repository\nengine = ScoringEngine.new(commit.repository)\nbegin\nSidekiq.logger.info \"Scoring for commit: #{commit.id}\"\n@@ -14,5 +15,8 @@ class ScoreCommitJob < ActiveJob::Base\nSidekiq.logger.info \"Commit: #{commit.id}, Error: #{e}\"\nretry_job wait: 5.minutes if retries_count < MAX_RETRY_COUNT\nend\n+ else\n+ commit.set(auto_score: 0)\n+ end\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "test/jobs/score_commit_job_test.rb", "new_path": "test/jobs/score_commit_job_test.rb", "diff": "@@ -23,10 +23,16 @@ class ScoreCommitJobTest < ActiveJob::TestCase\nassert_enqueued_jobs 1\nend\n- test 'must score commit' do\n+ test 'must score commit if repository is present' do\nScoringEngine.any_instance.stubs(:calculate_score).with(@commit).returns(2)\nScoreCommitJob.perform_now(@commit.id.to_s)\nassert_equal 1, Commit.count\nassert_equal 2, @commit.reload.auto_score\nend\n+\n+ test 'must score commit to 0 if repository is absent' do\n+ commit = create(:commit, message: Faker::Lorem.sentences, sha: 'eb0df748bbf084ca522f5ce4ebcf508d16169b96', repository: nil)\n+ ScoreCommitJob.perform_now(commit.id.to_s)\n+ assert_equal 0, commit.reload.auto_score\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/stripe_response_handler_test.rb", "new_path": "test/models/stripe_response_handler_test.rb", "diff": "require \"test_helper\"\nclass SponsorerDetailTest < ActiveSupport::TestCase\n- test 'when customer subscription is created then the subscription should be marked as active'\n+ test 'when customer subscription is created then the subscription should be marked as active' do\n+ skip(\"Pending\")\n+ end\n- test 'when invoice payment is succeeded then payment should be recorded'\n+ test 'when invoice payment is succeeded then payment should be recorded' do\n+ skip(\"Pending\")\n+ end\n- test 'invoice payment is failed'\n+ test 'invoice payment is failed' do\n+ skip(\"Pending\")\n+ end\n- test 'customer subscription is updated'\n+ test 'customer subscription is updated' do\n+ skip(\"Pending\")\n+ end\n- test 'customer source is created'\n+ test 'customer source is created' do\n+ skip(\"Pending\")\n+ end\n- test 'customer subscription is deleted'\n+ test 'customer subscription is deleted' do\n+ skip(\"Pending\")\n+ end\ndef seed\n@round = create :round, :open\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Score commits to zero if repository is absent
332,109
03.09.2017 00:41:56
-19,080
99e3ca024bbd1fa8be6dec0b04bc810a98960080
Revered the logic to schedule commit scoring on its creation
[ { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -40,7 +40,7 @@ class Commit\nc.user.inc(commits_count: 1)\nend\n- after_create :schedule_scoring_job\n+ #after_create :schedule_scoring_job\ndef info\n@info ||= repository ? user.gh_client.repos.commits.get(repository.owner, repository.name, sha, { redirection: true }) : nil\n" }, { "change_type": "MODIFY", "old_path": "test/models/commit_test.rb", "new_path": "test/models/commit_test.rb", "diff": "@@ -65,6 +65,7 @@ class CommitTest < ActiveSupport::TestCase\nassert_equal commit_2.round, round_2\nend\n+=begin\ntest 'commit scoring job is scheduled after the commit is created' do\nclear_enqueued_jobs\nclear_performed_jobs\n@@ -83,5 +84,6 @@ class CommitTest < ActiveSupport::TestCase\ncommit.update({message: Faker::Lorem.sentences})\nend\nend\n+=end\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Revered the logic to schedule commit scoring on its creation
332,093
05.09.2017 17:42:36
-19,080
f83c60c530e18f5b757c95afa3c7aa5be6195f55
Rake task to remove transactions which are created when user became sponsorer
[ { "change_type": "MODIFY", "old_path": "app/models/sponsorer_detail.rb", "new_path": "app/models/sponsorer_detail.rb", "diff": "@@ -46,7 +46,6 @@ class SponsorerDetail\ndef save_payment_details(plan, amount, date)\npayment = self.payments.build(subscription_plan: plan, amount: amount/100, date: Time.at(date).to_datetime)\npayment.save!\n- user.reset_points\nend\nprivate\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -226,15 +226,6 @@ class User\nself.transactions.where(transaction_type: 'royalty_bonus').asc(:created_at).first\nend\n- def reset_points\n- if self.points > 0\n- p = self.points\n- self.transactions.create!(points: p, transaction_type: 'royalty_bonus', type: 'credit')\n- self.transactions.create!(points: -p, transaction_type: 'redeem_points', type: 'debit')\n- self.set(points: 0)\n- end\n- end\n-\ndef active_sponsorer_detail\nsponsorer_details.asc(:subscribed_at).where(subscription_status: :active).asc(:created_at).last\nend\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/tasks/revert_bonus.rake", "diff": "+namespace :revert_bonus do\n+ desc 'revert royaly bonus assigned to user after taking a subscription'\n+ # Remove all transaction created when user became an sponsorer and his/her all points\n+ # got converted into royalty bonus.\n+ task revert_subscription_royalty_bonus: :environment do\n+ # Taking all the sponsorers\n+ sponsorers = User.where(:id.in => SponsorerDetail.pluck(:user_id).uniq)\n+ # Fetching all royalty transactions formed during sponsorer creating\n+ royalty_transactions = Transaction.where(transaction_type: :royalty_bonus, :user_id.in => sponsorers.pluck(:id), :created_at.gte => DateTime.parse('01/08/2017'))\n+ points = royalty_transactions.collect{ |x| -x.points }\n+ # Fetching all redeem transactions formed during sponsorer creating\n+ redeem_transactions = Transaction.where(transaction_type: :redeem_points, :points.in => points, :created_at.gt => DateTime.parse('01/08/2017'))\n+ # Deleting fetched royalty transactions\n+ royalty_transactions.destroy_all\n+ # Deleting fetched redeem transactions\n+ redeem_transactions.destroy_all\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/lib/tasks/revert_bonus_test.rb", "diff": "+require 'test_helper'\n+\n+class RevertBonusTest < ActiveSupport::TestCase\n+ def setup\n+ @user = create :user\n+ CodeCuriosity::Application.load_tasks\n+ Rake::Task['revert_bonus:revert_subscription_royalty_bonus'].reenable\n+ end\n+\n+ test 'remove transaction which are created when user becomes a sponsorer' do\n+ sponsorer_detail = create :sponsorer_detail, user: @user\n+ transaction_1 = create :transaction, type: 'credit', transaction_type: 'royalty_bonus', points: 500, created_at: DateTime.parse(\"30/07/2017\"), user: @user\n+ transaction_2 = create :transaction, type: 'credit', transaction_type: 'Round', points: 50, user: @user\n+ sponsorer_detail.save_payment_details('INDIVIDUAL', 250, Time.now)\n+ transaction_3 = create :transaction, type: 'credit', transaction_type: 'royalty_bonus', points: 550, user: @user\n+ transaction_4 = create :transaction, type: 'debit', transaction_type: 'redeem_points', points: -550, user: @user\n+ assert_equal 4, @user.transactions.count\n+ assert_equal 2, @user.transactions.where(transaction_type: 'royalty_bonus').count\n+ assert_equal 1, @user.transactions.where(transaction_type: 'redeem_points').count\n+ run_rake_task\n+ assert_equal 2, @user.transactions.count\n+ assert_equal 1, @user.transactions.where(type: 'credit', transaction_type: 'royalty_bonus', points: 500).count\n+ assert_equal 0, @user.transactions.where(type: 'debit', transaction_type: 'redeeem_points').count\n+ end\n+\n+ test 'must not remove any other transactions' do\n+ transaction_1 = create :transaction, transaction_type: 'royalty_bonus', type: 'credit', points: 200, user: @user\n+ transaction_2 = create :transaction, transaction_type: 'redeem_points', type: 'debit', points: -100, user: @user\n+ assert_equal 2, @user.transactions.count\n+ assert_equal 1, @user.transactions.where(transaction_type: 'royalty_bonus').count\n+ assert_equal 1, @user.transactions.where(transaction_type: 'redeem_points').count\n+ run_rake_task\n+ assert_equal 2, @user.transactions.count\n+ assert_equal 1, @user.transactions.where(transaction_type: 'royalty_bonus').count\n+ assert_equal 1, @user.transactions.where(transaction_type: 'redeem_points').count\n+ end\n+\n+ def run_rake_task\n+ Rake::Task['revert_bonus:revert_subscription_royalty_bonus'].invoke\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "test/lib/tasks/set_amount_test.rb", "new_path": "test/lib/tasks/set_amount_test.rb", "diff": "require 'test_helper'\n-class TransactionAmountCheck < ActiveSupport::TestCase\n+class SetAmountTest < ActiveSupport::TestCase\ndef setup\n@user = create :user\nCodeCuriosity::Application.load_tasks\n" }, { "change_type": "MODIFY", "old_path": "test/models/sponsorer_detail_test.rb", "new_path": "test/models/sponsorer_detail_test.rb", "diff": "@@ -56,7 +56,7 @@ class SponsorerDetailTest < ActiveSupport::TestCase\nassert user.roles.where(name: 'Sponsorer').any?\nend\n- test 'save_payment_details should create the payment record and reset the user points' do\n+ test 'save_payment_details should create the payment record' do\nround = create :round, :open\nuser = create :user, github_user_since: Date.today - 6.months, created_at: Date.today - 3.months, points: 500\ncreate(:subscription, round: round, user: user)\n@@ -69,10 +69,6 @@ class SponsorerDetailTest < ActiveSupport::TestCase\nplan = stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\nsponsorer_detail.save_payment_details(plan, 10000, Time.now - 2.days)\nassert_equal 1, sponsorer_detail.payments.count\n- assert_equal 2, user.transactions.count\n- assert_equal 1, user.transactions.where(points: 500, transaction_type: 'royalty_bonus', type: 'credit').count\n- assert_equal 1, user.transactions.where(points: -500, transaction_type: 'redeem_points', type: 'debit').count\n- assert_equal 0, user.reload.points\nStripeMock.stop\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -46,19 +46,6 @@ class UserTest < ActiveSupport::TestCase\nassert user.able_to_redeem?\nend\n- test \"reset_points should move points to royalty points and set points to 0\" do\n- round = create :round, :open\n- user = create :user, github_user_since: Date.today - 6.months, created_at: Date.today - 3.months, points: 500\n- create(:subscription, round: round, user: user)\n- assert_equal 0, user.transactions.count\n- assert_equal 500, user.reload.points\n- user.reset_points\n- assert_equal 2, user.transactions.count\n- assert_equal 1, user.transactions.where(points: 500, transaction_type: 'royalty_bonus', type: 'credit').count\n- assert_equal 1, user.transactions.where(points: -500, transaction_type: 'redeem_points', type: 'debit').count\n- assert_equal 0, user.reload.points\n- end\n-\ntest 'active_sponsorer_detail should return the active sponsorer detail' do\nround = create :round, :open\nuser = create :user, github_user_since: Date.today - 6.months, created_at: Date.today - 3.months, points: 500\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Rake task to remove transactions which are created when user became sponsorer
332,093
07.09.2017 15:11:15
-19,080
a35bc866e015485b5b9bfbb508a058f661260292
A feature to block users
[ { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/admin/users.js", "diff": "+$(document).on('page:change', function(event) {\n+\n+ $(document).on('change', '.block', function(){\n+ id = this.id;\n+ $(\".block#\"+id).prop(\"disabled\", true);\n+ $.ajax({\n+ type: 'patch',\n+ url: '/admin/users/'+id+'/block_user',\n+ data: { 'blocked': this.checked, 'id': id }\n+ })\n+ })\n+});\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/admin/users_controller.rb", "new_path": "app/controllers/admin/users_controller.rb", "diff": "class Admin::UsersController < ApplicationController\nbefore_action :authenticate_user!\nbefore_action :authenticate_admin!\n+ before_action :find_user, only: [:block_user, :destroy]\ndef index\n@users = User.contestants.desc(:created_at).page(params[:page])\n@@ -13,14 +14,16 @@ class Admin::UsersController < ApplicationController\ndef login_as\nuser = User.find(params[:user_id])\n-\nif user\nsign_in :user, user\nend\n-\nredirect_to root_path\nend\n+ def block_user\n+ @user.update(blocked: params[:blocked]) if @user\n+ end\n+\ndef search\nif params[:q].blank?\nredirect_to admin_users_path\n@@ -35,15 +38,17 @@ class Admin::UsersController < ApplicationController\nend\ndef destroy\n- user = User.find(params[:id])\n-\n- if user\n- user.destroy\n- redirect_to admin_users_path, notice: \"#{user.name} has been deleted successfully\"\n+ if @user\n+ @user.destroy\n+ redirect_to admin_users_path, notice: \"#{@user.name} has been deleted successfully\"\nelse\nredirect_to admin_users_path, notice: \"User not found\"\nend\n-\nend\n+ private\n+\n+ def find_user\n+ @user = User.find(params[:id])\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/github/repos_controller.rb", "new_path": "app/controllers/github/repos_controller.rb", "diff": "@@ -3,7 +3,7 @@ class Github::ReposController < ApplicationController\ndef sync\nunless current_user.repo_syncing?\n- UserReposJob.perform_later(current_user.id.to_s)\n+ UserReposJob.perform_later(current_user.id.to_s) unless current_user.blocked\nend\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/repositories_controller.rb", "new_path": "app/controllers/repositories_controller.rb", "diff": "@@ -37,7 +37,7 @@ class RepositoriesController < ApplicationController\ndef sync\nunless current_user.gh_data_syncing?\n- CommitJob.perform_later(current_user.id.to_s, 'all', @repo.id.to_s)\n+ CommitJob.perform_later(current_user.id.to_s, 'all', @repo.id.to_s) unless current_user.blocked\nend\nflash[:notice] = I18n.t('repositories.github_sync')\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "@@ -18,12 +18,19 @@ class UsersController < ApplicationController\nend\nend\n+ def block_user\n+ user = User.find(params[:id])\n+ user.update(blocked: true)\n+ end\n+\ndef sync\nunless current_user.gh_data_syncing?\n+ unless current_user.blocked\nCommitJob.perform_later(current_user.id.to_s, 'all')\nActivityJob.perform_later(current_user.id.to_s, 'all')\nend\nend\n+ end\ndef update_notification\nuser_params = params.fetch(:user).permit(:notify_monthly_progress, :notify_monthly_points)\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -24,6 +24,7 @@ class User\nfield :last_sign_in_at, type: Time\nfield :current_sign_in_ip, type: String\nfield :last_sign_in_ip, type: String\n+ field :blocked, type: Boolean, default: false\nfield :github_handle, type: String\nfield :active, type: Boolean, default: true\n@@ -77,6 +78,8 @@ class User\nindex(auto_created: 1)\nscope :contestants, -> { where(auto_created: false) }\n+ scope :blocked, -> { where(blocked: true) }\n+ scope :allowed, -> { where(blocked: false) }\nscope :judges, -> { where(is_judge: true) }\nvalidates :email, :github_handle, :name, presence: true\n" }, { "change_type": "MODIFY", "old_path": "app/views/admin/users/_user.html.haml", "new_path": "app/views/admin/users/_user.html.haml", "diff": "%td= user.points\n%td= user.email\n%td= user.created_at.strftime('%d/%m/%Y %T')\n+ %td= check_box_tag user.id, 'blocked', user.blocked, { id: \"#{user.id}\", class: 'block'}\n%td\n- if user.is_judge?\n%a{href: admin_user_mark_as_judge_path(user, flag: false), class: \"btn btn-danger btn-sm\", data: {confirm: \"Are you sure?\"}}\nLogin as\n%a{href: admin_user_path(user.id), class: \"btn btn-danger btn-sm\", data: {method: 'delete', confirm: \"Are you sure? This action is irreversible\"}}\n%i.fa.fa-trash\n+\n" }, { "change_type": "ADD", "old_path": "app/views/admin/users/block_user.js", "new_path": "app/views/admin/users/block_user.js", "diff": "" }, { "change_type": "MODIFY", "old_path": "app/views/admin/users/index.html.haml", "new_path": "app/views/admin/users/index.html.haml", "diff": "%th.col-xs-2 Name\n%th.col-xs-1 Handler\n%th.col-xs-1 Points\n- %th.col-xs-3 Email\n+ %th.col-xs-2 Email\n%th.col-xs-2 Joining Date\n+ %th.col-xs-1 Block\n%th.col-xs-3 Actions\n%tbody#users\n= render partial: 'user', collection: @users\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -64,6 +64,9 @@ Rails.application.routes.draw do\nget :mark_as_judge\nget :login_as\nget :search, on: :collection\n+ member do\n+ patch :block_user\n+ end\nend\nresources :subscriptions, only: [:index]\n" }, { "change_type": "MODIFY", "old_path": "lib/tasks/fetch_data.rake", "new_path": "lib/tasks/fetch_data.rake", "diff": "@@ -5,8 +5,8 @@ namespace :fetch_data do\nputs \"Running for #{type}\"\nper_batch = 1000\n- users = User.where(auto_created: false)\n-\n+ # disable fetching of repos for blocked users\n+ users = User.contestants.allowed\n0.step(users.count, per_batch) do |offset|\nusers.limit(per_batch).skip(offset).each do |user|\n#CommitJob.perform_later(user, type)\n@@ -23,7 +23,7 @@ namespace :fetch_data do\ndesc \"Fetch data for all rounds\"\ntask :all_rounds => :environment do |t, args|\ntype = 'all'\n- users = User.where(auto_created: false)\n+ users = User.contestants.allowed\nSubscription.all.each do |subscription|\nround = Round.find(subscription.round_id)\n@@ -39,7 +39,8 @@ namespace :fetch_data do\ndesc \"Sync repositories for every user\"\ntask :sync_repos => :environment do |t, args|\nper_batch = 1000\n- users = User.where(auto_created: false)\n+ # dont fetch repos of blocked users\n+ users = User.contestants.allowed\n0.step(users.count, per_batch) do |offset|\nusers.limit(per_batch).skip(offset).each do |user|\n" }, { "change_type": "MODIFY", "old_path": "lib/tasks/round.rake", "new_path": "lib/tasks/round.rake", "diff": "namespace :round do\n- desc \"Creat next round\"\n+ desc \"Create next round\"\ntask :next => :environment do |t, args|\ntomorrow = (Time.now - 1.hour).tomorrow\nreturn unless tomorrow.day == 1\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/lib/tasks/fetch_data_test.rb", "diff": "+require 'test_helper'\n+\n+class FetchDataTest < ActiveSupport::TestCase\n+ include ActiveJob::TestHelper\n+\n+ def setup\n+ super\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ CodeCuriosity::Application.load_tasks\n+ end\n+\n+ def teardown\n+ super\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ end\n+\n+ test 'must not fetch commits and activities if user is blocked and is contestant' do\n+ # contestant and blocked\n+ user = create :user, blocked: true, auto_created: false\n+ round = create :round, :open\n+ repository = create :repository\n+ user.repositories << repository\n+ commit = create :commit, round: round, user: user, repository: repository\n+ activity = create :activity, round: round, user: user, repository: repository\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ Rake::Task['fetch_data:commits_and_activities'].reenable\n+ Rake::Task['fetch_data:commits_and_activities'].invoke\n+ assert_enqueued_jobs 0\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ end\n+\n+ test 'must not fetch repositories if user is blocked and is contestant' do\n+ # contestant and blocked\n+ user = create :user, blocked: true, auto_created: false\n+ round = create :round, :open\n+ repository = create :repository\n+ user.repositories << repository\n+ commit = create :commit, round: round, user: user, repository: repository\n+ activity = create :activity, round: round, user: user, repository: repository\n+ clear_enqueued_jobs\n+ clear_performed_jobs\n+ Rake::Task['fetch_data:sync_repos'].reenable\n+ Rake::Task['fetch_data:sync_repos'].invoke\n+ assert_enqueued_jobs 0\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -64,6 +64,31 @@ class UserTest < ActiveSupport::TestCase\nassert_equal sponsorer_detail_2, user.sponsorer_detail\nend\n+ test 'must return user which are contestants and not blocked' do\n+ user_1 = create :user, auto_created: false, blocked: false\n+ user_2 = create :user, auto_created: true, blocked: false\n+ user_3 = create :user, auto_created: false, blocked: true\n+ assert_includes User.contestants.allowed, user_1\n+ assert_equal 1, User.contestants.allowed.count\n+ end\n+\n+ test 'must return user which are contestants' do\n+ user_1 = create :user, auto_created: false, blocked: false\n+ user_2 = create :user, auto_created: true, blocked: false\n+ user_3 = create :user, auto_created: false, blocked: true\n+ assert_includes User.contestants, user_1\n+ assert_includes User.contestants, user_3\n+ assert_equal 2, User.contestants.count\n+ end\n+\n+ test 'must return user which are contestants and blocked' do\n+ user_1 = create :user, auto_created: false, blocked: false\n+ user_2 = create :user, auto_created: true, blocked: false\n+ user_3 = create :user, auto_created: false, blocked: true\n+ assert_includes User.contestants.blocked, user_3\n+ assert_equal 1, User.contestants.blocked.count\n+ end\n+\ndef omniauthentication\n@date = Date.new(2015, 10, 10)\nOmniAuth.config.test_mode = true\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
A feature to block users
332,093
22.08.2017 14:29:10
-19,080
4740fc74387b53f569bb2fe40ce4bd96b0811d9e
user can add his twitter handle
[ { "change_type": "MODIFY", "old_path": "app/assets/stylesheets/redeem.scss", "new_path": "app/assets/stylesheets/redeem.scss", "diff": "a {\ncolor: white;\n}\n+\n}\n+\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "@@ -23,6 +23,17 @@ class UsersController < ApplicationController\nuser.update(blocked: true)\nend\n+ def edit\n+\n+ end\n+\n+ def update\n+ if current_user.update user_params\n+ return\n+ end\n+ render :edit\n+ end\n+\ndef sync\nunless current_user.gh_data_syncing?\nunless current_user.blocked\n@@ -89,4 +100,10 @@ class UsersController < ApplicationController\nuser.save\nredirect_to root_url, notice: \"Your account has been deleted successfully.\"\nend\n+ private\n+\n+ def user_params\n+ params.require(:user).permit(:twitter_handle)\n+ end\n+\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -27,6 +27,7 @@ class User\nfield :blocked, type: Boolean, default: false\nfield :github_handle, type: String\n+ field :twitter_handle, type: String\nfield :active, type: Boolean, default: true\nfield :is_judge, type: Boolean, default: false\nfield :is_sponsorer, type: Boolean, default: false\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/users/edit.js.haml", "diff": "+$(\"#newform\").html(\"#{escape_javascript(render 'form')}\")\n+$('#userform').modal('show')\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%h1 User Profile\n= react_component 'CelebrityBox', { type: 'info', title: '', message: t('user.celebrity_signup') } if current_user && current_user.celebrity\n%section.content\n+ #newform\n.row\n.col-sm-4\n.box.box-primary\n.box-body.box-profile\n= image_tag avatar_url(@user), class: 'profile-user-img img-responsive img-circle', alt: @user.name\n%h3.profile-username.text-center= @user.name.titleize\n- %p.text-muted.text-center\n+ %p.text-muted\n+ - unless @user.twitter_handle.present?\n+ .pull-right\n+ = link_to \"Add your twitter handle\", edit_user_path, remote: true, data: { toggle: \"modal\", target: \"#newform\"}\n+ - else\n+ %i.fa.fa-twitter\n+ = @user.twitter_handle\n= link_to github_url(@user), target: '_blank' do\n%i.fa.fa-github\n= @user.github_handle\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/users/update.js.haml", "diff": "+$('#userform').modal('hide');\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -32,7 +32,7 @@ Rails.application.routes.draw do\npost \"/stripe/webhooks\", to: \"stripe#webhooks\"\n- resources :users, only: [:index, :show, :destroy] do\n+ resources :users, only: [:index, :show, :destroy, :edit, :update] do\nmember do\nget 'sync'\nput 'update_notification'\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
user can add his twitter handle
332,093
24.08.2017 11:35:12
-19,080
47d1b70cc72a3b4e1f551041366eed34dd0ede5d
Integration with twitter
[ { "change_type": "DELETE", "old_path": ".byebug_history", "new_path": null, "diff": "-exit\n-round.errors\n-round.name = nil\n-round.errors\n-round.errors[:end_date]\n-round.errors\n-round.save\n-round\n-round.errors[:end_date]\n-round.valid?\n-round.end_date\n-round.from_date\n-exit\n-current_user.points\n-exit\n-params\n-current_user\n-next\n-continue\n-next\n-next]\n-next\n-user.subscriptions\n-next\n-user\n-next\n-round\n-next\n-continue\n-@round.subscriptions\n-@round.subscriptions.where(:user_id => current_user).any?\n-@round\n-next\n-current_user\n" }, { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -57,6 +57,7 @@ group :development, :test do\ngem 'brakeman', :require => false\ngem 'simplecov', :require => false\ngem 'webmock'\n+ gem 'twitter'\nend\ngroup :test do\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -93,6 +93,7 @@ GEM\nsass (>= 3.3.4)\nbrakeman (3.3.5)\nbson (4.1.1)\n+ buftok (0.2.0)\nbuilder (3.2.2)\nbyebug (9.0.5)\ncapybara (2.9.2)\n@@ -140,6 +141,7 @@ GEM\ndotenv-rails (2.1.1)\ndotenv (= 2.1.1)\nrailties (>= 4.0, < 5.1)\n+ equalizer (0.0.10)\nerubis (2.7.0)\nexecjs (2.7.0)\nfactory_girl (4.7.0)\n@@ -174,8 +176,15 @@ GEM\nhaml (~> 4.0.0)\nnokogiri (~> 1.6.0)\nruby_parser (~> 3.5)\n+ http (1.0.4)\n+ addressable (~> 2.3)\n+ http-cookie (~> 1.0)\n+ http-form_data (~> 1.0.1)\n+ http_parser.rb (~> 0.6.0)\nhttp-cookie (1.0.3)\ndomain_name (~> 0.5)\n+ http-form_data (1.0.3)\n+ http_parser.rb (0.6.0)\ni18n (0.7.0)\njbuilder (2.6.0)\nactivesupport (>= 3.0.0, < 5.1)\n@@ -205,6 +214,8 @@ GEM\nnokogiri (>= 1.5.9)\nmail (2.6.4)\nmime-types (>= 1.16, < 4)\n+ memoizable (0.4.2)\n+ thread_safe (~> 0.3, >= 0.3.1)\nmetaclass (0.0.4)\nmethod_source (0.8.2)\nmime-types (3.1)\n@@ -257,6 +268,7 @@ GEM\nmulti_json (1.12.1)\nmulti_xml (0.5.5)\nmultipart-post (2.0.0)\n+ naught (1.1.0)\nnetrc (0.11.0)\nnokogiri (1.6.8)\nmini_portile2 (~> 2.1.0)\n@@ -388,6 +400,7 @@ GEM\nsimple_form (3.2.1)\nactionpack (> 4, < 5.1)\nactivemodel (> 4, < 5.1)\n+ simple_oauth (0.3.1)\nsimplecov (0.12.0)\ndocile (~> 1.1.0)\njson (>= 1.8, < 3)\n@@ -414,11 +427,22 @@ GEM\nmulti_json (~> 1.0)\nstripe (>= 1.31.0, <= 1.58.0)\nthor (0.19.1)\n- thread_safe (0.3.5)\n+ thread_safe (0.3.6)\ntilt (2.0.5)\ntimecop (0.8.1)\nturbolinks (2.5.3)\ncoffee-rails\n+ twitter (5.17.0)\n+ addressable (~> 2.3)\n+ buftok (~> 0.2.0)\n+ equalizer (= 0.0.10)\n+ faraday (~> 0.9.0)\n+ http (~> 1.0)\n+ http_parser.rb (~> 0.6.0)\n+ json (~> 1.8)\n+ memoizable (~> 0.4.0)\n+ naught (~> 1.0)\n+ simple_oauth (~> 0.3.0)\ntzinfo (1.2.2)\nthread_safe (~> 0.1)\nuglifier (3.0.1)\n@@ -511,6 +535,7 @@ DEPENDENCIES\nstripe-ruby-mock (~> 2.4.1)\ntimecop\nturbolinks (~> 2.5)\n+ twitter\nuglifier (>= 1.3.0)\nversionist\nweb-console (~> 2.0)\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/redeem_controller.rb", "new_path": "app/controllers/redeem_controller.rb", "diff": "@@ -4,7 +4,7 @@ class RedeemController < ApplicationController\ndef create\n@redeem = current_user.redeem_requests.build(redeem_params)\n@redeem.sponsorer_detail = current_user.active_sponsorer_detail\n-\n+ debugger\nif @redeem.save\nflash[:notice] = I18n.t('redeem.request_created')\nend\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "@@ -100,6 +100,7 @@ class UsersController < ApplicationController\nuser.save\nredirect_to root_url, notice: \"Your account has been deleted successfully.\"\nend\n+\nprivate\ndef user_params\n" }, { "change_type": "MODIFY", "old_path": "app/models/redeem_request.rb", "new_path": "app/models/redeem_request.rb", "diff": "@@ -30,6 +30,7 @@ class RedeemRequest\nbefore_validation {|r| r.points = r.points.to_i }\nbefore_create :set_amount\n+ after_create :tweet\nafter_create do |r|\nr.create_redeem_transaction\n@@ -38,6 +39,7 @@ class RedeemRequest\nend\nafter_save :send_notification\n+ after_save :tweet\ndef user_total_points\nif user.total_points == 0\n@@ -197,6 +199,15 @@ class RedeemRequest\nprivate\n+ def tweet\n+ if !status\n+ message = \"#Reward of $#{amount} requested by #{user.twitter_handle ? user.twitter_handle : user.name} #opensource\"\n+ elsif status_changed?\n+ message = \"Hooray! #{user.twitter_handle ? user.twitter_handle : user.name} has just been #rewarded $#{amount}. #opensource\"\n+ end\n+ TWITTER_CLIENT.update(message);\n+ end\n+\ndef set_amount\ndenominator = if sponsorer_detail\nREDEEM['one_dollar_to_points']\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -85,6 +85,7 @@ class User\nvalidates :email, :github_handle, :name, presence: true\n+ before_save :check_twitter_handle\nafter_create do |user|\nuser.calculate_popularity unless user.auto_created\nend\n@@ -237,4 +238,11 @@ class User\ndef sponsorer_detail\nsponsorer_details.asc(:created_at).last\nend\n+\n+ def check_twitter_handle\n+ if self.twitter_handle.present? && !/^@/.match(self.twitter_handle)\n+ self.twitter_handle = '@' + self.twitter_handle\n+ end\n+ end\n+\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/edit.js.haml", "new_path": "app/views/users/edit.js.haml", "diff": "-$(\"#newform\").html(\"#{escape_javascript(render 'form')}\")\n+$(\"#userform\").replaceWith(\"#{escape_javascript(render 'form')}\")\n$('#userform').modal('show')\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%h1 User Profile\n= react_component 'CelebrityBox', { type: 'info', title: '', message: t('user.celebrity_signup') } if current_user && current_user.celebrity\n%section.content\n- #newform\n+ #userform\n.row\n.col-sm-4\n.box.box-primary\n= image_tag avatar_url(@user), class: 'profile-user-img img-responsive img-circle', alt: @user.name\n%h3.profile-username.text-center= @user.name.titleize\n%p.text-muted\n- - unless @user.twitter_handle.present?\n.pull-right\n- = link_to \"Add your twitter handle\", edit_user_path, remote: true, data: { toggle: \"modal\", target: \"#newform\"}\n- - else\n- %i.fa.fa-twitter\n- = @user.twitter_handle\n+ = link_to \"#{ @user.twitter_handle.present? ? @user.twitter_handle : \"Add your twitter handle\" }\", edit_user_path, remote: true, data: { toggle: \"modal\", target: \"#newform\"}, class: \"%i fa fa-twitter\", id: 'twitter-handle'\n+ / .pull-right\n+ / %i.fa.fa-twitter\n+ / = @user.twitter_handle\n= link_to github_url(@user), target: '_blank' do\n%i.fa.fa-github\n= @user.github_handle\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/update.js.haml", "new_path": "app/views/users/update.js.haml", "diff": "$('#userform').modal('hide');\n+$('.modal-backdrop').remove();\n+$('#twitter-handle').html(\"#{current_user.twitter_handle.present? ? current_user.twitter_handle : \"Add your twitter handle\" }\");\n" }, { "change_type": "ADD", "old_path": null, "new_path": "config/initializers/twitter_client.rb", "diff": "+# global twitter client for our code curiosity to tweet\n+TWITTER_CLIENT = Twitter::REST::Client.new do |config|\n+ config.consumer_key = ENV['TWITTER_CONSUMER_KEY']\n+ config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']\n+ config.access_token = ENV['TWITTER_ACCESS_TOKEN']\n+ config.access_token_secret = ENV['TWITTER_ACCESS_SECRET']\n+end\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/users_controller_test.rb", "new_path": "test/controllers/users_controller_test.rb", "diff": "require 'test_helper'\nclass UsersControllerTest < ActionController::TestCase\n- # test \"the truth\" do\n- # assert true\n- # end\n+ test \"should return success when edit is called\" do\n+ goal = create :goal, points: 15\n+ goal_2 = create :goal, points: 30\n+ round = create :round, :open\n+ user = create :user, auth_token: 'dah123rty', goal: goal\n+ sign_in user\n+ xhr :get, :edit, id: user.id\n+ assert_response :success\n+ end\n+\n+ test \"should update twitter handle when update\" do\n+ goal = create :goal, points: 15\n+ goal_2 = create :goal, points: 30\n+ round = create :round, :open\n+ user = create :user, auth_token: 'dah123rty', goal: goal\n+ sign_in user\n+ xhr :patch, :update, user: { twitter_handle: 'amitk'}, id: user.id\n+ assert_response :success\n+ assert_equal '@amitk', user.reload.twitter_handle\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -89,6 +89,13 @@ class UserTest < ActiveSupport::TestCase\nassert_equal 1, User.contestants.blocked.count\nend\n+ test 'append @ prefix in twitter handle if not present' do\n+ user = create :user\n+ assert_nil user.twitter_handle\n+ user.update(twitter_handle: 'amitk')\n+ assert /^@/.match(user.twitter_handle)\n+ end\n+\ndef omniauthentication\n@date = Date.new(2015, 10, 10)\nOmniAuth.config.test_mode = true\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Integration with twitter
332,093
01.09.2017 13:20:43
-19,080
32c613a0f624b35f633b9642bbb2e004c8ae6092
User helper method to show twitter handle correctly
[ { "change_type": "MODIFY", "old_path": "app/helpers/users_helper.rb", "new_path": "app/helpers/users_helper.rb", "diff": "@@ -13,4 +13,8 @@ module UsersHelper\n#v*REDEEM['one_dollar_to_points']]\nend\nend\n+\n+ def remove_prefix(twitter_handle)\n+ twitter_handle[1..twitter_handle.length]\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/_form.html.haml", "new_path": "app/views/users/_form.html.haml", "diff": ".modal-footer\n= f.submit 'save', class: 'btn btn-primary'\n%button.btn.btn-default{\"data-dismiss\" => \"modal\", :type => \"button\"} Close\n+\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%h3.profile-username.text-center= @user.name.titleize\n%p.text-muted\n.pull-right\n- = link_to \"#{ @user.twitter_handle.present? ? @user.twitter_handle : \"Add your twitter handle\" }\", edit_user_path, remote: true, data: { toggle: \"modal\", target: \"#newform\"}, class: \"%i fa fa-twitter\", id: 'twitter-handle'\n+ = link_to \"#{ @user.twitter_handle.present? ? remove_prefix(@user.twitter_handle) : \"Add your twitter handle\" }\", edit_user_path, remote: true, data: { toggle: \"modal\", target: \"#newform\"}, class: \"%i fa fa-twitter\", id: 'twitter-handle'\n/ .pull-right\n/ %i.fa.fa-twitter\n/ = @user.twitter_handle\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/helpers/users_helper_test.rb", "diff": "+require 'test_helper'\n+\n+class UsersHelperTest < ActionView::TestCase\n+ test \"show remove twitter handle prefix from twitter handle\" do\n+ twitter_handle = \"@amitk301293\"\n+ assert_equal = \"amitk301293\", remove_prefix(twitter_handle)\n+ end\n+end\n\\ No newline at end of file\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
User helper method to show twitter handle correctly
332,093
11.09.2017 16:54:35
-19,080
2af8764ec3cc6d97fe6ac3d4883f99617cfafff6
Changes in views Simple changes in views at profile and judging page.
[ { "change_type": "MODIFY", "old_path": "app/views/judging/activities.html.haml", "new_path": "app/views/judging/activities.html.haml", "diff": ".box.box-primary\n.box-header.with-border\n%h3.box-title Activities\n- .box-tools.pull-right.commits-tools#activities_pagination\n+ .box-tools.text-center.commits-tools#activities_pagination\n= paginate @activities, remote: true, window: 1, outer_window: 1\n.box-body#activities\n= render partial: 'judging/activity', collection: @activities\n" }, { "change_type": "MODIFY", "old_path": "app/views/judging/commits.html.haml", "new_path": "app/views/judging/commits.html.haml", "diff": ".box.box-primary\n.box-header.with-border\n%h3.box-title Commits\n- .box-tools.pull-right.commits-tools#commits_pagination\n+ .box-tools.text-center.commits-tools#commits_pagination\n= paginate @commits, remote: true, window: 1, outer_window: 1\n.box-body#commits\n= render partial: 'judging/commit', collection: @commits\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": ".box-body.box-profile\n= image_tag avatar_url(@user), class: 'profile-user-img img-responsive img-circle', alt: @user.name\n%h3.profile-username.text-center= @user.name.titleize\n- %p.text-muted\n+ %p.text-muted.text-center\n- if logged_in_user?\n= render 'twitter_data', user: @user\n= link_to github_url(@user), target: '_blank' do\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Changes in views Simple changes in views at profile and judging page.
332,093
12.09.2017 11:30:05
-19,080
97ba31ac360cd32284489e695320122a0f7b7533
Modified impact graph on homepage
[ { "change_type": "MODIFY", "old_path": "app/helpers/home_helper.rb", "new_path": "app/helpers/home_helper.rb", "diff": "@@ -42,11 +42,11 @@ module HomeHelper\ndef multi_line_chart\nusers = Subscription.collection.aggregate( [ { \"$group\" => { _id: \"$round_id\", total: { \"$sum\" => 1 } } } ] ).sort {|x, y| Date.parse(Round.find(y[\"_id\"]).name) <=> Date.parse(Round.find(x[\"_id\"]).name) }.collect { |r| [ Round.find(r[\"_id\"]).name, r[\"total\"] ] }\n- users = users[1..6].reverse if users.any?\n+ users = users[1..(users.count - 7)].reverse if users.any?\ncontributions = Subscription.collection.aggregate( [ {\"$match\" => { \"created_at\" => { \"$gt\" => Date.parse(\"march 2016\") } } }, { \"$group\" => { _id: \"$round_id\", total: { \"$sum\" => \"$points\" } } } ]).sort {|x, y| Date.parse(Round.find(y[\"_id\"]).name) <=> Date.parse(Round.find(x[\"_id\"]).name) }.collect { |r| [ Round.find(r[\"_id\"]).name, r[\"total\"] ] }\n- contributions = contributions[1..6].reverse if contributions.any?\n+ contributions = contributions[1..(contributions.count - 2)].reverse if contributions.any?\n@user_trend = []\n@contribution_trend = []\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Modified impact graph on homepage
332,093
12.09.2017 13:51:50
-19,080
77cf0c7d9ad9019761b7d879465b50281512cb12
Google analytics added A coffee script add to track traffic on code curiosity
[ { "change_type": "ADD", "old_path": null, "new_path": "app/assets/javascripts/google_analytics.js.coffee", "diff": "+class @GoogleAnalytics\n+\n+ @load: ->\n+\n+ ((i, s, o, g, r, a, m) ->\n+ i['GoogleAnalyticsObject'] = r\n+ i[r] = i[r] or ->\n+ (i[r].q = i[r].q or []).push arguments\n+ return\n+\n+ i[r].l = 1 * new Date\n+\n+ a = s.createElement(o)\n+ m = s.getElementsByTagName(o)[0]\n+\n+ a.async = 1\n+ a.src = g\n+ m.parentNode.insertBefore a, m\n+ return\n+ ) window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'\n+ ga 'create', GoogleAnalytics.analyticsId(), 'auto'\n+\n+ # If Turbolinks is supported, set up a callback to track pageviews on page:change.\n+ # If it isn't supported, just track the pageview now.\n+ if typeof Turbolinks isnt 'undefined' and Turbolinks.supported\n+ document.addEventListener \"page:change\", (->\n+ GoogleAnalytics.trackPageview()\n+ ), true\n+ else\n+ GoogleAnalytics.trackPageview()\n+\n+ @trackPageview: (url) ->\n+ unless GoogleAnalytics.isLocalRequest()\n+ ga 'send',\n+ hitType: 'pageview'\n+ page: location.pathname\n+\n+ @isLocalRequest: ->\n+ GoogleAnalytics.documentDomainIncludes \"local\"\n+\n+ @documentDomainIncludes: (str) ->\n+ document.domain.indexOf(str) isnt -1\n+\n+ @analyticsId: ->\n+ # your google analytics ID(s) here...\n+ 'UA-106229370-1'\n+\n+GoogleAnalytics.load()\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Google analytics added A coffee script add to track traffic on code curiosity
332,093
12.09.2017 15:42:03
-19,080
acc6b483187bf2fc03e3b9951648b3c16e8a86a2
Twitter link added at landing page
[ { "change_type": "MODIFY", "old_path": "app/views/application/_navbar.html.haml", "new_path": "app/views/application/_navbar.html.haml", "diff": "%span.sr-only Toggle navigation\n.navbar-custom-menu\n%ul.nav.navbar-nav\n+ %li\n+ = link_to 'https://twitter.com/code_curiosity', target: :_blank do\n+ %i.fa.fa-twitter\n%li\n= link_to faq_path do\n%i.fa.fa-question\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Twitter link added at landing page
332,093
12.09.2017 16:53:25
-19,080
7c839f3cb1cfa75e4271aa17dc1760bad6cd18b3
Twitter link on nav bar Link added to Code Curiosity twitter
[ { "change_type": "MODIFY", "old_path": "app/views/application/_navbar.html.haml", "new_path": "app/views/application/_navbar.html.haml", "diff": ".navbar-custom-menu\n%ul.nav.navbar-nav\n%li\n- = link_to 'https://twitter.com/code_curiosity', target: :_blank do\n+ = link_to ACCOUNT['twitter'], { :style=>'color:#1da1f2;', target: :_blank} do\n%i.fa.fa-twitter\n%li\n= link_to faq_path do\n" }, { "change_type": "MODIFY", "old_path": "config/code_curiosity_config.yml", "new_path": "config/code_curiosity_config.yml", "diff": "@@ -67,3 +67,5 @@ redeem:\n- amazon.in\n- amazon.uk\n+account:\n+ twitter: 'https://twitter.com/code_curiosity'\n" }, { "change_type": "MODIFY", "old_path": "config/initializers/globals.rb", "new_path": "config/initializers/globals.rb", "diff": "@@ -14,6 +14,7 @@ YAML.load_file('config/code_curiosity_config.yml').tap do |config|\nSUBSCRIPTIONS = config['subscriptions']\nSPONSORER_THRESHOLD = config['sponsor_display_threshold']\nREDEEM_THRESHOLD = config['redeem_request_threshold']\n+ ACCOUNT = config['account']\nend\nCOMMIT_RATINGS = (0..5).to_a\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Twitter link on nav bar Link added to Code Curiosity twitter
332,093
14.09.2017 11:30:08
-19,080
27c170f88e36ac1a0567b533d715ee854c8222b1
Fix favicon on home, info and public page
[ { "change_type": "MODIFY", "old_path": "app/views/layouts/home.html.haml", "new_path": "app/views/layouts/home.html.haml", "diff": "%meta{:charset => 'UTF-8'}/\n%meta{:content => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no', :name => 'viewport'}/\n%title CodeCuriosity\n+ = favicon_link_tag asset_path('icon.png'), :rel => 'icon', :type => 'image/png'\n= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true\n= javascript_include_tag 'application', 'data-turbolinks-track' => true\n= csrf_meta_tags\n" }, { "change_type": "MODIFY", "old_path": "app/views/layouts/info.html.haml", "new_path": "app/views/layouts/info.html.haml", "diff": "%meta{:charset => 'UTF-8'}/\n%meta{:content => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no', :name => 'viewport'}/\n%title CodeCuriosity\n+ = favicon_link_tag asset_path('icon.png'), :rel => 'icon', :type => 'image/png'\n= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true\n= javascript_include_tag 'application', 'data-turbolinks-track' => true\n= csrf_meta_tags\n" }, { "change_type": "MODIFY", "old_path": "app/views/layouts/public.html.haml", "new_path": "app/views/layouts/public.html.haml", "diff": "%meta{:charset => 'UTF-8'}/\n%meta{:content => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no', :name => 'viewport'}/\n%title CodeCuriosity\n+ = favicon_link_tag asset_path('icon.png'), :rel => 'icon', :type => 'image/png'\n= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true\n= javascript_include_tag 'application', 'data-turbolinks-track' => true\n= csrf_meta_tags\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fix favicon on home, info and public page
332,093
19.09.2017 16:52:12
-19,080
3ef1fcda97cf3e950ed11afeda5844de1ed6b233
Admin repositories page modified Displaying only parent repositories and those forked repositories whose parent not present in DB. Forked repos count present in DB with parent repos. Ignore all forked repos if parent repo is ignored.
[ { "change_type": "MODIFY", "old_path": "app/controllers/admin/repositories_controller.rb", "new_path": "app/controllers/admin/repositories_controller.rb", "diff": "@@ -2,11 +2,11 @@ class Admin::RepositoriesController < ApplicationController\nbefore_action :authenticate_user!\nbefore_action :authenticate_admin!\nbefore_action :load_repository, only: [ :assign_judge, :add_judges, :update_ignore_field ]\n-\ndef index\nstatus = params[:ignored] || false\n- @repos = Repository.where(ignore: status, name: /#{params[:query]}/).\n+ @repos = Repository.parent.where(ignore: status, name: /#{params[:query]}/).\norder(name: :asc).page(params[:page])\n+ load_forks_count\nif request.xhr?\nrespond_to do |format|\nformat.js\n@@ -25,6 +25,8 @@ class Admin::RepositoriesController < ApplicationController\ndef update_ignore_field\n@repo.update_attributes(ignore: params[:ignore_value])\n+ repositories = Repository.any_of({popular_repository_id: @repo.id}, {source_gh_id: @repo.gh_id})\n+ repositories.update_all(ignore: params[:ignore_value]) if repositories\nend\ndef search\n@@ -33,11 +35,15 @@ class Admin::RepositoriesController < ApplicationController\nreturn\nend\n- @repos = Repository.required.where(name: /#{params[:q]}/).asc(:name).page(params[:page])\n-\n+ @repos = Repository.required.parent.where(name: /#{params[:q]}/).asc(:name).page(params[:page])\n+ load_forks_count\nrender :index\nend\n+ def load_forks_count\n+ @forks_repos_count = Repository.collection.aggregate [ { '$match' => {popular_repository_id: { '$in' => @repos.pluck(:id) } } }, {'$group' => { '_id' => '$popular_repository_id', 'count' => { '$sum' => 1} } } ]\n+ end\n+\nprivate\ndef load_repository\n" }, { "change_type": "MODIFY", "old_path": "app/helpers/admin/repositories_helper.rb", "new_path": "app/helpers/admin/repositories_helper.rb", "diff": "@@ -3,5 +3,10 @@ module Admin::RepositoriesHelper\ndef check_boolean(str)\nstr == \"true\"\nend\n+\n+ def child_count(id)\n+ repos = @forks_repos_count.to_a.select{ |r| r['_id'] == id}\n+ repos[0]['count'] unless repos.empty?\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/repository.rb", "new_path": "app/models/repository.rb", "diff": "@@ -38,7 +38,7 @@ class Repository\nscope :popular, -> { where(type: 'popular') }\nscope :users_repos, -> { where(:type.ne => 'popular') }\nscope :required, -> { where(ignore: false) }\n-\n+ scope :parent, -> { any_of({type: 'popular'}, {source_gh_id: nil, popular_repository_id: nil})}\ndef popular?\nself.type == 'popular'\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/admin/repositories/_repos_table.html.haml", "new_path": "app/views/admin/repositories/_repos_table.html.haml", "diff": "%table.table.table-hover.table-bordered#repos\n%thead\n%tr\n- %th.col-xs-2 Name\n+ %th.col-xs-2\n+ Name\n+ .badge Forks\n%th.col-xs-3 Description\n%th.col-xs-1 Stars\n%th.col-xs-1.5 Judges\n%tr\n%td.col-xs-2\n= link_to repo.name, repo.source_url, target: \"_blank\"\n+ - if repo.popular? || repo.source_gh_id.nil?\n+ .badge= child_count(repo.id)\n%td.col-xs-3= repo.description\n%td.col-xs-1= repo.stars\n%td.col-xs-1.5{id: \"judges_#{repo._id}\"}= repo.judges_name\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/admin/repositories_controller_test.rb", "new_path": "test/controllers/admin/repositories_controller_test.rb", "diff": "@@ -2,20 +2,52 @@ require \"test_helper\"\nclass Admin::RepositoriesControllerTest < ActionController::TestCase\n- test \"must update repository's ignore field\" do\n- seed_data\n- assert_equal false, @repo.ignore\n- xhr :patch, :update_ignore_field, { ignore_value: true, id: @repo.id }, format: :js\n- assert_response :success\n- assert_equal true, @repo.reload.ignore\n- end\n-\n- def seed_data\n+ def setup\nround = create(:round, :status => 'open')\nrole = create(:role, :name => 'Admin')\n@user = create(:user, :auth_token => 'dah123rty', goal: create(:goal) )\n@user.roles << role\nsign_in @user\n- @repo = create(:repository)\n+ @repo = create(:repository, gh_id: 123439, type: 'popular')\n+ end\n+\n+ test \"must update ignore field of child and parent repository which are associated with each other through popular_repository_id\" do\n+ repository_1 = create :repository, popular_repository_id: @repo.id\n+ assert_equal false, @repo.ignore\n+ assert_equal false, repository_1.reload.ignore\n+ xhr :patch, :update_ignore_field, { ignore_value: true, id: @repo.id }, format: :js\n+ assert_equal true, @repo.reload.ignore\n+ assert_equal true, repository_1.reload.ignore\n+ end\n+\n+ test \"must update ignore field of child and parent repository which are associated with each other through source_gh_id\" do\n+ repository_1 = create :repository, source_gh_id: @repo.gh_id\n+ assert_equal false, @repo.ignore\n+ assert_equal false, repository_1.reload.ignore\n+ xhr :patch, :update_ignore_field, { ignore_value: true, id: @repo.id }, format: :js\n+ assert_equal true, @repo.reload.ignore\n+ assert_equal true, repository_1.reload.ignore\n+ end\n+\n+ test \"must not update any other repositories which are not ignored\" do\n+ repository_1 = create :repository\n+ assert_equal false, @repo.ignore\n+ assert_equal false, repository_1.reload.ignore\n+ xhr :patch, :update_ignore_field, { ignore_value: true, id: @repo.id }, format: :js\n+ assert_equal true, @repo.reload.ignore\n+ assert_equal false, repository_1.reload.ignore\n+ end\n+\n+ test \"must update ignore field of parent and all its child repositories\" do\n+ repository_1 = create :repository, popular_repository_id: @repo.id\n+ repository_2 = create :repository, source_gh_id: @repo.gh_id\n+ assert_equal false, @repo.ignore\n+ assert_equal false, repository_1.reload.ignore\n+ assert_equal false, repository_2.reload.ignore\n+ xhr :patch, :update_ignore_field, { ignore_value: true, id: @repo.id }, format: :js\n+ assert_response :success\n+ assert_equal true, @repo.reload.ignore\n+ assert_equal true, repository_1.reload.ignore\n+ assert_equal true, repository_2.reload.ignore\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/repository_test.rb", "new_path": "test/models/repository_test.rb", "diff": "@@ -51,4 +51,27 @@ class RepositoryTest < ActiveSupport::TestCase\nassert info.success?\nend\n+ test 'must return parent repositories' do\n+ repo = create :repository, type: 'popular', gh_id: 231232\n+ repository_1 = create :repository, popular_repository_id: repo.id, type: nil\n+ repository_2 = create :repository, source_gh_id: repo.gh_id, popular_repository_id: repo.id, type: nil\n+ assert_equal 1, Repository.parent.count\n+ assert_equal repo, Repository.parent.find_by(gh_id: 231232)\n+ end\n+\n+ test 'must return child repositories whose parents are not present in DB' do\n+ repo = create :repository, type: 'popular', gh_id: 231232\n+ repository_1 = create :repository, type: nil\n+ repository_2 = create :repository, popular_repository_id: repo.id, type: nil\n+ assert_equal 2, Repository.parent.count\n+ assert_not_nil Repository.parent.find(repository_1.id)\n+ end\n+\n+ test 'must not return any child repositories whose parent are present in DB' do\n+ repo = create :repository, type: 'popular', gh_id: 231232\n+ repository_1 = create :repository, popular_repository_id: repo.id, type: nil\n+ repository_2 = create :repository, source_gh_id: repo.gh_id, type: nil\n+ assert_equal 1, Repository.parent.count\n+ assert_not_nil Repository.parent.find(repo.id)\n+ end\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Admin repositories page modified Displaying only parent repositories and those forked repositories whose parent not present in DB. Forked repos count present in DB with parent repos. Ignore all forked repos if parent repo is ignored.
332,093
15.09.2017 14:37:33
-19,080
29976c996b2a67c8fecb22663f684bd64a20c3ad
New display field earned in user profile Field to dispay, capital redeemed by user
[ { "change_type": "MODIFY", "old_path": "app/helpers/users_helper.rb", "new_path": "app/helpers/users_helper.rb", "diff": "@@ -17,4 +17,8 @@ module UsersHelper\ndef remove_prefix(twitter_handle)\ntwitter_handle[1..-1]\nend\n+\n+ def amount_earned(user)\n+ user.transactions.where(type: 'debit').sum(:amount).abs\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%li.list-group-item\n%b Activities\n%a.pull-right= @user.activities_count\n+ %li.list-group-item\n+ %b Earned\n+ %a.pull-right $ #{amount_earned @user}\n%li.list-group-item\n%b Goal\n- if @user.current_subscription && @user.current_subscription.goal\n" }, { "change_type": "MODIFY", "old_path": "test/helpers/users_helper_test.rb", "new_path": "test/helpers/users_helper_test.rb", "diff": "@@ -3,6 +3,25 @@ require 'test_helper'\nclass UsersHelperTest < ActionView::TestCase\ntest \"show remove twitter handle prefix from twitter handle\" do\ntwitter_handle = \"@amitk301293\"\n- assert_equal = \"amitk301293\", remove_prefix(twitter_handle)\n+ assert_equal \"amitk301293\", remove_prefix(twitter_handle)\n+ end\n+\n+ test 'must return sum amount of only debit transactions made by user' do\n+ user = create :user\n+ create :transaction, transaction_type: 'royalty_bonus', type: 'credit', points: 1000, user: user\n+ create :transaction, transaction_type: 'Round', type: 'credit', points: 100, user: user\n+ create :transaction, transaction_type: 'redeem_points', type: 'debit', points: 200, user: user\n+ assert_equal 10, amount_earned(user)\n+ # user becomes a sponsorer helper method should return amount according to that\n+ create :sponsorer_detail, user: user\n+ create :transaction, transaction_type: 'redeem_points', type: 'debit', points: 300, user: user\n+ assert_equal 40, amount_earned(user)\n+ end\n+\n+ test 'must return 0 if user has no debit transactions' do\n+ user = create :user\n+ create :transaction, transaction_type: 'royalty_bonus', type: 'credit', points: 1000, user: user\n+ create :transaction, transaction_type: 'Round', type: 'credit', points: 100, user: user\n+ assert_equal 0, amount_earned(user)\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
New display field earned in user profile Field to dispay, capital redeemed by user
332,093
26.09.2017 17:30:25
-19,080
ef89893f190a82da2278b7da68453f09bcd5f910
scoring job error fix
[ { "change_type": "MODIFY", "old_path": "app/jobs/scoring_job.rb", "new_path": "app/jobs/scoring_job.rb", "diff": "@@ -9,6 +9,7 @@ class ScoringJob < ActiveJob::Base\nround = Round.find(round_id)\nSidekiq.logger.info \"******************* Logger Info for Scoring Job **************************\"\n+ if repository\nSidekiq.logger.info \"Scoring for Repository: #{repository.name}, User: #{repository.owner}, Current Round: from #{round.from_date}, Type: #{type}\"\nbegin\nif type == 'commits'\n@@ -19,5 +20,8 @@ class ScoringJob < ActiveJob::Base\nrescue Mongo::Error::SocketError\nretry_job wait: 5.minutes if @retries_count < MAX_RETRY_COUNT\nend\n+ else\n+ Sidekiq.logger.info \"------------------------- Repository not Found ID: #{repository.id} ----------------------------\"\n+ end\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
scoring job error fix
332,093
08.09.2017 15:34:37
-19,080
f9bebfe18fe64c823fcebe35233d33ed1b55211c
Sort redeem requests First list redeem requests from a paid plan, then list redeem requests from a free plan.
[ { "change_type": "MODIFY", "old_path": "app/controllers/admin/redeem_requests_controller.rb", "new_path": "app/controllers/admin/redeem_requests_controller.rb", "diff": "@@ -52,7 +52,7 @@ class Admin::RedeemRequestsController < ApplicationController\ndef load_redeem_request\n@status = params[:status] || false\n- @redeem_requests = RedeemRequest.where(status: @status).desc(:created_at)\n+ @redeem_requests = RedeemRequest.where(status: @status).desc(:sponsorer_detail).desc(:created_at)\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/admin/redeem_requests/_redeem_request.html.haml", "new_path": "app/views/admin/redeem_requests/_redeem_request.html.haml", "diff": "%tr\n%td\n- - if redeem_request.user.active_sponsorer_detail\n+ - if redeem_request.user.is_sponsorer\n.badge $\n= link_to redeem_request.user.email, user_path(redeem_request.user), target: '_blank'\n%td\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Sort redeem requests First list redeem requests from a paid plan, then list redeem requests from a free plan.
332,093
29.09.2017 14:07:32
-19,080
8dec3869d0d85ad81c6fea9b49b15f6779e959b6
rake task to delete unwanted repository directories
[ { "change_type": "MODIFY", "old_path": "lib/tasks/repo.rake", "new_path": "lib/tasks/repo.rake", "diff": "@@ -27,4 +27,19 @@ namespace :repo do\nend\nend\n+ desc \"delete cloned repository whose commits got scored\"\n+ task delete_repository_dir: :environment do\n+ # get all the repository ids whose commits belong to the current round\n+ # repository_ids = Commit.pluck(:repository_id).uniq\n+ repository_ids = Round.opened.commits.pluck(:repository_id).uniq\n+ # get those repository ids whose commits from the current round are not scored yet\n+ unscored_repository_ids = Round.opened.commits.where(auto_score: nil).pluck(:repository_id).uniq\n+ # Remove all those repository directories which are not required for the current round\n+ # if their directory exists\n+ (repository_ids - unscored_repository_ids).each do |id|\n+ path = \"#{Rails.root.join(SCORING_ENGINE_CONFIG[:repositories]).to_s}/#{id}\"\n+ FileUtils.rm_r(path) if Dir.exists?(path)\n+ end\n+ end\n+\nend\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/lib/tasks/repo_test.rb", "diff": "+require 'test_helper'\n+\n+class RepoTest < ActiveSupport::TestCase\n+\n+ def setup\n+ @path = \"#{Rails.root.join(SCORING_ENGINE_CONFIG[:repositories]).to_s}\"\n+ @round = create :round, :open\n+ CodeCuriosity::Application.load_tasks\n+ Rake::Task['repo:delete_repository_dir'].reenable\n+ Dir.mkdir(\"#{@path}\") unless Dir.exists?(\"#{@path}\")\n+ end\n+\n+ test 'must not delete repository directories whose commits are not scored yet' do\n+ repo_1 = create :repository\n+ Dir.mkdir(\"#{@path}/#{repo_1.id}\")\n+ commit_1 = create :commit, auto_score: nil, repository: repo_1, round: @round\n+ commit_2 = create :commit, auto_score: nil, repository: repo_1, round: @round\n+ assert_includes Dir.entries(@path), repo_1.id.to_s\n+ Rake::Task['repo:delete_repository_dir'].invoke\n+ assert_includes Dir.entries(@path), repo_1.id.to_s\n+ end\n+\n+ test 'must delete only those repository directories whose all commits are scored' do\n+ repo_1 = create :repository\n+ repo_2 = create :repository\n+ Dir.mkdir(\"#{@path}/#{repo_1.id}\")\n+ Dir.mkdir(\"#{@path}/#{repo_2.id}\")\n+ commit_1 = create :commit, auto_score: nil, repository: repo_1, round: @round\n+ commit_2 = create :commit, auto_score: nil, repository: repo_1, round: @round\n+ commit_3 = create :commit, auto_score: nil, repository: repo_2, round: @round\n+ commit_4 = create :commit, auto_score: nil, repository: repo_2, round: @round\n+ assert_includes Dir.entries(@path), repo_1.id.to_s\n+ assert_includes Dir.entries(@path), repo_2.id.to_s\n+ commit_1.update(auto_score: 0)\n+ commit_2.update(auto_score: 0)\n+ Rake::Task['repo:delete_repository_dir'].invoke\n+ assert_not_includes Dir.entries(@path), repo_1.id.to_s\n+ assert_includes Dir.entries(@path), repo_2.id.to_s\n+ end\n+\n+ test 'must not delete repository directories whose some commits are not scored yet' do\n+ repo_1 = create :repository\n+ Dir.mkdir(\"#{@path}/#{repo_1.id}\")\n+ commit_1 = create :commit, auto_score: nil, repository: repo_1, round: @round\n+ commit_2 = create :commit, auto_score: nil, repository: repo_1, round: @round\n+ assert_includes Dir.entries(@path), repo_1.id.to_s\n+ commit_1.update(auto_score: 0)\n+ Rake::Task['repo:delete_repository_dir'].invoke\n+ assert_includes Dir.entries(@path), repo_1.id.to_s\n+ end\n+\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
rake task to delete unwanted repository directories
332,093
14.09.2017 18:50:42
-19,080
92b0a560cca7991680a1fdc19787ba428b9d17ff
Filter on admin users page
[ { "change_type": "MODIFY", "old_path": "app/assets/javascripts/admin/users.js", "new_path": "app/assets/javascripts/admin/users.js", "diff": "$(document).on('page:change', function(event) {\n+ $(function() {\n+ $('#blocked').bootstrapToggle();\n+ })\n+\n+ $('#blocked').change(function() {\n+ $('#status').val(!this.checked);\n+ $('#q').val('');\n+ $.ajax({\n+ type: 'get',\n+ url: '/admin/users',\n+ data: { 'blocked': !(this.checked) }\n+ });\n+ });\n+\n$(document).on('change', '.block', function(){\nid = this.id;\n$(\".block#\"+id).prop(\"disabled\", true);\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/admin/users_controller.rb", "new_path": "app/controllers/admin/users_controller.rb", "diff": "@@ -4,7 +4,13 @@ class Admin::UsersController < ApplicationController\nbefore_action :find_user, only: [:block_user, :destroy]\ndef index\n- @users = User.contestants.desc(:created_at).page(params[:page])\n+ @status = params[:blocked] || false\n+ @users = User.contestants.where(blocked: @status).desc(:created_at).page(params[:page])\n+ if request.xhr?\n+ respond_to do |format|\n+ format.js\n+ end\n+ end\nend\ndef mark_as_judge\n@@ -29,9 +35,9 @@ class Admin::UsersController < ApplicationController\nredirect_to admin_users_path\nreturn\nend\n-\n- @users = User.contestants.where(github_handle: /#{params[:q]}/)\n- @users = User.contestants.where(email: params[:q]) if @users.none?\n+ @status = params[:status]\n+ @users = User.contestants.where(blocked: params[:status], github_handle: /#{params[:q]}/)\n+ @users = User.contestants.where(blocked: params[:status], email: params[:q]) if @users.none?\n@users = @users.page(params[:page])\nrender :index\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "@@ -100,6 +100,7 @@ class UsersController < ApplicationController\n# So, we manipulate the UID and set auto_created: true, so that no data will be fetched.\nuser.uid = \"#{user.uid}-DELETED\"\nuser.auto_created = true\n+ user.blocked = false if user.blocked\nuser.save\nredirect_to root_url, notice: \"Your account has been deleted successfully.\"\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/admin/users/index.html.haml", "new_path": "app/views/admin/users/index.html.haml", "diff": "+%section.content-header\n+ %h1\n+ Users :-\n+ %label.slide\n+ %input#blocked{checked: !(@status == \"true\"), type: 'checkbox', data: { toggle: 'toggle', width: '80', height: '40', on: 'Allowed', off: 'Blocked' }}\n+\n%section.content\n.row\n.col-xs-12\n.box.box-primary\n.box-header\n%h3.box-title\n- %span Users:\n+ %span Contestants:\n.box-tools\n= form_tag(search_admin_users_path, method: :get, class: 'col-xs-3 col-md-4 pull-right') do\n.input-group.input-group-sm\n+ = hidden_field_tag 'status', @status\n= text_field_tag('q', params[:q], class: 'form-control pull-right', placeholder: 'github handle/email')\n.input-group-btn\n%button.btn.btn-default{type: 'submit'} Go\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/admin/users_controller_test.rb", "new_path": "test/controllers/admin/users_controller_test.rb", "diff": "@@ -39,5 +39,4 @@ class Admin::UsersControllerTest < ActionController::TestCase\nassert_equal RedeemRequest.count, 0\nassert_response :redirect\nend\n-\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Filter on admin users page
332,093
27.09.2017 19:15:30
-19,080
41568df46179347d79f16c5ca18a783de0be01bd
git cloning error rescued
[ { "change_type": "MODIFY", "old_path": "app/models/scoring_engine.rb", "new_path": "app/models/scoring_engine.rb", "diff": "@@ -29,20 +29,23 @@ class ScoringEngine\nrescue Git::GitExecuteError\n#delete the repo dir and clone again\nFileUtils.rm_r(\"#{Rails.root.join(config[:repositories]).to_s}/#{repo.id}\")\n- self.git = Git.clone(\"https://github.com/#{repo.owner}/#{repo.name}.git\", repo.id, path: Rails.root.join(config[:repositories]).to_s)\n+ # self.git = Git.clone(\"https://github.com/#{repo.owner}/#{repo.name}.git\", repo.id, path: Rails.root.join(config[:repositories]).to_s)\n+ self.git = clone_repo(repo)\nend\nelse\n- self.git = Git.clone(\"https://github.com/#{repo.owner}/#{repo.name}.git\", repo.id, path: Rails.root.join(config[:repositories]).to_s)\n+ # self.git = Git.clone(\"https://github.com/#{repo.owner}/#{repo.name}.git\", repo.id, path: Rails.root.join(config[:repositories]).to_s)\n+ self.git = clone_repo(repo)\n+ if self.git\n#gets the current repository branch. usually, is master.\nbranch = self.git.branches.local.first.name unless branch\nself.git.checkout(branch)\nend\n+ end\nself.git\nend\ndef comments_score(commit)\nreturn 0 if commit.comments_count == 0\n-\nscore = [\ncommit.comments_count/config[:comments_to_points],\nconfig[:max_score]\n@@ -68,6 +71,7 @@ class ScoringEngine\ndef bugspots_score(commit)\nreturn 0 if commit.info.nil?\nfetch_repo unless git\n+ return 0 unless git\n# search all the origin branches that holds the commit and return the branch name.\n# git branch --all --contains <sha>\n# ex., git branch --all --contains fd891813e0f4a85e4b55a25d12f6d4d7de35c90b in prasadsurase/code-curiosity\n@@ -187,4 +191,23 @@ class ScoringEngine\nend\nend\n+ private\n+ # method to clone repository if repository failed to clone it will retry for ten times\n+ # if it fails in all retries the method will return nil\n+ # sometimes git clone fails stating\n+ # No such file or directory\n+ # fatal: cannot store pack file\n+ # fatal: index-pack failed\n+ def clone_repo(repo)\n+ begin\n+ retries ||= 0\n+ Git.clone(\"https://github.com/#{repo.owner}/#{repo.name}.git\", repo.id, path: Rails.root.join(config[:repositories]).to_s)\n+ rescue Git::GitExecuteError\n+ retry if (retries += 1) < 10\n+ FileUtils.rm_r(\"#{Rails.root.join(config[:repositories]).to_s}/#{repo.id}\") if Dir.exist?(repo_dir)\n+ Sidekiq.logger.info \"Unable to clone repositoriy: #{repo.id}\"\n+ return nil\n+ end\n+ end\n+\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/scoring_engine_test.rb", "new_path": "test/models/scoring_engine_test.rb", "diff": "@@ -180,6 +180,24 @@ class ScoringEngineTest < ActiveSupport::TestCase\nassert_equal bugspot_score.round(3), scores.round(3)\nend\n+ test 'method should return nil if it is unable to clone repository' do\n+ repo = create :repository, ssh_url: 'git@github.com:prasadsurase/code-curiosity.git', owner: 'prasadsurase', name: 'code-curiosity'\n+ commit = create(:commit, message: Faker::Lorem.sentences, sha: '8a11b8031c06df55f0edf7d41aad22987a74165d', repository: repo)\n+ engine = ScoringEngine.new(repo)\n+ Git.stubs(:clone).raises(Git::GitExecuteError, {})\n+ git = engine.send(:clone_repo, repo)\n+ assert_nil git\n+ end\n+\n+ test 'method should return git if it can clone repository' do\n+ repo = create :repository, ssh_url: 'git@github.com:prasadsurase/code-curiosity.git', owner: 'prasadsurase', name: 'code-curiosity'\n+ commit = create(:commit, message: Faker::Lorem.sentences, sha: '8a11b8031c06df55f0edf7d41aad22987a74165d', repository: repo)\n+ engine = ScoringEngine.new(repo)\n+ git = engine.send(:clone_repo, repo)\n+ assert_not_nil git\n+ end\n+\n+\ndef stub_commit_for_bugspots_scoring\n@repo = create :repository, ssh_url: 'git@github.com:prasadsurase/code-curiosity.git', owner: 'prasadsurase', name: 'code-curiosity'\n@commit = create(:commit, message: Faker::Lorem.sentences, sha: '8a11b8031c06df55f0edf7d41aad22987a74165d', repository: @repo)\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
git cloning error rescued
332,093
03.10.2017 14:46:06
-19,080
a75398afe86022565b2d918cd340eaf22e25ee71
Sponsorer Image added on home page and mails
[ { "change_type": "ADD", "old_path": "app/assets/images/org-ett-logo.png", "new_path": "app/assets/images/org-ett-logo.png", "diff": "Binary files /dev/null and b/app/assets/images/org-ett-logo.png differ\n" }, { "change_type": "ADD", "old_path": "app/assets/images/org-josh-logo.png", "new_path": "app/assets/images/org-josh-logo.png", "diff": "Binary files /dev/null and b/app/assets/images/org-josh-logo.png differ\n" }, { "change_type": "MODIFY", "old_path": "app/views/home/_subscribers_list.html.haml", "new_path": "app/views/home/_subscribers_list.html.haml", "diff": ".box-header\n%h2= header\n.box-body\n+ - ORGANIZATIONAL_SPONSORERS.each do |org|\n+ .img-center\n+ = link_to image_tag(org[1][\"logo\"], class: \"img-responsive\", width: 200, height: 200, alt: \"Responsive image\"), org[1][\"link\"], target: '_blank'\n- sponsorer_group.in_groups_of(4) do |group|\n- group.each do |sponsorer|\n- if sponsorer\n" }, { "change_type": "MODIFY", "old_path": "app/views/layouts/mailer.html.haml", "new_path": "app/views/layouts/mailer.html.haml", "diff": "%tr\n%td{:bgcolor => \"#ffffff\", :height => \"100%\", :role => \"module-content\", :style => \"padding: 10px 10px 10px 10px;\", :valign => \"top\"}\n= yield :signature\n+ <center><b>Our Sponsors</b></center>\n%table.wrapper{:align => \"center\", :border => \"0\", :cellpadding => \"0\", :cellspacing => \"0\", \"data-attributes\" => \"%7B%22backgroundcolor%22%3A%22%23FFFFFF%22%2C%22iconsize%22%3A30%2C%22iconcolor%22%3A%22AUTO%22%2C%22borderradius%22%3A2%2C%22padding%22%3A%225%2C0%2C5%2C0%22%2C%22alignment%22%3A%22center%22%2C%22option_facebook%22%3A%7B%22checked%22%3Atrue%2C%22text%22%3A%22https%3A//www.facebook.com/joshsoftware%22%2C%22filename%22%3A%22facebook.png%22%2C%22title%22%3A%22Facebook%22%2C%22backgroundcolor%22%3A%22%233B579D%22%7D%2C%22option_twitter%22%3A%7B%22checked%22%3Atrue%2C%22text%22%3A%22https%3A//twitter.com/joshsoftware%22%2C%22filename%22%3A%22twitter.png%22%2C%22title%22%3A%22Twitter%22%2C%22backgroundcolor%22%3A%22%237AC4F7%22%7D%2C%22option_instagram%22%3A%7B%22checked%22%3Afalse%2C%22text%22%3A%22%22%2C%22filename%22%3A%22instagram.png%22%2C%22title%22%3A%22Instagram%22%2C%22backgroundcolor%22%3A%22%237F4B30%22%7D%2C%22option_googleplus%22%3A%7B%22checked%22%3Afalse%2C%22text%22%3A%22%22%2C%22filename%22%3A%22google-plus.png%22%2C%22title%22%3A%22Google+%22%2C%22backgroundcolor%22%3A%22%23D44132%22%7D%2C%22option_pinterest%22%3A%7B%22checked%22%3Afalse%2C%22text%22%3A%22%22%2C%22filename%22%3A%22pinterest.png%22%2C%22title%22%3A%22Pinterest%22%2C%22backgroundcolor%22%3A%22%23CB2027%22%7D%2C%22option_linkedin%22%3A%7B%22checked%22%3Atrue%2C%22text%22%3A%22https%3A//www.linkedin.com/company/josh-software-private-limited%22%2C%22filename%22%3A%22linkedin.png%22%2C%22backgroundcolor%22%3A%22%230077B5%22%7D%7D\", \"data-type\" => \"social\", :role => \"module\", :style => \"table-layout: fixed;\", :width => \"100%\"}\n+ %tr\n+ %td{:align => \"center\", :role => \"module-content\", :style => \"font-size:6px;line-height:10px;background-color:;padding: 5px 0px 5px 0px;\", :valign => \"top\"}\n+ %table{:align => \"center\", :border => \"0\", :cellpadding => \"0\", :cellspacing => \"0\", :style => \"\"}\n+ %tr\n+ %td{:style => \"padding: 0px 20px;\"}\n+ %a{:alt => \"JoshSoftware\", :border => \"0\", :href => \"http://www.joshsoftware.com/\", :role => \"social-icon-link\", :style => \"border-radius: 2px; -webkit-border-radius:2px; -moz-border-radius:2px; -ms-border-radius:2px; -o-border-radius:2px; color: white; display: inline-block; outline: none; text-decoration:none; border: none; font-family: Helvetica, arial, sans-serif;\", :target => \"_blank\", :title => \"Josh\"}\n+ %img{:alt => \"Josh\", :border => \"0\", :height => \"30\", :src => \"http://www.joshsoftware.com/assets/JOSHSoftware_LogoStack_Color_org-b7401425ee89d6448e5657436e826fb9.png\", :style => \"height: 40px; width: 130px; border:none; color: white; font-family: Helvetica, arial, sans-serif;\", :title => \"JoshSoftware\", :width => \"30\"}/\n+ %td{:style => \"padding: 0px 20px;\"}\n+ %a{:alt => \"ETT\", :border => \"0\", :href => \"https://www.facebook.com/Emerging-Technology-Trust-840341759454971/\", :role => \"social-icon-link\", :style => \" border-radius: 2px; -webkit-border-radius:2px; -moz-border-radius:2px; -ms-border-radius:2px; -o-border-radius:2px; color: white; display: inline-block; outline: none; text-decoration:none; border: none; font-family: Helvetica, arial, sans-serif;\", :target => \"_blank\", :title => \"ETT\"}\n+ %img{:alt => \"ETT\", :border => \"0\", :height => \"30\", :src => \"https://scontent-bom1-1.xx.fbcdn.net/v/t1.0-9/17991267_840341959454951_2769018118289680160_n.png?oh=7d794375d50dc7cceada4c7b1189cec2&oe=5A7FE11A\", :style => \"height: 40px; width: 140px; border:none; color: white; font-family: Helvetica, arial, sans-serif;\", :title => \"ETT\", :width => \"30\"}/\n+ %table.wrapper{:align => \"center\", :border => \"0\", :cellpadding => \"0\", :cellspacing => \"0\", \"data-attributes\" => \"%7B%22backgroundcolor%22%3A%22%23FFFFFF%22%2C%22iconsize%22%3A30%2C%22iconcolor%22%3A%22AUTO%22%2C%22borderradius%22%3A2%2C%22padding%22%3A%225%2C0%2C5%2C0%22%2C%22alignment%22%3A%22center%22%2C%22option_facebook%22%3A%7B%22checked%22%3Atrue%2C%22text%22%3A%22https%3A//www.facebook.com/joshsoftware%22%2C%22filename%22%3A%22facebook.png%22%2C%22title%22%3A%22Facebook%22%2C%22backgroundcolor%22%3A%22%233B579D%22%7D%2C%22option_twitter%22%3A%7B%22checked%22%3Atrue%2C%22text%22%3A%22https%3A//twitter.com/joshsoftware%22%2C%22filename%22%3A%22twitter.png%22%2C%22title%22%3A%22Twitter%22%2C%22backgroundcolor%22%3A%22%237AC4F7%22%7D%2C%22option_instagram%22%3A%7B%22checked%22%3Afalse%2C%22text%22%3A%22%22%2C%22filename%22%3A%22instagram.png%22%2C%22title%22%3A%22Instagram%22%2C%22backgroundcolor%22%3A%22%237F4B30%22%7D%2C%22option_googleplus%22%3A%7B%22checked%22%3Afalse%2C%22text%22%3A%22%22%2C%22filename%22%3A%22google-plus.png%22%2C%22title%22%3A%22Google+%22%2C%22backgroundcolor%22%3A%22%23D44132%22%7D%2C%22option_pinterest%22%3A%7B%22checked%22%3Afalse%2C%22text%22%3A%22%22%2C%22filename%22%3A%22pinterest.png%22%2C%22title%22%3A%22Pinterest%22%2C%22backgroundcolor%22%3A%22%23CB2027%22%7D%2C%22option_linkedin%22%3A%7B%22checked%22%3Atrue%2C%22text%22%3A%22https%3A//www.linkedin.com/company/josh-software-private-limited%22%2C%22filename%22%3A%22linkedin.png%22%2C%22backgroundcolor%22%3A%22%230077B5%22%7D%7D\", \"data-type\" => \"social\", :role => \"module\", :style => \"table-layout: fixed; margin-top: 1cm;\", :width => \"100%\"}\n%tr\n%td{:align => \"center\", :role => \"module-content\", :style => \"font-size:6px;line-height:10px;background-color:;padding: 5px 0px 5px 0px;\", :valign => \"top\"}\n%table{:align => \"center\", :border => \"0\", :cellpadding => \"0\", :cellspacing => \"0\", :style => \"\"}\n" }, { "change_type": "MODIFY", "old_path": "app/views/redeem_mailer/redeem_request.html.haml", "new_path": "app/views/redeem_mailer/redeem_request.html.haml", "diff": "- content_for :signature do\n= render 'application/mail_signature'\n-\n%h4= \"Hello #{@user.name},\"\n%p\nYour redemption request has been received. We will process your request and send you a coupon code as soon as possible.\n" }, { "change_type": "MODIFY", "old_path": "config/code_curiosity_config.yml", "new_path": "config/code_curiosity_config.yml", "diff": "@@ -33,6 +33,14 @@ redeem_request_threshold:\nfree: 400\npaid: 500\n+organizational_sponsorers:\n+ josh:\n+ logo: \"org-josh-logo.png\"\n+ link: \"http://www.joshsoftware.com\"\n+ ett:\n+ logo: \"org-ett-logo.png\"\n+ link: \"https://www.facebook.com/Emerging-Technology-Trust-840341759454971/\"\n+\nscoring_engine:\n:repositories: 'repositories' # repositories dir\n:max_score: 5\n" }, { "change_type": "MODIFY", "old_path": "config/initializers/globals.rb", "new_path": "config/initializers/globals.rb", "diff": "@@ -15,6 +15,7 @@ YAML.load_file('config/code_curiosity_config.yml').tap do |config|\nSPONSORER_THRESHOLD = config['sponsor_display_threshold']\nREDEEM_THRESHOLD = config['redeem_request_threshold']\nACCOUNT = config['account']\n+ ORGANIZATIONAL_SPONSORERS = config['organizational_sponsorers']\nend\nCOMMIT_RATINGS = (0..5).to_a\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Sponsorer Image added on home page and mails
332,093
03.10.2017 18:31:27
-19,080
cdf1c2e10b4e6a69364e643b98bea37017ef4fb7
fixed sponsorer image size error on home page
[ { "change_type": "MODIFY", "old_path": "app/views/home/_subscribers_list.html.haml", "new_path": "app/views/home/_subscribers_list.html.haml", "diff": ".box-header\n%h2= header\n.box-body\n+ - if organization\n- ORGANIZATIONAL_SPONSORERS.each do |org|\n.img-center\n- = link_to image_tag(org[1][\"logo\"], class: \"img-responsive\", width: 200, height: 200, alt: \"Responsive image\"), org[1][\"link\"], target: '_blank'\n+ = link_to image_tag(org[1][\"logo\"], class: \"img-responsive\", width: 180, height: 180, alt: \"Responsive image\"), org[1][\"link\"], target: '_blank'\n- sponsorer_group.in_groups_of(4) do |group|\n- group.each do |sponsorer|\n- if sponsorer\n.img-center\n- = link_to image_tag( select_avatar(sponsorer), class: \"img-responsive\", width: 130, height: 130, alt: \"Responsive image\"), redirect(sponsorer)\n+ = link_to image_tag( select_avatar(sponsorer), class: \"img-responsive\", width: 180, height: 180, alt: \"Responsive image\"), redirect(sponsorer)\n" }, { "change_type": "MODIFY", "old_path": "app/views/home/index.html.haml", "new_path": "app/views/home/index.html.haml", "diff": "= render partial: 'info', collection: data, as: 'info'\n.row.marketing\n- if @sponsorer_organizations.count >= SPONSORER_THRESHOLD['organization']\n- = render partial: 'subscribers_list', locals: {header: \"Organization Sponsors\", sponsorer_group: @sponsorer_organizations}\n+ = render partial: 'subscribers_list', locals: {header: \"Organization Sponsors\", sponsorer_group: @sponsorer_organizations, organization: true}\n- if @sponsorer_users.count >= SPONSORER_THRESHOLD['individual']\n- = render partial: 'subscribers_list', locals: {header: \"Individual Sponsors\", sponsorer_group: @sponsorer_users}\n+ = render partial: 'subscribers_list', locals: {header: \"Individual Sponsors\", sponsorer_group: @sponsorer_users, organization: false}\n.row.marketing#sponsor\n= render 'sponsorer_benefits'\n- if @size > 0\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
fixed sponsorer image size error on home page
332,093
10.10.2017 18:58:24
-19,080
9c583d4d0d6ee20ca1cecf39c59834adca6478b0
Added logger statements in UserReposJob
[ { "change_type": "MODIFY", "old_path": "app/jobs/user_repos_job.rb", "new_path": "app/jobs/user_repos_job.rb", "diff": "@@ -5,6 +5,9 @@ class UserReposJob < ActiveJob::Base\nattr_accessor :user\nrescue_from(StandardError) do |exception|\n+ Sidekiq.logger.info \"**************************************Exception *******************************\"\n+ Sidekiq.logger.info \"User: #{user.github_handle}\"\n+ Sidekiq.logger.info \"Exception: #{exception.inspect}\"\nuser.set(last_repo_sync_at: nil) if user\nend\n@@ -17,6 +20,7 @@ class UserReposJob < ActiveJob::Base\nSidekiq.logger.info \"************************* UserReposJob Logger Info ***************************\"\nSidekiq.logger.info \"Syncing repositories of #{user.github_handle}\"\n+ Sidekiq.logger.info \"Last repository sync at: #{user.last_repo_sync_at}\"\ngh_repos = user.fetch_all_github_repos\n@@ -56,6 +60,7 @@ class UserReposJob < ActiveJob::Base\nend\nrepo = Repository.build_from_gh_info(gh_repo)\n+ Sidekiq.logger.info \"Repository INFO: Name: #{repo.name} | Stars: #{repo.stars} \"\nif repo.stars >= REPOSITORY_CONFIG['popular']['stars']\nuser.repositories << repo\n@@ -71,7 +76,6 @@ class UserReposJob < ActiveJob::Base\nrepo.source_gh_id = repo.info.source.id\nuser.repositories << repo\nuser.save\n- Sidekiq.logger.info \"Persisted popular repository #{repo.name} for user #{user.github_handle\n- }\"\n+ Sidekiq.logger.info \"Persisted popular repository #{repo.name} for user #{user.github_handle}\"\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Added logger statements in UserReposJob
332,109
01.11.2017 12:03:54
-19,080
bf915c683079a2473f27a976aa5ed6921b694fdd
Removed the logic to recalculate the royal bonus on resignup
[ { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -197,14 +197,17 @@ class User\nend\nif royalty_points > 0\n+ self.transactions.create(points: royalty_points, transaction_type: 'royalty_bonus', type: 'credit')\n+=begin\nroyalty_bonuses = self.transactions.where(transaction_type: 'royalty_bonus', type: 'credit')\nself.transactions.create(\npoints: royalty_bonuses.any? ? royalty_points - royalty_bonuses.sum(:points) : royalty_points,\ntransaction_type: 'royalty_bonus', type: 'credit'\n)\n+=end\nend\n- self.points = total_points\n+ self.points = royalty_points\nself.save\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -171,6 +171,7 @@ class UserTest < ActiveSupport::TestCase\nassert_equal 500, transaction.points\nassert_equal 500, user.total_points\n+=begin\nredeem_request_1 = create(:redeem_request, points: 100, address: 'baner', user: user)\nredeem_request_2 = create(:redeem_request, points: 250, address: 'baner', user: user)\nassert_equal 3, user.transactions.count\n@@ -192,6 +193,7 @@ class UserTest < ActiveSupport::TestCase\nassert_equal 'royalty_bonus', transaction.transaction_type\nassert_equal 300, transaction.points\nassert_equal 550, user.total_points\n+=end\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed the logic to recalculate the royal bonus on resignup
332,093
01.11.2017 16:10:10
-19,080
f8f92d0dd07c449d88b2f916b42c42e108e6fa63
Bonus points pertaining to each goal updated
[ { "change_type": "MODIFY", "old_path": "config/goals.yml", "new_path": "config/goals.yml", "diff": "goals:\nHiker:\npoints: 15\n- bonus_points: 20\n+ bonus_points: 5\nimage_url:\ndescription: \"I think I can earn %{points} in a month\"\nredeem_text: \"Redeem 50 points (~5$) and gift yourself a pack of Github <a href='https://github.myshopify.com/products/octodex-sticker-packs' target='_blank'>stickers</a> or <a href='https://github.myshopify.com/products/atom-coasters' target='_blank'>coasters</a>!\"\nMountaineer:\npoints: 50\n- bonus_points: 75\n+ bonus_points: 15\nimage_url:\ndescription: \"I'm good! Let me target %{points} for this month\"\nredeem_text: \"Redeem 250 points (~25$) and gift yourself a <a href='https://github.myshopify.com/products/github-username-shirt' target='_blank'>tshirt</a> or <a href='https://github.myshopify.com/products/github-mug' target='_blank'>mug</a> or something similar\"\nRover:\npoints: 200\n- bonus_points: 250\n+ bonus_points: 50\nimage_url:\ndescription: \"I'm reaching for Mars! Let me target %{points}!\"\nredeem_text: \"Redeem 550 points (~55$) and gift yourself a Github <a href='https://github.myshopify.com/products/invertocat-hoodie' target='_blank'>hoodie</a>\"\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Bonus points pertaining to each goal updated
332,093
02.11.2017 16:26:35
-19,080
4cd65a8b50e928cb4ff419f385b0516ab9cdabc9
Fixed redeem request amount error when retailer is other
[ { "change_type": "MODIFY", "old_path": "app/models/redeem_request.rb", "new_path": "app/models/redeem_request.rb", "diff": "@@ -6,7 +6,7 @@ class RedeemRequest\nfield :coupon_code, type: String\nfield :status, type: Boolean, default: false\nfield :points, type: Integer\n- field :amount, type: Integer\n+ field :amount, type: Float\nfield :retailer, type: String, default: REDEEM['retailers'].first\nfield :store, type: String\nfield :address, type: String\n@@ -55,7 +55,8 @@ class RedeemRequest\ndef update_transaction_points\nif points.to_i > 0\n- self.transaction.update(points: points)\n+ update_amount\n+ self.transaction.update(points: points, amount: amount)\nself.user.update(points: self.user.total_points)\nend\nend\n@@ -203,6 +204,15 @@ class RedeemRequest\nelse\nREDEEM['one_dollar_to_points'] * 2\nend\n- self.amount = points/denominator\n+ self.amount = points.to_f/denominator\n+ end\n+\n+ def update_amount\n+ denominator = if sponsorer_detail\n+ REDEEM['one_dollar_to_points']\n+ else\n+ REDEEM['one_dollar_to_points'] * 2\n+ end\n+ self.set(amount: points.to_f/denominator)\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/transaction.rb", "new_path": "app/models/transaction.rb", "diff": "@@ -23,6 +23,7 @@ class Transaction\nbefore_save do |t|\nt.points = t.credit? ? t.points.abs : -(t.points.abs)\n+ t.amount = t.credit? ? t.amount.abs : -(t.amount.abs)\nend\nafter_create :update_user_total_points\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/admin/redeem_requests_controller_test.rb", "new_path": "test/controllers/admin/redeem_requests_controller_test.rb", "diff": "@@ -158,6 +158,39 @@ class Admin::RedeemRequestsControllerTest < ActionController::TestCase\nassert_not_includes assigns(:redeem_requests), redeem_request\nend\n+ test \"when redeem_request is updated update redeem_request amount\" do\n+ seed_data\n+ create(:transaction, :type => 'credit', :points => 200, user: @user)\n+ redeem_request = create(:redeem_request, store: nil, retailer: 'other',\n+ address: \"House Number-168/17A, Freehold\\r\\nNear Shatabdi Public School\\r\\nSector-23,Sanjay Nagar\\r\\nGhaziabad-201002\", gift_product_url: \"https://github.myshopify.com/products/arctocat\", points: 0, user: @user)\n+ assert_equal 1, RedeemRequest.count\n+ assert_equal 0, RedeemRequest.first.amount\n+ patch :update, id: redeem_request.id, redeem_request: {points: 300, coupon_code: \"Order #67981\"}\n+ assert_equal 15, RedeemRequest.first.amount\n+ end\n+\n+ test \"when redeem_request is updated update redeem_request amount in ratio 1:10 points if redeem_request has sponsorer_detail\" do\n+ seed_data\n+ sponsorer_detail = create(:sponsorer_detail)\n+ create(:transaction, :type => 'credit', :points => 1000, user: @user)\n+ redeem_request = create(:redeem_request, store: nil, retailer: 'other',\n+ address: \"House Number-168/17A, Freehold\\r\\nNear Shatabdi Public School\\r\\nSector-23,Sanjay Nagar\\r\\nGhaziabad-201002\", gift_product_url: \"https://github.myshopify.com/products/arctocat\", points: 0, sponsorer_detail: sponsorer_detail, user: @user)\n+ assert_equal 1, RedeemRequest.count\n+ assert_equal 0, RedeemRequest.first.amount\n+ patch :update, id: redeem_request.id, redeem_request: {points: 300, coupon_code: \"Order #67981\"}\n+ assert_equal 30, RedeemRequest.first.amount\n+ end\n+\n+ test \"when redeem_request is updated update redeem_request amount in ratio 1:20 points if redeem_request has no sponsorer_detail\" do\n+ seed_data\n+ create(:transaction, :type => 'credit', :points => 200, user: @user)\n+ redeem_request = create(:redeem_request, store: nil, retailer: 'other',\n+ address: \"House Number-168/17A, Freehold\\r\\nNear Shatabdi Public School\\r\\nSector-23,Sanjay Nagar\\r\\nGhaziabad-201002\", gift_product_url: \"https://github.myshopify.com/products/arctocat\", points: 0, user: @user)\n+ assert_equal 1, RedeemRequest.count\n+ assert_equal 0, RedeemRequest.first.amount\n+ patch :update, id: redeem_request.id, redeem_request: {points: 300, coupon_code: \"Order #67981\"}\n+ assert_equal 15, RedeemRequest.first.amount\n+ end\ndef seed_data\nround = create(:round, :status => 'open')\nrole = create(:role, :name => 'Admin')\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fixed redeem request amount error when retailer is other
332,109
09.11.2017 18:56:38
-19,080
f8331bcf58da73921609d6750422d4ef3073af39
Updated ActivitiesFetcher to retrieve repo info using id Currently, we are retrieving repo info using username and reponame. This fails if the repo is transfered to another user.
[ { "change_type": "MODIFY", "old_path": "app/models/activities_fetcher.rb", "new_path": "app/models/activities_fetcher.rb", "diff": "@@ -21,7 +21,7 @@ class ActivitiesFetcher\nactivities.each do |a|\nif TRACKING_EVENTS.key?(a.type) && Time.parse(a.created_at) > since_time\nrepo = Repository.where(gh_id: a.repo.id).first\n- repo = self.create_repo(a.repo.name) unless repo\n+ repo = self.create_repo(a.repo.id) unless repo\ncreate_activity(a, repo) if repo && !repo.ignore\nend\nend\n@@ -45,8 +45,8 @@ class ActivitiesFetcher\nuser_activity.save\nend\n- def create_repo(repo_name)\n- info = user.gh_client.repos.get(*repo_name.split('/'))\n+ def create_repo(repo_id)\n+ info = user.gh_client.repos.get_by_id(repo_id)\nif info.stargazers_count >= REPOSITORY_CONFIG['popular']['stars']\nrepo = Repository.build_from_gh_info(info)\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Updated ActivitiesFetcher to retrieve repo info using id (#126) Currently, we are retrieving repo info using username and reponame. This fails if the repo is transfered to another user.
332,100
09.11.2017 18:59:26
-19,080
c3fe1867bd2df4fea1802e6588925c0db1a13ef0
Fixes bug in UsersController#show if user not found
[ { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "@@ -9,12 +9,12 @@ class UsersController < ApplicationController\ndef show\n@user = User.find(params[:id])\n+ if @user\n@show_transactions = current_user == @user\ncontribution_data(@user)\n- if @user\nrender layout: current_user ? 'application' : 'public'\nelse\n- redirect_to root_url, notice: 'Invalid user name'\n+ redirect_to root_url, alert: I18n.t('user.not_exist_in_system')\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fixes bug in UsersController#show if user not found (#384)
332,093
06.02.2018 20:15:16
-19,080
873b1ecabdcd4d23ebb13ac955e118432d73dbce
reset redeem_points mailer subject
[ { "change_type": "MODIFY", "old_path": "app/mailers/subscription_mailer.rb", "new_path": "app/mailers/subscription_mailer.rb", "diff": "@@ -23,7 +23,7 @@ class SubscriptionMailer < ApplicationMailer\n@user = user\n@message = message\n- mail(to: user.email, subject: \"[CODECURIOSITY] Terms of Service has changed. Please support our dream\")\n+ mail(to: user.email, subject: \"[CODECURIOSITY] Your points for the month of #{Date.today.strftime(\"%B\")}!\")\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
reset redeem_points mailer subject
332,093
15.02.2018 16:17:20
-19,080
7a7fdd26787c5505b4efc9360ff3050dd180423e
Update github_api gem
[ { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -18,7 +18,8 @@ gem 'jquery-rails'\ngem 'turbolinks', '~>2.5'\ngem 'jbuilder', '~> 2.0'\ngem 'sdoc', '~> 0.4.0', group: :doc\n-gem 'github_api', git: 'https://github.com/prasadsurase/github.git', branch: 'add-redirection-support'\n+gem 'github_api', '~> 0.18.2'\n+gem 'hashie', '~> 3.5'\ngem 'devise', '~> 3.5'\ngem 'highcharts-rails', '~> 4.2', '>= 4.2.5'\ngem 'bootstrap-datepicker-rails'\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -13,19 +13,6 @@ GIT\nspecs:\nrugged (0.25.0b8)\n-GIT\n- remote: https://github.com/prasadsurase/github.git\n- revision: a019aff34aa31a662c5e21439d8f81593dcba352\n- branch: add-redirection-support\n- specs:\n- github_api (0.14.5)\n- addressable (~> 2.4.0)\n- descendants_tracker (~> 0.0.4)\n- faraday (~> 0.8, < 0.10)\n- faraday_middleware (= 0.10.0)\n- hashie (>= 3.4)\n- oauth2 (~> 1.0)\n-\nGIT\nremote: https://github.com/prasadsurase/ruby-git.git\nrevision: 1f26c1c4cc50f183a54ce1e42efcc3762fbdaaa1\n@@ -151,10 +138,14 @@ GEM\ni18n (~> 0.5)\nfaraday (0.9.2)\nmultipart-post (>= 1.2, < 3)\n- faraday_middleware (0.10.0)\n- faraday (>= 0.7.4, < 0.10)\nfont-awesome-rails (4.6.3.1)\nrailties (>= 3.2, < 5.1)\n+ github_api (0.18.2)\n+ addressable (~> 2.4)\n+ descendants_tracker (~> 0.0.4)\n+ faraday (~> 0.8)\n+ hashie (~> 3.5, >= 3.5.2)\n+ oauth2 (~> 1.0)\nglobalid (0.3.7)\nactivesupport (>= 4.1.0)\nhaml (4.0.7)\n@@ -166,7 +157,7 @@ GEM\nhtml2haml (>= 1.0.1)\nrailties (>= 4.0.1)\nhashdiff (0.3.0)\n- hashie (3.4.4)\n+ hashie (3.5.7)\nhighcharts-rails (4.2.5)\nrailties (>= 3.1)\nhtml2haml (2.0.0)\n@@ -469,9 +460,10 @@ DEPENDENCIES\nfaker (~> 1.6.1)\nfont-awesome-rails\ngit!\n- github_api!\n+ github_api (~> 0.18.2)\nhaml\nhaml-rails\n+ hashie (~> 3.5)\nhighcharts-rails (~> 4.2, >= 4.2.5)\njbuilder (~> 2.0)\njquery-rails\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Update github_api gem
332,091
28.02.2018 22:08:35
-19,080
450471a9b3b881386aee59906a481ab143372357
Upgrade account of offer winner users on signin without CC details
[ { "change_type": "ADD", "old_path": null, "new_path": "app/models/offer.rb", "diff": "+class Offer\n+ include Mongoid::Document\n+\n+ field :name, type: String, default: \"\"\n+ field :email, type: String, default: \"\"\n+ field :active_from, type: Date\n+\n+ validates :email, :name, :active_from, presence: true\n+\n+\n+ def self.is_winner?(user)\n+ Offer.where(:email => user.email, :active_from.lte => Date.today).present?\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -119,6 +119,10 @@ class User\n# for auto_created users, we need to invoke the after_create callback.\nuser.calculate_popularity unless user.current_subscription\n+ if Offer.is_winner?(user)\n+ user.upgrade_account unless user.active_sponsorer_detail\n+ end\n+\nuser\nend\n@@ -275,4 +279,12 @@ class User\nend\nend\n+\n+ def upgrade_account\n+ sponsorer_details.create(\n+ sponsorer_type: 'INDIVIDUAL',\n+ subscription_status: 'active',\n+ payment_plan: SPONSOR['individual'].keys.first,\n+ )\n+ end\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -196,4 +196,24 @@ class UserTest < ActiveSupport::TestCase\n=end\nend\n+ test 'upgrade account if user is offer winner' do\n+ round = create :round, :open\n+ offer = Offer.create(\n+ email: 'test@test.com',\n+ name: 'test_user',\n+ active_from: Date.today + 5.day\n+ )\n+ omniauthentication\n+ user = User.find_by name: 'test_user'\n+ assert_equal user.active_sponsorer_detail, nil\n+\n+ offer.update_attributes(active_from: Date.today)\n+ omniauthentication\n+ assert_equal !!user.active_sponsorer_detail, true\n+ assert_equal user.sponsorer_details.count, 1\n+\n+ omniauthentication\n+ assert_equal user.sponsorer_details.count, 1\n+ end\n+\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Upgrade account of offer winner users on signin without CC details
332,091
28.02.2018 22:35:00
-19,080
a2c42eb8c59d02d205324a7b04ba0fabf6536e28
Subscription page changes for offer winners
[ { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -265,7 +265,7 @@ class User\nend\ndef sponsorer_detail\n- sponsorer_details.asc(:created_at).last\n+ sponsorer_details.where(:stripe_customer_id.ne => nil).asc(:created_at).last\nend\ndef append_twitter_prefix\n" }, { "change_type": "MODIFY", "old_path": "app/views/sponsorer_details/index.html.haml", "new_path": "app/views/sponsorer_details/index.html.haml", "diff": "%i.fa.fa-github\n= @user.github_handle\n+\n+ - if Offer.is_winner?(current_user)\n+ %h3 Congratulation!! You have been upgraded to a Paid Subscriber from 1st March till 1st June, 2018.\n+ - else\n.col-sm-9\n.nav-tabs-custom\n%ul.nav.nav-tabs\n= link_to \"Terms of Service\", \"/Terms_of_service_CodeCuriosity.pdf\"\ncarefully.\n- - if @sponsor.nil?\n+ - if @sponsor.nil? && !Offer.is_winner?(current_user)\n.row.marketing#sponsor\n= render 'home/sponsorer_benefits'\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Subscription page changes for offer winners
332,090
12.03.2018 16:26:56
-19,080
62eb395c17fd3a5f5e1e4f4b2ea46494a815d590
commits fetch error fixed
[ { "change_type": "MODIFY", "old_path": "app/models/commits_fetcher.rb", "new_path": "app/models/commits_fetcher.rb", "diff": "@@ -9,7 +9,7 @@ class CommitsFetcher\nend\ndef fetch(type = :daily)\n- user.gh_client.repos.branches(repo.owner, repo.name, {auto_pagination: true}).each do |branch|\n+ user.gh_client.repos.branches(user: repo.owner, repo: repo.name).list.each do |branch|\n# Refer to issue https://rollbar.com/JoshSoftware/CodeCuriosity/items/8/\n# This is a quick fix where we ignore branches / repos that have moved.\n# This is related to https://github.com/piotrmurach/github/pull/258 and\n" }, { "change_type": "MODIFY", "old_path": "test/models/commits_fetcher_test.rb", "new_path": "test/models/commits_fetcher_test.rb", "diff": "@@ -26,7 +26,7 @@ class CommitsFetcherTest < ActiveSupport::TestCase\nend\ntest 'fetch daily' do\n- Github::Client::Repos.any_instance.stubs(:branches).returns(['master'])\n+ Github::Client::Repos::Branches.any_instance.stubs(:list).returns(['master'])\nCommitsFetcher.any_instance.stubs(:branch_commits).with('master').returns(true)\ncommits_fetcher = CommitsFetcher.new(@repo, @user, @round)\ncommits_fetcher.fetch(:daily)\n@@ -34,7 +34,7 @@ class CommitsFetcherTest < ActiveSupport::TestCase\nend\ntest 'fetch all' do\n- Github::Client::Repos.any_instance.stubs(:branches).returns(['master'])\n+ Github::Client::Repos::Branches.any_instance.stubs(:list).returns(['master'])\nCommitsFetcher.any_instance.stubs(:branch_commits).with('master', :all).returns(true)\ncommits_fetcher = CommitsFetcher.new(@repo, @user, @round)\ncommits_fetcher.fetch(:all)\n@@ -54,7 +54,7 @@ class CommitsFetcherTest < ActiveSupport::TestCase\nfile_path = 'test/fixtures/commit-daily.json'\n@commits = JSON.parse(File.read(file_path)).collect{|i| Hashie::Mash.new(i)}\nTimecop.freeze(Time.parse(@commits.first.commit.committer.date))\n- Github::Client::Repos.any_instance.stubs(:branches).returns([branch])\n+ Github::Client::Repos::Branches.any_instance.stubs(:list).returns([branch])\nassert_equal 1, @commits.select{|i| i.commit.author.date >= (Time.now - 30.hours)}.count\nquery_params = { author: 'prasadsurase', sha: 'master', since: (Time.now - 30.hours), 'until' => @round.end_date.end_of_day }\nstub_get('/repos/prasadsurase/code-curiosity/commits').with(query: query_params).to_return(\n@@ -93,7 +93,7 @@ class CommitsFetcherTest < ActiveSupport::TestCase\nheaders: {content_type: \"application/json; charset=utf-8\"}\n)\n- Github::Client::Repos.any_instance.stubs(:branches).returns([branch])\n+ Github::Client::Repos::Branches.any_instance.stubs(:list).returns([branch])\nassert_equal 17, @commits.select{|i| i.commit.author.date >= @round.from_date.beginning_of_day}.count\ncommits_fetcher = CommitsFetcher.new(@repo, @user, @round)\ncommits_fetcher.fetch(:all)\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
commits fetch error fixed
332,090
14.03.2018 19:16:46
-19,080
32d889533203ed022d2d4f346a8132b192793b2f
fetch all github repos of user
[ { "change_type": "MODIFY", "old_path": "app/models/concerns/user_github_helper.rb", "new_path": "app/models/concerns/user_github_helper.rb", "diff": "@@ -27,7 +27,7 @@ module UserGithubHelper\ndef fetch_all_github_repos\nall_repos = []\n- gh_client.repos.list(per_page: 100).each_page do |repos|\n+ gh_client.repos(user: github_handle).list(per_page: 100).each_page do |repos|\nrepos.each{|r| all_repos << r }\n# hashie warning on concat\n# all_repos.concat(repos)\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
fetch all github repos of user
332,090
14.03.2018 19:34:17
-19,080
b4a8b8b852ba7c66463387b47f9654b7eeb8c2c9
add update points task
[ { "change_type": "ADD", "old_path": null, "new_path": "lib/tasks/update_points.rake", "diff": "+namespace :update_points do\n+ desc 'fetch commits and activities and perform scoring'\n+ task :fetch_and_score, [:user, :round] => :environment do |t, args|\n+ round = Round.find(args[:round]) if args[:round].present?\n+ user = User.find(args[:user]) if args[:user].present?\n+ type = 'all'\n+\n+ ActivityJob.perform_now(user.id.to_s, type, round.id.to_s)\n+\n+ user.repositories.required.each do |repo|\n+ CommitJob.perform_now(user.id.to_s, type, repo.id.to_s)\n+ end\n+\n+ activities_repo_ids = Activity.where(auto_score: nil, round: round, user: user)\n+ .distinct(:repository_id)\n+ Repository.find(activities_repo_ids).each do |repo|\n+ ScoringJob.perform_later(repo.id.to_s, round.id.to_s, 'activities')\n+ end\n+\n+ commits_repo_ids = Commit.where(auto_score: nil, round: round, user: user)\n+ .distinct(:repository_id)\n+ Repository.find(commits_repo_ids).each do |repo|\n+ ScoringJob.perform_later(repo.id.to_s, round.id.to_s, 'commits')\n+ end\n+ end\n+\n+ desc 'update total points'\n+ task :total_points, [:user, :round] => :environment do |t, args|\n+ round = Round.find(args[:round]) if args[:round].present?\n+ user = User.find(args[:user]) if args[:user].present?\n+\n+ round.subscriptions.where(user_id: user.id).each(&:update_points)\n+\n+ subscription = user.subscriptions.where(round_id: round.id).first\n+ subscription.credit_points if subscription\n+\n+ user.set(points: user.total_points)\n+ end\n+end\n\\ No newline at end of file\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
add update points task
332,090
15.03.2018 17:54:22
-19,080
1849fd6166eff3c25f2e3a8534b14cca675338c1
passing round while creating commits and activities
[ { "change_type": "MODIFY", "old_path": "app/models/activities_fetcher.rb", "new_path": "app/models/activities_fetcher.rb", "diff": "@@ -42,6 +42,7 @@ class ActivitiesFetcher\nuser_activity.user = user\nuser_activity.repository = repo\nuser_activity.organization_id = repo.organization_id\n+ user_activity.round = round\nuser_activity.save\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/activity.rb", "new_path": "app/models/activity.rb", "diff": "@@ -79,7 +79,7 @@ class Activity\n# instead of the last month. However, it will impact scoring and bonus points. Keeping this\n# line commented in case we find a better fix. - Gautam\n- self.round = Round.opened\n+ self.round = Round.opened unless self.round\n#self.round = Round.where(:from_date.lte => commented_on, :end_date.gte => commented_on).first unless self.round\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -65,7 +65,7 @@ class Commit\n# line commented in case we find a better fix. - Gautam\n#self.round = Round.where(:from_date.lte => commit_date, :end_date.gte => commit_date).first unless self.round\n- self.round = Round.opened\n+ self.round = Round.opened unless self.round\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/commits_fetcher.rb", "new_path": "app/models/commits_fetcher.rb", "diff": "@@ -55,6 +55,7 @@ class CommitsFetcher\ncommit.html_url = data['html_url']\ncommit.comments_count = data['commit']['comment_count']\ncommit.organization_id = repo.organization_id\n+ commit.round = round\ncommit.save\nend\n" }, { "change_type": "MODIFY", "old_path": "lib/tasks/update_points.rake", "new_path": "lib/tasks/update_points.rake", "diff": "@@ -8,7 +8,7 @@ namespace :update_points do\nActivityJob.perform_now(user.id.to_s, type, round.id.to_s)\nuser.repositories.required.each do |repo|\n- CommitJob.perform_now(user.id.to_s, type, repo.id.to_s)\n+ CommitJob.perform_now(user.id.to_s, type, repo.id.to_s, round.id.to_s)\nend\nactivities_repo_ids = Activity.where(auto_score: nil, round: round, user: user)\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
passing round while creating commits and activities
332,090
19.03.2018 16:31:35
-19,080
e926b120658b5e85dfc7202fd5685ce074510d42
add end time of round
[ { "change_type": "MODIFY", "old_path": "app/models/activities_fetcher.rb", "new_path": "app/models/activities_fetcher.rb", "diff": "@@ -15,11 +15,12 @@ class ActivitiesFetcher\nround.from_date.beginning_of_day\nend\n+ end_time = round.end_date.try(:end_of_day) || Date.today.end_of_day\n#repos = user.repositories.inject({}){|o, r| o[r.gh_id] = r; o}\nactivities = user.gh_client.activity.events.performed(user.github_handle, auto_pagination: true)\nactivities.each do |a|\n- if TRACKING_EVENTS.key?(a.type) && Time.parse(a.created_at) > since_time\n+ if TRACKING_EVENTS.key?(a.type) && (Time.parse(a.created_at)).between?(since_time, end_time)\nrepo = Repository.where(gh_id: a.repo.id).first\nrepo = self.create_repo(a.repo.id) unless repo\ncreate_activity(a, repo) if repo && !repo.ignore\n" }, { "change_type": "MODIFY", "old_path": "test/fixtures/activities.json", "new_path": "test/fixtures/activities.json", "diff": "\"created_at\": \"2016-09-26T10:33:34Z\",\n\"updated_at\": \"2016-09-26T10:54:10Z\",\n\"closed_at\": null,\n- \"body\": \"I'm working on my very first test using FactoryGirl, rspec and Capybara, and I was wondering: How do I pass a freshly created object to its testing method ?\\r\\n\\r\\nSo far I managed to create my factories, and my test. It creates a user, assigns him an ```onboard_token```, and then visits my page. On controller side, I'm retrieving the User with the ```find_by_onboard_token``` method.\\r\\n\\r\\nThe problem is, it cannot find such a user\\r\\n```\\r\\ntoken = params[:token]\\r\\n!User.where(onboard_token: token).empty?\\r\\n```\\r\\nI made sure ```params[:token]``` was present, but still, it's kinda hard to figure out the relationship between objects created in tests and their match in controller.\\r\\n\\r\\nHere is my test:\\r\\n```rb\\r\\n\\r\\nRSpec.describe UsersController, type: :controller do\\r\\n render_views\\r\\n\\r\\n before(:each) do\\r\\n @user = FactoryGirl.create(:user)\\r\\n sign_in @user\\r\\n end\\r\\n\\r\\n describe \\\"GET #onboard\\\", :js => true do\\r\\n\\r\\n it \\\"simulates creator onboard\\\" do\\r\\n visit onboard_path(:token => @user.onboard_token)\\r\\n page.execute_script('$(\\\\'.two-parts-slide\\\\').css(\\\\'margin-left\\\\', \\\\'-100%\\\\');')\\r\\n fill_in('whoami', with: 'Test Model')\\r\\n fill_in('whoami2', with: 'Test Model')\\r\\n fill_in('pw1', with: '12345678')\\r\\n fill_in('pw2', with: '12345678')\\r\\n if page.has_selector?('#agreeterms')\\r\\n page.execute_script('$(\\\\'#agreeterms\\\\').prop(\\\\'checked\\\\', true);')\\r\\n else\\r\\n find('#agreeterms', :match == :first).trigger('click')\\r\\n end\\r\\n page.execute_script('$(\\\\'#submit-welcome\\\\').click();')\\r\\n expect(@user.active).to eq(true)\\r\\n end\\r\\n end\\r\\n\\r\\n\\r\\nend\\r\\n\\r\\n\\r\\n```\\r\\n\\r\\nNow, I'm not even sure this comes from FactoryGirl, it might as well just come from my lack of experience with tests. Sorry if this sounds silly !\\r\\n\"\n+ \"body\": \"I'm working on my very first test using FactoryGirl, rspec and Capybara, and I was wondering: How do I pass a freshly created object to its testing method ?\\r\\n\\r\\nSo far I managed to create my factories, and my test. It creates a user, assigns him an ```onboard_token```, and then visits my page. On controller side, I'm retrieving the User with the ```find_by_onboard_token``` method.\\r\\n\\r\\nThe problem is, it cannot find such a user\\r\\n```\\r\\ntoken = params[:token]\\r\\n!User.where(onboard_token: token).empty?\\r\\n```\\r\\nI made sure ```params[:token]``` was present, but still, it's kinda hard to figure out the relationship between objects created in tests and their match in controller.\\r\\n\\r\\nHere is my test:\\r\\n```rb\\r\\n\\r\\nRSpec.describe UsersController, type: :controller do\\r\\n render_views\\r\\n\\r\\n before(:each) do\\r\\n @user = FactoryGirl.create(:user)\\r\\n sign_in @user\\r\\n end\\r\\n\\r\\n describe \\\"GET #onboard\\\", :js : true do\\r\\n\\r\\n it \\\"simulates creator onboard\\\" do\\r\\n visit onboard_path(:token : @user.onboard_token)\\r\\n page.execute_script('$(\\\\'.two-parts-slide\\\\').css(\\\\'margin-left\\\\', \\\\'-100%\\\\');')\\r\\n fill_in('whoami', with: 'Test Model')\\r\\n fill_in('whoami2', with: 'Test Model')\\r\\n fill_in('pw1', with: '12345678')\\r\\n fill_in('pw2', with: '12345678')\\r\\n if page.has_selector?('#agreeterms')\\r\\n page.execute_script('$(\\\\'#agreeterms\\\\').prop(\\\\'checked\\\\', true);')\\r\\n else\\r\\n find('#agreeterms', :match == :first).trigger('click')\\r\\n end\\r\\n page.execute_script('$(\\\\'#submit-welcome\\\\').click();')\\r\\n expect(@user.active).to eq(true)\\r\\n end\\r\\n end\\r\\n\\r\\n\\r\\nend\\r\\n\\r\\n\\r\\n```\\r\\n\\r\\nNow, I'm not even sure this comes from FactoryGirl, it might as well just come from my lack of experience with tests. Sorry if this sounds silly !\\r\\n\"\n},\n\"comment\": {\n\"url\": \"https://api.github.com/repos/prasadsurase/code-curiosity/issues/comments/249539246\",\n\"url\": \"https://api.github.com/orgs/prasadsurase\",\n\"avatar_url\": \"https://avatars.githubusercontent.com/u/130756?\"\n}\n+ },\n+ {\n+ \"id\": 7249660086,\n+ \"type\": \"IssuesEvent\",\n+ \"actor\": {\n+ \"id\": 562052,\n+ \"login\": \"prasadsurase\",\n+ \"display_login\": \"prasadsurase\",\n+ \"gravatar_id\": \"\",\n+ \"url\": \"https://api.github.com/users/prasadsurase\",\n+ \"avatar_url\": \"https://avatars.githubusercontent.com/u/562052?\"\n+ },\n+ \"repo\": {\n+ \"id\": 67219068,\n+ \"name\": \"prasadsurase/code-curiosity\",\n+ \"url\": \"https://api.github.com/repos/prasadsurase/code-curiosity\"\n+ },\n+ \"payload\": {\n+ \"action\": \"opened\",\n+ \"issue\": {\n+ \"url\": \"https://api.github.com/repos/prasadsurase/populator/issues/1\",\n+ \"repository_url\": \"https://api.github.com/repos/prasadsurase/populator\",\n+ \"labels_url\": \"https://api.github.com/repos/prasadsurase/populator/issues/1/labels{/name}\",\n+ \"comments_url\": \"https://api.github.com/repos/prasadsurase/populator/issues/1/comments\",\n+ \"events_url\": \"https://api.github.com/repos/prasadsurase/populator/issues/1/events\",\n+ \"html_url\": \"https://github.com/prasadsurase/populator/issues/1\",\n+ \"id\": 297454435,\n+ \"number\": 1,\n+ \"title\": \"add sidekiq job\",\n+ \"user\": {\n+ \"login\": \"prasadsurase\",\n+ \"id\": 562052,\n+ \"avatar_url\": \"https://avatars3.githubusercontent.com/u/562052?v=4\",\n+ \"gravatar_id\": \"\",\n+ \"url\": \"https://api.github.com/users/prasadsurase\",\n+ \"html_url\": \"https://github.com/prasadsurase\",\n+ \"followers_url\": \"https://api.github.com/users/prasadsurase/followers\",\n+ \"following_url\": \"https://api.github.com/users/prasadsurase/following{/other_user}\",\n+ \"gists_url\": \"https://api.github.com/users/prasadsurase/gists{/gist_id}\",\n+ \"starred_url\": \"https://api.github.com/users/prasadsurase/starred{/owner}{/repo}\",\n+ \"subscriptions_url\": \"https://api.github.com/users/prasadsurase/subscriptions\",\n+ \"organizations_url\": \"https://api.github.com/users/prasadsurase/orgs\",\n+ \"repos_url\": \"https://api.github.com/users/prasadsurase/repos\",\n+ \"events_url\": \"https://api.github.com/users/prasadsurase/events{/privacy}\",\n+ \"received_events_url\": \"https://api.github.com/users/prasadsurase/received_events\",\n+ \"type\": \"User\",\n+ \"site_admin\": false\n+ },\n+ \"labels\": [],\n+ \"state\": \"open\",\n+ \"locked\": false,\n+ \"assignee\": null,\n+ \"assignees\": [],\n+ \"milestone\": null,\n+ \"comments\": 0,\n+ \"created_at\": \"2016-08-15T13:56:37Z\",\n+ \"updated_at\": \"2016-08-15T13:56:37Z\",\n+ \"closed_at\": null,\n+ \"author_association\": \"OWNER\",\n+ \"body\": null\n}\n+ },\n+ \"public\": true,\n+ \"created_at\": \"2016-08-15T13:56:37Z\"\n+ }\n+\n]\n" }, { "change_type": "MODIFY", "old_path": "test/models/activities_fetcher_test.rb", "new_path": "test/models/activities_fetcher_test.rb", "diff": "@@ -12,7 +12,8 @@ class ActivitiesFetcherTest < ActiveSupport::TestCase\nheaders: {content_type: \"application/json; charset=utf-8\"}\n)\n- stub_get('/repos/prasadsurase/code-curiosity').to_return(\n+ # this Code-curiosity repo belongs to user prasadsurase.\n+ stub_get('/repositories/67219068').to_return(\nbody: File.read('test/fixtures/repo.json'), status: 200,\nheaders: {content_type: \"application/json; charset=utf-8\"}\n)\n@@ -27,6 +28,22 @@ class ActivitiesFetcherTest < ActiveSupport::TestCase\nTimecop.return\nend\n+ describe 'fetch activities for a given round' do\n+ test 'should create if present' do\n+ @round = create :round, :open, from_date: 1.month.ago.beginning_of_month, end_date: 1.month.ago.end_of_month\n+ activities_fetcher = ActivitiesFetcher.new(@user, @round)\n+ activities_fetcher.fetch(:all)\n+ assert_equal 1, Activity.count\n+ end\n+\n+ test 'should not create if not present' do\n+ @round = create :round, :open, from_date: 1.month.from_now.beginning_of_month, end_date: 1.month.from_now.end_of_month\n+ activities_fetcher = ActivitiesFetcher.new(@user, @round)\n+ activities_fetcher.fetch(:all)\n+ assert_equal 0, Activity.count\n+ end\n+ end\n+\ntest 'fetch daily' do\nactivities_fetcher = ActivitiesFetcher.new(@user, @round)\nactivities_fetcher.fetch(:daily)\n@@ -37,14 +54,14 @@ class ActivitiesFetcherTest < ActiveSupport::TestCase\ntest 'fetch all' do\nactivities_fetcher = ActivitiesFetcher.new(@user, @round)\nactivities_fetcher.fetch(:all)\n- assert_equal 2, Activity.count\n+ assert_equal 3, Activity.count\nassert_equal 1, Repository.count\nend\ntest 'creates activity' do\nactivities_fetcher = ActivitiesFetcher.new(@user, @round)\nactivities_fetcher.fetch(:all)\n- assert_equal 2, Activity.count\n+ assert_equal 3, Activity.count\nactivity = Activity.first\njson_data = @activities[1]\nassert_equal activity.gh_id, json_data['id']\n@@ -61,7 +78,7 @@ class ActivitiesFetcherTest < ActiveSupport::TestCase\ntest 'creates repo if not present' do\nactivities_fetcher = ActivitiesFetcher.new(@user, @round)\nactivities_fetcher.fetch(:all)\n- assert_equal 2, Activity.count\n+ assert_equal 3, Activity.count\nassert_equal 1, Repository.count\nrepository = Repository.last\ndata = @activities[1]['repo']\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
add end time of round
332,090
20.03.2018 20:07:50
-19,080
aaa4e8be4b9da6e1e2f93bbf804c6147c6380876
pass round while fetching commits and activities
[ { "change_type": "MODIFY", "old_path": "lib/tasks/fetch_data.rake", "new_path": "lib/tasks/fetch_data.rake", "diff": "namespace :fetch_data do\ndesc \"Fetch code-curiosity github repositories commits and activities periodically.\"\n- task :commits_and_activities, [:type] => :environment do |t, args|\n+ task :commits_and_activities, [:round, :type] => :environment do |t, args|\n+ round = args[:round] ? Round.find(args[:round]) : Round.opened\ntype = args[:type] || 'daily'\nputs \"Running for #{type}\"\n@@ -12,10 +13,10 @@ namespace :fetch_data do\n#CommitJob.perform_later(user, type)\nuser.repositories.required.each do |repo|\n- CommitJob.perform_later(user.id.to_s, type, repo.id.to_s)\n+ CommitJob.perform_later(user.id.to_s, type, repo.id.to_s, round.id.to_s)\nend\n- ActivityJob.perform_later(user.id.to_s, type)\n+ ActivityJob.perform_later(user.id.to_s, type, round.id.to_s)\nend\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
pass round while fetching commits and activities
332,090
23.03.2018 20:19:31
-19,080
90950d644a8aefe63af72902a35c91fc210f866f
sidebar UI changes 1. removed green color of subscribe band 2. highlighted active bar
[ { "change_type": "MODIFY", "old_path": "app/views/application/_sidebar.html.haml", "new_path": "app/views/application/_sidebar.html.haml", "diff": "%span Judging\n= render 'admin_sidebar' if current_user.is_admin?\n= render 'orgs_sidebar' if current_user.organizations.any?\n- %li.bg-green\n+ %li{class: is_active('index', 'sponsorer_details')}\n%a{href: sponsorer_details_path}\n%i.fa.fa-usd\n%span Subscribe\n" }, { "change_type": "MODIFY", "old_path": "vendor/assets/stylesheets/skin-black-light.css", "new_path": "vendor/assets/stylesheets/skin-black-light.css", "diff": ".skin-black-light .sidebar-menu > li:hover > a,\n.skin-black-light .sidebar-menu > li.active > a {\ncolor: #000000;\n- background: #f4f4f5;\n+ background: #bfbfbf;\n}\n.skin-black-light .sidebar-menu > li.active {\nborder-left-color: #ffffff;\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
sidebar UI changes 1. removed green color of subscribe band 2. highlighted active bar
332,090
22.03.2018 18:05:08
-19,080
1801508e38b61dd497ccec8744bc6e82b83bc8b7
change subscription plan of contest winners without creating sponsorer details
[ { "change_type": "MODIFY", "old_path": "app/helpers/redeem_helper.rb", "new_path": "app/helpers/redeem_helper.rb", "diff": "module RedeemHelper\ndef redeem_request_value(user, one_dollar_to_points)\n- (user.is_sponsorer and user.active_sponsorer_detail) ? one_dollar_to_points : one_dollar_to_points * 2\n+ (Offer.is_winner?(current_user) || (user.is_sponsorer and user.active_sponsorer_detail)) ? one_dollar_to_points : one_dollar_to_points * 2\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/offer.rb", "new_path": "app/models/offer.rb", "diff": "@@ -4,11 +4,16 @@ class Offer\nfield :name, type: String, default: \"\"\nfield :email, type: String, default: \"\"\nfield :active_from, type: Date\n+ field :active_till, type: Date\n- validates :email, :name, :active_from, presence: true\n+ validates :email, :name, :active_from, :active_till, presence: true\ndef self.is_winner?(user)\n- Offer.where(:email => user.email, :active_from.lte => Date.today).present?\n+ Offer.where(\n+ :email => user.email,\n+ :active_from.lte => Date.today,\n+ :active_till.gte => Date.today\n+ ).present?\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/redeem_request.rb", "new_path": "app/models/redeem_request.rb", "diff": "@@ -143,7 +143,7 @@ class RedeemRequest\n#3 if user is on free plan he can only redeem 400 royalty points per month.\nroyalty_points_threshold_check_as_per_user(total_points, royalty_points,\nredeemed_royalty_point, total_redeemed_royalty, royalty,\n- user.is_sponsorer ? REDEEM_THRESHOLD['paid'] : REDEEM_THRESHOLD['free'])\n+ (Offer.is_winner?(user) || user.is_sponsorer) ? REDEEM_THRESHOLD['paid'] : REDEEM_THRESHOLD['free'])\nend\n# validating redeemption request limit for free and paid user\n@@ -199,7 +199,7 @@ class RedeemRequest\nprivate\ndef set_amount\n- denominator = if sponsorer_detail\n+ denominator = if sponsorer_detail || Offer.is_winner?(user)\nREDEEM['one_dollar_to_points']\nelse\nREDEEM['one_dollar_to_points'] * 2\n@@ -208,7 +208,7 @@ class RedeemRequest\nend\ndef update_amount\n- denominator = if sponsorer_detail\n+ denominator = if sponsorer_detail || Offer.is_winner?(user)\nREDEEM['one_dollar_to_points']\nelse\nREDEEM['one_dollar_to_points'] * 2\n" }, { "change_type": "MODIFY", "old_path": "app/models/transaction.rb", "new_path": "app/models/transaction.rb", "diff": "@@ -58,7 +58,7 @@ class Transaction\nend\ndef set_amount\n- if user.is_sponsorer\n+ if user.is_sponsorer || Offer.is_winner?(user)\nset(amount: points.to_f/SUBSCRIPTIONS['individual'])\nelse\nset(amount: points.to_f/SUBSCRIPTIONS['free'])\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -119,10 +119,6 @@ class User\n# for auto_created users, we need to invoke the after_create callback.\nuser.calculate_popularity unless user.current_subscription\n- if Offer.is_winner?(user)\n- user.upgrade_account unless user.active_sponsorer_detail\n- end\n-\nuser\nend\n@@ -278,13 +274,4 @@ class User\nend\nend\nend\n-\n-\n- def upgrade_account\n- sponsorer_details.create(\n- sponsorer_type: 'INDIVIDUAL',\n- subscription_status: 'active',\n- payment_plan: SPONSOR['individual'].keys.first,\n- )\n- end\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/redeem/_new_modal.html.haml", "new_path": "app/views/redeem/_new_modal.html.haml", "diff": "%h4.modal-title\nRedeem Points\n%b.pull-right.maring-right-fifty= \"$1 : #{redeem_request_value(current_user, REDEEM['one_dollar_to_points'])} points\"\n- - unless current_user.active_sponsorer_detail\n+ - unless Offer.is_winner?(current_user) || current_user.active_sponsorer_detail\n.text-center{style: \"font-size:14px\"}\n%strong\n#promote\n" }, { "change_type": "MODIFY", "old_path": "app/views/redeem/_submit_buttons.html.haml", "new_path": "app/views/redeem/_submit_buttons.html.haml", "diff": "%button.btn.btn-default{'data-dismiss' => 'modal', :type => 'button'} Cancel\n-- if current_user.active_sponsorer_detail\n+- if Offer.is_winner?(current_user) || current_user.active_sponsorer_detail\n= f.submit \"Redeem\", class: \"btn btn-primary\"\n- else\n%button.btn.btn-primary.submit-redeem{ type: \"button\", data: { points: current_user.points, free: SUBSCRIPTIONS['free'], paid: SUBSCRIPTIONS['individual']} } Redeem\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "app/views/subscription_mailer/progress.html.haml", "new_path": "app/views/subscription_mailer/progress.html.haml", "diff": "Keep going, you still have some time!\n= \"You are only #{@subscription.goal.points - @subscription.points} points away from reaching your goal!\"\n-- if !@user.active_sponsorer_detail\n+- if !@user.active_sponsorer_detail && !Offer.is_winner?(@user)\n%p\n%br\n%b\n" }, { "change_type": "MODIFY", "old_path": "app/views/subscription_mailer/redeem_points.html.haml", "new_path": "app/views/subscription_mailer/redeem_points.html.haml", "diff": "For more details on your points, check out your\n= link_to \"CodeCuriosity profile\", user_url(@user)\n-- if !@user.active_sponsorer_detail\n+- if !@user.active_sponsorer_detail && !Offer.is_winner?(@user)\n%p\n%br\n%b\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "- else\n%span.pull-right Not set yet\n- if logged_in_user?\n- - if @user.active_sponsorer_detail || @user.able_to_redeem?\n+ - if Offer.is_winner?(current_user) || @user.active_sponsorer_detail || @user.able_to_redeem?\n= link_to '#', class: \"btn btn-primary btn-block\", data: { toggle: 'modal', target: '#redeem-modal .modal' } do\n%b Redeem Points\n- else\n%span.tool-tip{\"data-placement\" => \"top\", \"data-toggle\" => \"tooltip\", :title => \"Not met the redemption criteria\"}\n%span.btn.btn-primary.btn-block{:disabled => \"disabled\"} Redeem Points\n%p\n- - unless current_user.active_sponsorer_detail\n+ - unless Offer.is_winner?(current_user) || current_user.active_sponsorer_detail\n.text-center\n%strong\n#promote\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/factories/offer.rb", "diff": "+FactoryGirl.define do\n+ factory :offer do\n+ name {Faker::Name.name}\n+ email { Faker::Internet.email }\n+ active_from Date.today.beginning_of_month\n+ active_till Date.today.end_of_month\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "test/models/redeem_request_test.rb", "new_path": "test/models/redeem_request_test.rb", "diff": "@@ -7,6 +7,45 @@ class RedeemRequestTest < ActiveSupport::TestCase\n@redeem_request ||= build(:redeem_request)\nend\n+ describe 'if user is a contest winner' do\n+ before do\n+ @user = create :user\n+ @offer = create :offer, email: @user.email\n+ @round = create :round, :open\n+ @round_transaction = create :transaction, points: 300, type: 'credit', transaction_type: 'Round', user: @user\n+ @royalty_transaction = create :transaction, points: 200, transaction_type: 'royalty_bonus', type: 'credit', user: @user\n+ end\n+\n+ test 'should be able to redeem points with same plan as INDIVIDUAL subscriber' do\n+ redeem_request = create :redeem_request, points: 300, user: @user\n+ assert_equal redeem_request.amount, 30.0\n+ end\n+\n+ test 'should be able to redeem points without any sponsorer detail' do\n+ redeem_request = create :redeem_request, points: 300, user: @user\n+ assert_equal @user.redeem_requests.count, 1\n+ assert_equal redeem_request.amount, 30.0\n+ end\n+\n+ test 'should be able to redeem upto 500 royalty points in a month' do\n+ redeem_request = build :redeem_request, points: 500, user: @user\n+ assert redeem_request.valid?\n+ end\n+\n+ test 'should not be able to redeem more than 500 royalty points in a month' do\n+ redeem_request = build :redeem_request, points: 520, user: @user\n+ assert_not redeem_request.valid?\n+ end\n+\n+ describe 'if user is no more a contest winner' do\n+ test 'should be able to redeem points with same plan as FREE subscriber' do\n+ @offer.set active_till: Date.yesterday\n+ redeem_request = create :redeem_request, points: 300, user: @user\n+ assert_equal redeem_request.amount, 15.0\n+ end\n+ end\n+ end\n+\ntest \"validity of redeem_request\" do\nuser = create :user\nredeem_request = build(:redeem_request, :points => 2, :address => 'baner', user: user)\n" }, { "change_type": "MODIFY", "old_path": "test/models/user_test.rb", "new_path": "test/models/user_test.rb", "diff": "@@ -196,24 +196,4 @@ class UserTest < ActiveSupport::TestCase\n=end\nend\n- test 'upgrade account if user is offer winner' do\n- round = create :round, :open\n- offer = Offer.create(\n- email: 'test@test.com',\n- name: 'test_user',\n- active_from: Date.today + 5.day\n- )\n- omniauthentication\n- user = User.find_by name: 'test_user'\n- assert_equal user.active_sponsorer_detail, nil\n-\n- offer.update_attributes(active_from: Date.today)\n- omniauthentication\n- assert_equal !!user.active_sponsorer_detail, true\n- assert_equal user.sponsorer_details.count, 1\n-\n- omniauthentication\n- assert_equal user.sponsorer_details.count, 1\n- end\n-\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
change subscription plan of contest winners without creating sponsorer details
332,090
11.04.2018 12:56:48
-19,080
ab5e2111a827ea8138f546b378a078fdec1efb69
script to backup database regularly
[ { "change_type": "ADD", "old_path": null, "new_path": "config.rb", "diff": "+# encoding: utf-8\n+\n+##\n+# Backup v4.x Configuration\n+#\n+# Documentation: http://backup.github.io/backup\n+# Issue Tracker: https://github.com/backup/backup/issues\n+\n+##\n+# Config Options\n+#\n+# The options here may be overridden on the command line, but the result\n+# will depend on the use of --root-path on the command line.\n+#\n+# If --root-path is used on the command line, then all paths set here\n+# will be overridden. If a path (like --tmp-path) is not given along with\n+# --root-path, that path will use it's default location _relative to --root-path_.\n+#\n+# If --root-path is not used on the command line, a path option (like --tmp-path)\n+# given on the command line will override the tmp_path set here, but all other\n+# paths set here will be used.\n+#\n+# Note that relative paths given on the command line without --root-path\n+# are relative to the current directory. The root_path set here only applies\n+# to relative paths set here.\n+#\n+# ---\n+#\n+# Sets the root path for all relative paths, including default paths.\n+# May be an absolute path, or relative to the current working directory.\n+#\n+# root_path 'my/root'\n+#\n+# Sets the path where backups are processed until they're stored.\n+# This must have enough free space to hold apx. 2 backups.\n+# May be an absolute path, or relative to the current directory or +root_path+.\n+#\n+# tmp_path 'my/tmp'\n+#\n+# Sets the path where backup stores persistent information.\n+# When Backup's Cycler is used, small YAML files are stored here.\n+# May be an absolute path, or relative to the current directory or +root_path+.\n+#\n+# data_path 'my/data'\n+\n+##\n+# Utilities\n+#\n+# If you need to use a utility other than the one Backup detects,\n+# or a utility can not be found in your $PATH.\n+#\n+# Utilities.configure do\n+# tar '/usr/bin/gnutar'\n+# redis_cli '/opt/redis/redis-cli'\n+# end\n+\n+##\n+# Logging\n+#\n+# Logging options may be set on the command line, but certain settings\n+# may only be configured here.\n+#\n+# Logger.configure do\n+# console.quiet = true # Same as command line: --quiet\n+# logfile.max_bytes = 2_000_000 # Default: 500_000\n+# syslog.enabled = true # Same as command line: --syslog\n+# syslog.ident = 'my_app_backup' # Default: 'backup'\n+# end\n+#\n+# Command line options will override those set here.\n+# For example, the following would override the example settings above\n+# to disable syslog and enable console output.\n+# backup perform --trigger my_backup --no-syslog --no-quiet\n+\n+##\n+# Component Defaults\n+#\n+# Set default options to be applied to components in all models.\n+# Options set within a model will override those set here.\n+#\n+# Storage::S3.defaults do |s3|\n+# s3.access_key_id = \"my_access_key_id\"\n+# s3.secret_access_key = \"my_secret_access_key\"\n+# end\n+#\n+# Notifier::Mail.defaults do |mail|\n+# mail.from = 'sender@email.com'\n+# mail.to = 'receiver@email.com'\n+# mail.address = 'smtp.gmail.com'\n+# mail.port = 587\n+# mail.domain = 'your.host.name'\n+# mail.user_name = 'sender@email.com'\n+# mail.password = 'my_password'\n+# mail.authentication = 'plain'\n+# mail.encryption = :starttls\n+# end\n+\n+##\n+# Preconfigured Models\n+#\n+# Create custom models with preconfigured components.\n+# Components added within the model definition will\n+# +add to+ the preconfigured components.\n+#\n+# preconfigure 'MyModel' do\n+# archive :user_pictures do |archive|\n+# archive.add '~/pictures'\n+# end\n+#\n+# notify_by Mail do |mail|\n+# mail.to = 'admin@email.com'\n+# end\n+# end\n+#\n+# MyModel.new(:john_smith, 'John Smith Backup') do\n+# archive :user_music do |archive|\n+# archive.add '~/music'\n+# end\n+#\n+# notify_by Mail do |mail|\n+# mail.to = 'john.smith@email.com'\n+# end\n+# end\n" }, { "change_type": "MODIFY", "old_path": "config/deploy.rb", "new_path": "config/deploy.rb", "diff": "@@ -30,7 +30,7 @@ set :branch, 'master'\nset :shared_paths, [\n'config/mongoid.yml', 'config/secrets.yml', 'log',\n'config/git.yml', '.env.production', 'repositories',\n- 'cache'\n+ 'cache', 'config/backup.yml'\n]\n# Optional settings:\n" }, { "change_type": "ADD", "old_path": null, "new_path": "models/code_curiosity_backup.rb", "diff": "+# encoding: utf-8\n+\n+##\n+# Backup Generated: code_curiosity_backup\n+# Once configured, you can run the backup with the following command:\n+#\n+# $ backup perform -t code_curiosity_backup [-c <path_to_configuration_file>]\n+#\n+# For more information about Backup's components, see the documentation at:\n+# http://backup.github.io/backup\n+#\n+\n+BACKUP = YAML.load_file('config/backup.yml')['backup_data']\n+\n+Model.new(:code_curiosity_backup, 'Description for code_curiosity_backup') do\n+\n+ ##\n+ # MongoDB [Database]\n+ #\n+ database MongoDB do |db|\n+ db.name = BACKUP['database_name']\n+ db.username = \"\"\n+ db.password = \"\"\n+ db.host = BACKUP['database_host']\n+ db.port = 27017\n+ db.ipv6 = false\n+ db.only_collections = []\n+ db.additional_options = []\n+ db.lock = false\n+ db.oplog = false\n+ end\n+\n+ ##\n+ # Amazon Simple Storage Service [Storage]\n+ #\n+ store_with S3 do |s3|\n+ # AWS Credentials\n+ s3.access_key_id = BACKUP['s3_access_key_id']\n+ s3.secret_access_key = BACKUP['s3_secret_access_key']\n+ # Or, to use a IAM Profile:\n+ # s3.use_iam_profile = true\n+\n+ s3.region = \"ap-southeast-1\"\n+ s3.bucket = \"codecuriosity\"\n+ #s3.path = \"/backups\"\n+ s3.keep = 5\n+ # s3.keep = Time.now - 2592000 # Remove all backups older than 1 month.\n+ end\n+\n+ ##\n+ # GPG [Encryptor]\n+ #\n+ # Setting up #keys, as well as #gpg_homedir and #gpg_config,\n+ # would be best set in config.rb using Encryptor::GPG.defaults\n+ #\n+ encrypt_with GPG do |encryption|\n+ # Setup public keys for #recipients\n+ encryption.keys = {}\n+ encryption.keys['user@domain.com'] = <<-KEY\n+ -----BEGIN PGP PUBLIC KEY BLOCK-----\n+ Version: GnuPG v1.4.11 (Darwin)\n+\n+ mQENBFq4/RUBCACrmhrL6EBOruu3OaYhzggDgxCw9f77r1Y/XS4OmU/PTtr8NGAe\n+ TAoTffwoNZmdi3LQ3AfFlj1egSZnxu3wP0NYpjg/PMZz3yF8DFPQ+OXbZM7hqMio\n+ j/+FPVWy8KURrZuZRiP2PolqZP9K376R7iK0ZenNqlFjBwwJoUbMRgacxzyXRbFR\n+ DY1TVGXqdykkeLL8ExtZCc6fdFIIMo90/wEjp+GjKWbP9O+8qw9UaZ3sQNTndxxS\n+ sgDgJJunAMEKDk/03l2JpGQgpqPwOs/t95fjWHAVSh+52b4CHsvkP+48UDNjZ0GG\n+ mbF54zdti3eOZ0zvMAlaHh9WOmbnUjOvySU5ABEBAAG0LiJSYWh1bCBKYWRoYXYi\n+ IChwYWluKSA8cmFodWwucmo5NDIxQGdtYWlsLmNvbT6JATgEEwECACIFAlq4/RUC\n+ GwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEM3HGI/JkrsDEecH/2SUO2/m\n+ VT1jLR4WyZnlgrGZFLHv9HVaOFvaRGGSPqP5+t84wXNSWY0f3JI/77bY0msCCQfb\n+ zBJEzN5T8ljeu+RVWB+PgGY3LM4Pq5hpKOF5g8aeKiOCqWOjxu8Ly15cq24V7WbF\n+ l1swF+Lp+AaF5LF6/sICinKbr0aWO4g3Gx5Gwyqhfi6a3VHI8sBHxLmPqY2QwqS+\n+ cEtQdtVHhdTEgaElt/uOK0TO2tfMsK2NIV/ZohFqAVwsTMoF2mo5EwqKyZ4ZTKWl\n+ KHGjMx84vsuemBEyJB7kEjYNmCZ+CKj0DwEDhfooWKQHmZvB+dKn/GcQYgMJyGQj\n+ 4cRO6ySPPLa5ymq5AQ0EWrj9FQEIAMC4om0eAZFOia34pL8whzX9D4Jb85srtcS4\n+ vrRJaaNhDTJi2T0B+WzK7qTJGs3pQm9cMfn7zxDwWp0cJ+qrE0yCYWP9TtaXckFf\n+ DPM73HIDbuMraFQ25/jCi4zWzSvNVi0J8f7p9aGWBoqHOzYpViwnqiX+55uBVgZn\n+ mckfqZLMxzJNQRtOAEWFzXdzaqEJdTuQDpHDGPWmbiZ1xCgWSrc+51zO+P7cAX4x\n+ qfHITyEviITb7MSAvOoXqwicE4cc0CjuFSnnNSQxBI/BieZqWpJoDO4RX1RiIv/9\n+ DCjyvt8GDJIqr38G/EdkN2QMEP0KHjQ/Al2CtbnuhakmgFAQGZ8AEQEAAYkBHwQY\n+ AQIACQUCWrj9FQIbDAAKCRDNxxiPyZK7A9gDB/9gdxT+rNAp00wgSc+vUgQgUBn7\n+ +wKZXl543ultH9KP22zEc4iXaiLbr+3lQiYbNnGDyPmGfCYcYReX9zwbOzN+VsV8\n+ ckYoCx9WOl74HtI802hiFfrokU8lyKECi9IjolRQZbNThn9Px5/1DkflHlvFwYH4\n+ lrT3ospW429+UJRQErRAP3OXFNCNvwVsTgQtpdRKRTqICpmdBXLwH7cRU3tBuLTS\n+ K0oAIrATXt1QUju3/XWiPFddBhGj5Hv2SBp5ElYT1sOPmzEM6v4xhzhP9WDyzv7/\n+ DtpjtchTeUxPcW3HIA5GUpS52Dq3DbtDOHIgqxIIDP2uIHaE2CSdAbbbPkYy\n+ =m0Pv\n+ -----END PGP PUBLIC KEY BLOCK-----\n+ KEY\n+\n+ # Specify mode (:asymmetric, :symmetric or :both)\n+ encryption.mode = :both # defaults to :asymmetric\n+\n+ # Specify recipients from #keys (for :asymmetric encryption)\n+ encryption.recipients = BACKUP['mail_username']\n+\n+ # Specify passphrase or passphrase_file (for :symmetric encryption)\n+ encryption.passphrase = 'a secret'\n+ # encryption.passphrase_file = '~/backup_passphrase'\n+ end\n+\n+ ##\n+ # Gzip [Compressor]\n+ #\n+ compress_with Gzip\n+\n+ ##\n+ # Mail [Notifier]\n+ #\n+ # The default delivery method for Mail Notifiers is 'SMTP'.\n+ # See the documentation for other delivery options.\n+ #\n+ notify_by Mail do |mail|\n+ mail.on_success = true\n+ mail.on_warning = true\n+ mail.on_failure = true\n+\n+ mail.from = BACKUP['mail_from']\n+ mail.to = BACKUP['mail_to']\n+ mail.cc = \"cc@email.com\"\n+ mail.bcc = \"bcc@email.com\"\n+ mail.reply_to = \"reply_to@email.com\"\n+ mail.address = \"smtp.gmail.com\"\n+ mail.port = 587\n+ mail.domain = \"your.host.name\"\n+ mail.user_name = BACKUP['mail_username']\n+ mail.password = BACKUP['mail_password']\n+ mail.authentication = \"plain\"\n+ mail.encryption = :starttls\n+ end\n+\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
script to backup database regularly
332,110
11.05.2018 12:58:04
-19,080
ef2b6573c49e323b79f42274e16a1359d8484ba4
Removed admin dashboard tab. Removed related controller, view and routes.
[ { "change_type": "DELETE", "old_path": "app/controllers/admin/dashboard_controller.rb", "new_path": null, "diff": "-class Admin::DashboardController < ApplicationController\n- before_action :authenticate_user!\n- before_action :authenticate_admin!\n-\n- def index\n- end\n-end\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/dashboard/_info_box.html.haml", "new_path": null, "diff": "-.col-md-3.col-sm-6.col-xs-12\n- .info-box\n- %span.info-box-icon{ class: info_box_bg }\n- %i.ion{class: icon }\n- .info-box-content\n- %span= title\n- %span.info-box-number= value\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_admin_sidebar.html.haml", "new_path": "app/views/application/_admin_sidebar.html.haml", "diff": "%span Admin\n%i.fa.fa-angle-left.pull-right\n%ul.treeview-menu\n- %li\n- %a{href: admin_dashboard_path}\n- %i.fa.fa-circle-o\n- %span Dashboard\n%li\n%a{href: admin_users_path}\n%i.fa.fa-circle-o\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -88,7 +88,6 @@ Rails.application.routes.draw do\npatch :update_ignore_field\nend\n- get 'dashboard/index', as: 'dashboard'\nend\nnamespace :github do\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed admin dashboard tab. - Removed related controller, view and routes.
332,098
11.05.2018 13:11:49
-19,080
e8b6617f957b4a9da320d3cf623848bb6f2697ec
Update commit model, add score, reward and frequency_factor
[ { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -15,6 +15,9 @@ class Commit\nfield :auto_score, type: Integer\nfield :default_score, type: Float, default: 0\nfield :bugspots_score, type: Float, default: 0\n+ field :score, type: Float, default: 0\n+ field :reward, type: Float, default: 0\n+ field :frequency_factor, type: Float, default: 1\nbelongs_to :user\nbelongs_to :repository\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Update commit model, add score, reward and frequency_factor
332,099
11.05.2018 13:23:33
-19,080
b2c59fd0cacc2882d3f0a945e45004e31369a796
[BANDANA][ANURAG]Removed sponsores and featured groups from the Home Page
[ { "change_type": "MODIFY", "old_path": "app/controllers/home_controller.rb", "new_path": "app/controllers/home_controller.rb", "diff": "@@ -2,10 +2,7 @@ class HomeController < ApplicationController\ninclude HomeHelper\n#load the before_actions only if the user is not logged in.\n- before_action :featured_groups, only: [:index], unless: proc { user_signed_in? }\n- before_action :featured_groups_size, only: [:index], unless: proc { user_signed_in? }\nbefore_action :multi_line_chart, only: [:index], unless: proc { user_signed_in? }\n- before_action :sponsorer_organizations, only: [:index], unless: proc { user_signed_in? }\ndef index\nif user_signed_in?\n@@ -55,7 +52,4 @@ class HomeController < ApplicationController\nend\nend\n- # methods from the HomeHelper module are public and need to be private\n- private :featured_groups, :featured_groups_size\n-\nend\n" }, { "change_type": "MODIFY", "old_path": "app/helpers/home_helper.rb", "new_path": "app/helpers/home_helper.rb", "diff": "module HomeHelper\n- def featured_groups\n- @featured_groups = Group.where(is_featured: true)\n- end\n-\n- def featured_groups_size\n- @size = @featured_groups.size\n- end\n-\n- def sponsorer_organizations\n- @sponsorer_organizations = SponsorerDetail.organizations.active.publish\n- @sponsorer_users = SponsorerDetail.individuals.active.publish\n- end\n-\ndef select_avatar(sponsorer)\nif sponsorer.avatar?\nsponsorer.avatar\n" }, { "change_type": "DELETE", "old_path": "app/views/home/_featured_groups.html.haml", "new_path": null, "diff": "-%h4\n- Featured Groups\n-- @featured_groups.each_with_index do |group, index|\n- %div{:class => \"#{widget_class()}\"}\n- %iframe{src: group_widget_url(group), height:\"380\" ,width: \"340\" ,frameborder:\"0\" }\n" }, { "change_type": "DELETE", "old_path": "app/views/home/_sponsorer_benefits.html.haml", "new_path": null, "diff": "-.col-xs-12\n- .box-header\n- %h2 Reward Opensource contributors!\n- .box-body\n- - INFO['benefits'].keys.each do |key|\n- .col-xs-12.col-sm-4.col-md-4\n- %ul.false.g-green.benefits\n- %li.title\n- %big #{key.camelize}\n- %li.desc\n- %ul.point\n- - INFO['benefits'][key].each do |stmt|\n- %li #{stmt}\n- - unless key == 'free'\n- %li\n- - if user_signed_in?\n- = link_to(\"Subscribe\", new_sponsorer_detail_path(type: key.camelize), class: \"btn btn-lg btn-success\", remote: true)\n- - else\n- = link_to(\"Subscribe\", omniauth_authorize_path(:user, :github, user: key.camelize), class: \"btn btn-lg btn-success\")\n" }, { "change_type": "MODIFY", "old_path": "app/views/home/index.html.haml", "new_path": "app/views/home/index.html.haml", "diff": "%a.btn.btn-primary.btn-lg{ href: omniauth_authorize_path(:user, :github) }\n%span.fa.fa-github\nSign in with Github\n- %a.btn.btn-success.btn-lg{ href: \"#sponsor\"}\n- %span\n- Reward Contributors!\n.row.marketing\n.col-md-12.col-lg-offset-1.col-md-offset-1\n- INFO['home'].each_slice(2) do |data|\n.col-lg-5.col-md-5\n= render partial: 'info', collection: data, as: 'info'\n- .row.marketing\n- - if @sponsorer_organizations.count >= SPONSORER_THRESHOLD['organization']\n- = render partial: 'subscribers_list', locals: {header: \"Organization Sponsors\", sponsorer_group: @sponsorer_organizations, organization: true}\n- - if @sponsorer_users.count >= SPONSORER_THRESHOLD['individual']\n- = render partial: 'subscribers_list', locals: {header: \"Individual Sponsors\", sponsorer_group: @sponsorer_users, organization: false}\n- .row.marketing#sponsor\n- = render 'sponsorer_benefits'\n- - if @size > 0\n- .row.marketing\n- = render partial: 'featured_groups'\n.row\n= render partial: 'trend'\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
[BANDANA][ANURAG]Removed sponsores and featured groups from the Home Page
332,110
11.05.2018 13:36:09
-19,080
b6c957ad5b371d40dd2aa20247e2f4f967d10ffc
Removed "Mark as Judge" option from admin users tab. Removed controller action and route.
[ { "change_type": "MODIFY", "old_path": "app/controllers/admin/users_controller.rb", "new_path": "app/controllers/admin/users_controller.rb", "diff": "@@ -13,11 +13,6 @@ class Admin::UsersController < ApplicationController\nend\nend\n- def mark_as_judge\n- User.find(params[:user_id]).set(is_judge: params[:flag])\n- redirect_to admin_users_path\n- end\n-\ndef login_as\nuser = User.find(params[:user_id])\nif user\n" }, { "change_type": "MODIFY", "old_path": "app/views/admin/users/_user.html.haml", "new_path": "app/views/admin/users/_user.html.haml", "diff": "%td= user.created_at.strftime('%d/%m/%Y %T')\n%td= check_box_tag user.id, 'blocked', user.blocked, { id: \"#{user.id}\", class: 'block'}\n%td\n- - if user.is_judge?\n- %a{href: admin_user_mark_as_judge_path(user, flag: false), class: \"btn btn-danger btn-sm\", data: {confirm: \"Are you sure?\"}}\n- %i.fa.fa-close\n- Remove as judge\n- - else\n- %a{href: admin_user_mark_as_judge_path(user, flag: true), class: \"btn btn-primary btn-sm\", data: {confirm: \"Are you sure?\"}}\n- %i.fa.fa-check\n- Mark as judge\n%a{href: admin_user_login_as_path(user), class: \"btn btn-primary btn-sm\", data: {confirm: \"Are you sure?\"}}\n%i.fa.fa-user\nLogin as\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -62,7 +62,6 @@ Rails.application.routes.draw do\nend\nend\nresources :users, only: [:index, :destroy] do\n- get :mark_as_judge\nget :login_as\nget :search, on: :collection\nmember do\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed "Mark as Judge" option from admin users tab. - Removed controller action and route.
332,099
11.05.2018 13:41:07
-19,080
83827a406f7ca805723bdc7e9556af3fbe4e4a00
Removed trends from the dashboards
[ { "change_type": "MODIFY", "old_path": "app/controllers/home_controller.rb", "new_path": "app/controllers/home_controller.rb", "diff": "@@ -24,32 +24,4 @@ class HomeController < ApplicationController\nend\nend\n- def trend\n- subscription = current_user ? current_user.current_subscription(current_round) : nil\n-\n- @goal = if params[:goal_id].present?\n- Goal.where(id: params[:goal_id]).first\n- elsif subscription\n- subscription.goal\n- end\n- @goal = Goal.default_goal unless @goal\n-\n- @points = current_round.subscriptions\n- .where(goal_id: @goal.id)\n- .order(points: :desc)\n- .pluck(:points)\n-\n- if current_user\n- if subscription && subscription.goal == @goal\n- @user_points = subscription.points\n- end\n- end\n-\n- if user_signed_in?\n- render layout: 'application'\n- else\n- render layout: 'info'\n- end\n- end\n-\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_navbar.html.haml", "new_path": "app/views/application/_navbar.html.haml", "diff": "= link_to faq_path do\n%i.fa.fa-question\nFAQS\n- %li\n- = link_to trend_path do\n- %span.fa.fa-line-chart\n- Trends\n- if current_user\n= render 'user_nav'\n- else\n" }, { "change_type": "DELETE", "old_path": "app/views/home/trend.html.haml", "new_path": null, "diff": "-%section.content-header\n- %h1= \"Trend for #{current_round.name} #{@goal.name}\"\n-%section.content\n- .row\n- .col-xs-12\n- .box\n- .box-body.no-padding\n- #points-chart-container\n- .col-xs-12.text-center.goal-trend-btns\n- - Goal.asc(:points).each do |g|\n- = link_to trend_path(g), class: 'btn btn-success' do\n- %i.fa.fa-line-chart\n- = \"Trend for #{g.name}\"\n-\n-\n-:javascript\n- showPointsChart('#{current_round.name}', #{@points.to_json}, #{@user_points || -100 });\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -136,7 +136,6 @@ Rails.application.routes.draw do\nget 'change_round/:id' => \"dashboard#change_round\", as: :change_round\nget 'dashboard' => 'dashboard#index'\n#get 'leaderboard' => 'home#leaderboard'\n- get 'trend/(:goal_id)' => 'home#trend', as: :trend\nget 'faq' => 'info#faq'\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed trends from the dashboards
332,110
11.05.2018 13:50:53
-19,080
7a48be5d84acd032cccd220d816ecb28098a0bb6
Removed admin `Judges` tab and `judges`,'Actions' column from admin repos tab.
[ { "change_type": "MODIFY", "old_path": "app/views/admin/repositories/_repos_table.html.haml", "new_path": "app/views/admin/repositories/_repos_table.html.haml", "diff": ".badge Forks\n%th.col-xs-3 Description\n%th.col-xs-1 Stars\n- %th.col-xs-1.5 Judges\n%th.col-xs-1 Ignored\n- %th.col-xs-2 Actions\n%th.col-xs-1 To be Ignored?\n%tbody\n- @repos.each do |repo|\n.badge= child_count(repo.id)\n%td.col-xs-3= repo.description\n%td.col-xs-1= repo.stars\n- %td.col-xs-1.5{id: \"judges_#{repo._id}\"}= repo.judges_name\n%td.col-xs-1= repo.ignore ? 'Yes' : 'No'\n- %td.col-xs-2\n- %a{href: assign_judge_admin_repository_path(repo), class: \"btn btn-primary btn-sm\", \"data-remote\": \"true\"}\n- %i.fa.fa-plus\n- Assign Judge\n%td.col-xs-1\n%input.secondary{:type => \"checkbox\", name: \"ignore\",checked: check_boolean(\"#{repo.ignore}\"), id: \"#{repo.id}\"}\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_admin_sidebar.html.haml", "new_path": "app/views/application/_admin_sidebar.html.haml", "diff": "%a{href: admin_repositories_path}\n%i.fa.fa-circle-o\n%span Repositories\n- %li\n- %a{href: admin_judges_path}\n- %i.fa.fa-circle-o\n- %span Judges\n%li\n%a{href: admin_ignored_files_path}\n%i.fa.fa-circle-o\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed admin `Judges` tab and `judges`,'Actions' column from admin repos tab.
332,110
11.05.2018 13:53:16
-19,080
68b1d059717ec20f71ec55253969ec569bc0b90a
Removed "Judging" tab from application sidebar.
[ { "change_type": "MODIFY", "old_path": "app/views/application/_sidebar.html.haml", "new_path": "app/views/application/_sidebar.html.haml", "diff": "= link_to activities_path do\n%i.fa.fa-cubes\n%span Contributions\n- - if current_user.is_judge\n- %li{class: is_active('commits', 'judging') || is_active('activities', 'judging')}\n- = link_to commits_judging_index_path do\n- %i.fa.ion-ribbon-b\n- %span Judging\n= render 'admin_sidebar' if current_user.is_admin?\n= render 'orgs_sidebar' if current_user.organizations.any?\n%li{class: is_active('index', 'sponsorer_details')}\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed "Judging" tab from application sidebar.
332,110
11.05.2018 14:11:52
-19,080
59ffabbce4806db403d6f4d397ee9bd1212b4376
Removed all the unused files from previous two commits.
[ { "change_type": "DELETE", "old_path": "app/controllers/admin/judges_controller.rb", "new_path": null, "diff": "-class Admin::JudgesController < ApplicationController\n- before_action :authenticate_user!\n- before_action :authenticate_admin!\n-\n- def index\n- @judges = User.judges.page(params[:page])\n- end\n-end\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/admin/repositories_controller.rb", "new_path": "app/controllers/admin/repositories_controller.rb", "diff": "@@ -14,15 +14,6 @@ class Admin::RepositoriesController < ApplicationController\nend\nend\n- def assign_judge\n- @judges = User.judges\n- end\n-\n- def add_judges\n- @repo.judges = User.find(params[:judges])\n- @repo.save\n- end\n-\ndef update_ignore_field\n@repo.update_attributes(ignore: params[:ignore_value])\nrepositories = Repository.any_of({popular_repository_id: @repo.id}, {source_gh_id: @repo.gh_id})\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/application_controller.rb", "new_path": "app/controllers/application_controller.rb", "diff": "@@ -37,12 +37,6 @@ class ApplicationController < ActionController::Base\nend\nend\n- def authenticate_judge!\n- unless current_user.is_judge\n- redirect_back(notice: I18n.t('messages.unauthorized_access'))\n- end\n- end\n-\ndef authenticate_admin!\nunless current_user.is_admin?\nredirect_back(notice: I18n.t('messages.unauthorized_access'))\n" }, { "change_type": "DELETE", "old_path": "app/controllers/judging_controller.rb", "new_path": null, "diff": "-class JudgingController < ApplicationController\n- include JudgesActions\n-\n- before_action :authenticate_user!\n- before_action :authenticate_judge!\n- before_action :find_resource, only: [:rate, :comment, :comments]\n-\n- def commits\n- @commits = current_round.commits\n- .page(params[:page])\n- .per(20)\n- .order(commit_date: :desc)\n- # .in(repository: current_user.judges_repository_ids)\n- end\n-\n- def activities\n- @activities = current_round.activities\n- .page(params[:page])\n- .per(20)\n- .order(commented_on: :desc)\n- # .in(repository: current_user.judges_repository_ids)\n- end\n-\n- private\n-\n- def find_resource\n- @resource = if params[:type] == 'commits'\n- Commit.where(id: params[:resource_id]).first\n- #Commit.where(id: params[:id]).in(repository: current_user.judges_repository_ids).first\n- else\n- Activity.where(id: params[:resource_id]).first\n- #Activity.where(id: params[:id]).in(repository: current_user.judges_repository_ids).first\n- end\n-\n- unless @resource\n- render nothing: true, status: 404\n- end\n-\n- if params[:rating].to_i > @resource.max_rating\n- render nothing: true, status: 401\n- end\n- end\n-end\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "@@ -4,7 +4,7 @@ class UsersController < ApplicationController\nbefore_action :authenticate_user!, except: [:show]\ndef index\n- @users = current_user.is_judge? ? User.contestants : [current_user]\n+ @users = [current_user]\nend\ndef show\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/repositories/_assign_judge_form.html.haml", "new_path": null, "diff": "-.modal-dialog\n- .modal-content\n- = simple_form_for @repo, url: add_judges_admin_repository_path(@repo), remote: true do |f|\n- .modal-header\n- %button.close{\"aria-label\" => \"Close\", \"data-dismiss\" => \"modal\", :type => \"button\"}\n- %span{\"aria-hidden\" => \"true\"} &times;\n- %h4.modal-title Assign Judges\n- .modal-body\n- .from-group\n- %label.control-label\n- Select Judge for #{@repo.name} repository\n- .input-group.col-sm-6\n- = select_tag :judges, options_from_collection_for_select(@judges, \"_id\", \"github_handle\", :selected => @repo.judges.map(&:_id)), class: 'form-control', multiple: true, placeholder: \"select members\"\n- .modal-footer\n- %button.btn.btn-default{\"data-dismiss\" => \"modal\", :type => \"button\"} Cancel\n- %button.btn.btn-primary{:type => \"submit\"} Save\n-\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/repositories/add_judges.js.haml", "new_path": null, "diff": "-$('#assign_judge_form').modal('hide')\n-$('#judges_#{@repo._id}').html(\"#{@repo.judges_name}\")\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/repositories/assign_judge.js.haml", "new_path": null, "diff": "-$(\"#assign_judge_form\").html(\"#{escape_javascript(render 'assign_judge_form.html.haml')}\")\n-$('#assign_judge_form').modal('show')\n" }, { "change_type": "MODIFY", "old_path": "app/views/admin/repositories/index.html.haml", "new_path": "app/views/admin/repositories/index.html.haml", "diff": "= render 'repos_table'\n.pagination-container\n= paginate @repos, remote: true\n-\n-.modal.fade#assign_judge_form\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -57,8 +57,6 @@ Rails.application.routes.draw do\nget :search, on: :collection\nmember do\npatch :update_ignore_field\n- patch :add_judges\n- get :assign_judge\nend\nend\nresources :users, only: [:index, :destroy] do\n@@ -71,7 +69,6 @@ Rails.application.routes.draw do\nresources :subscriptions, only: [:index]\n- resources :judges, only: [:index]\nresources :rounds, only: [:index] do\nget :mark_as_close\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed all the unused files from previous two commits.
332,110
11.05.2018 15:51:51
-19,080
6bb9088b3619af53e1432536a699508660f9cef4
Removed admin judges related view files.
[ { "change_type": "MODIFY", "old_path": "app/controllers/admin/repositories_controller.rb", "new_path": "app/controllers/admin/repositories_controller.rb", "diff": "class Admin::RepositoriesController < ApplicationController\nbefore_action :authenticate_user!\nbefore_action :authenticate_admin!\n- before_action :load_repository, only: [ :assign_judge, :add_judges, :update_ignore_field ]\n+ before_action :load_repository, only: :update_ignore_field\ndef index\nstatus = params[:ignored] || false\n@repos = Repository.parent.where(ignore: status, name: /#{params[:query]}/).\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/judges/_judges_table.html.haml", "new_path": null, "diff": "-%table.table.table-hover.table-bordered#judges\n- %thead\n- %tr\n- %th.col-xs-2 Name\n- %th.col-xs-4 Email\n- %th.col-xs-2 Github Handler\n- %tbody\n- - @judges.each do |judge|\n- %tr\n- %td.col-xs-2\n- = link_to judge.name, user_path(judge._id)\n- %td.col-xs-4= judge.email\n- %td.col-xs-2= link_to judge.github_handle, github_url(judge)\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/judges/index.html.haml", "new_path": null, "diff": "-%section.content-header\n- %h1\n- Judges\n-%section.content\n- .row\n- .col-xs-12\n- .box.box-primary\n- .box-body.table-responsive\n- - if @judges.any?\n- = render 'judges_table'\n- .pagination-container\n- = paginate @judges, params: { controller: 'admin/judges', action: 'index'}, remote: true\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/judges/index.js.erb", "new_path": null, "diff": "-$('#judges').html(\"<%=j render 'judges_table' %>\");\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed admin judges related view files.
332,110
11.05.2018 16:09:44
-19,080
5c9530c29561a23b9dfea2ba884d2f0f3e884feb
Removed admin subscription tab from side bar. Also removed controller and routes.
[ { "change_type": "DELETE", "old_path": "app/controllers/admin/subscriptions_controller.rb", "new_path": null, "diff": "-class Admin::SubscriptionsController < ApplicationController\n- include Admin::SubscriptionsHelper\n-\n- before_action :authenticate_user!\n- before_action :authenticate_admin!\n-\n- def index\n- @subscriptions = SponsorerDetail.asc(:subscription_status).page(params[:page])\n- end\n-\n-end\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/subscriptions/_subscription.html.haml", "new_path": null, "diff": "-%tr\n- %td= link_to subscription.user.name, user_path(subscription.user), target: '_blank'\n- %td= subscription.user.email\n- %td= subscription.sponsorer_type\n- %td= subscription.subscription_status.camelize\n- %td= SPONSOR[\"#{subscription.sponsorer_type.downcase}\"][\"base\"]\n- %td= subscription.updated_at.strftime('%d/%m/%Y %H:%M')\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/subscriptions/index.html.haml", "new_path": null, "diff": "-%section.content-header\n- %h1\n- Subscriptions\n- %span.badge $ #{total_subscription_amount}\n-%section.content\n- .row\n- .col-xs-12\n- .box.box-primary\n- .box-body.table-responsive\n- %table.table.table-hover.table-bordered\n- %thead\n- %tr\n- %th.col-xs-1 Name\n- %th.col-xs-2 Email\n- %th.col-xs-1 Type\n- %th.col-xs-1 Status\n- %th.col-xs-1 Amount\n- %th.col-xs-1 Created At\n-\n- %tbody#subscriptions\n- = render partial: 'subscription', collection: @subscriptions\n- .pagination-container\n- = paginate @subscriptions, remote: true\n" }, { "change_type": "DELETE", "old_path": "app/views/admin/subscriptions/index.js.erb", "new_path": null, "diff": "-$('#subscriptions').html(\"<%=j render(partial: 'subscription', collection: @subscriptions) %>\");\n-$(\".pagination-container\").html(\"<%=j(paginate @subscriptions, remote: true)%>\")\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_admin_sidebar.html.haml", "new_path": "app/views/application/_admin_sidebar.html.haml", "diff": "%a{href: admin_users_path}\n%i.fa.fa-circle-o\n%span Users\n- %li\n- %a{href: admin_subscriptions_path}\n- %i.fa.fa-circle-o\n- %span Subscriptions\n%li\n%a{href: admin_repositories_path}\n%i.fa.fa-circle-o\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -67,8 +67,6 @@ Rails.application.routes.draw do\nend\nend\n- resources :subscriptions, only: [:index]\n-\nresources :rounds, only: [:index] do\nget :mark_as_close\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed admin subscription tab from side bar. - Also removed controller and routes.
332,110
11.05.2018 16:20:58
-19,080
d6beb7e608a4f64dbb351af91541e54b6b87c3b4
Displayed active users count in admin users tab.
[ { "change_type": "MODIFY", "old_path": "app/views/admin/users/index.html.haml", "new_path": "app/views/admin/users/index.html.haml", "diff": "%section.content-header\n%h1\n- Users :-\n+ Users\n+ %span.badge #{@users.count}\n%label.slide\n%input#blocked{checked: !(@status == \"true\"), type: 'checkbox', data: { toggle: 'toggle', width: '80', height: '40', on: 'Allowed', off: 'Blocked' }}\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Displayed active users count in admin users tab.
332,099
11.05.2018 15:54:19
-19,080
2f5a73a5b534e00d364a6cde535e99d7a48410cd
Fixed the Home Page CodeCuriosity NavBar Also fixed and removed some specs
[ { "change_type": "MODIFY", "old_path": "app/views/application/_navbar.html.haml", "new_path": "app/views/application/_navbar.html.haml", "diff": "%span.logo-lg\n= image_tag 'logo_50pxh.png', height: 35\n%nav.navbar.navbar-static-top{:role => 'navigation'}\n+ - if current_user\n%a.sidebar-toggle{'data-toggle' => 'offcanvas', :href => '#', :role => 'button', style: \"padding-left: 11px; padding-right: 12px;\"}\n%span.sr-only Toggle navigation\n.navbar-custom-menu\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_user_nav.html.haml", "new_path": "app/views/application/_user_nav.html.haml", "diff": "-%li.dropdown.tasks-menu\n- %a.dropdown-toggle{ data: { toggle: 'dropdown' }}\n- %i.fa.fa-calendar :\n- %span.current-round= current_round.from_date.strftime(\"%b %Y\")\n- %ul.dropdown-menu\n- %li\n- %ul.menu\n- - @rounds.each do |round|\n- %li\n- = link_to round.from_date.strftime(\"%b %Y\"), change_round_path(round)\n%li.dropdown.user.user-menu\n%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => '#'}\n%img.user-image#profile-pic{:alt => current_user.name, :src => avatar_url}/\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/home_controller_test.rb", "new_path": "test/controllers/home_controller_test.rb", "diff": "@@ -27,16 +27,4 @@ class HomeControllerTest < ActionController::TestCase\nassert_template partial: '_trend'\nend\n- test 'should get trends' do\n- get :trend\n- assert_response :success\n- assert_template :trend\n- end\n-\n- test 'should get trends for a goal' do\n- get :trend, goal_id: @goal.id\n- assert_response :success\n- assert_template :trend\n- end\n-\nend\n" }, { "change_type": "DELETE", "old_path": "test/controllers/sponsorer_details_controller_test.rb", "new_path": null, "diff": "-require \"test_helper\"\n-\n-class SponsorerDetailsControllerTest < ActionController::TestCase\n-\n- before(:all) do\n- round = create(:round, :status => 'open')\n- @user = create(:user, :auth_token => 'dah123rty')\n- end\n-\n- test \"should not render index to not-logged in user\" do\n- get :index\n- assert_response :redirect\n- assert_redirected_to new_user_session_path\n- end\n-\n- test \"should render index to logged-in user who is sponsor\" do\n- @user.is_sponsorer = true\n- role = create(:role, name: 'Sponsorer')\n- @user.roles << role\n- @user.save\n- sign_in @user\n- get :index\n- assert_response :success\n- end\n-\n- test \"should skip set goal for every action related to sponsor\" do\n-\n- end\n-\n- test \"should be compulsory to set goal if sponsor want to access pages other than sponsor\" do\n- @user.is_sponsorer = true\n- role = create(:role, name: 'Sponsorer')\n- @user.roles << role\n- @user.save\n- sign_in @user\n- old_controller = @controller\n- @controller = DashboardController.new\n- get :index\n- assert_redirected_to goals_path\n- @controller = ActivitiesController.new\n- end\n-\n- test \"creates a valid stripe customer with subscription\" do\n- file = fixture_file_upload(\"#{Rails.root}/test/fixtures/rails.png\", \"image/png\")\n- sign_in(@user)\n-\n- stripe_helper = StripeMock.create_test_helper\n-\n- stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\n-\n- assert_difference 'SponsorerDetail.count' do\n- post :create, sponsorer_detail: { sponsorer_type: \"ORGANIZATION\", avatar: file, publish_profile: \"1\", payment_plan: \"base\" },\n- stripeToken: stripe_helper.generate_card_token(last4: '4242', exp_year: Time.now.year + 1), stripeEmail: @user.email\n- @sponsor = SponsorerDetail.all[-1]\n- assert_equal @sponsor.user.email, @user.email\n- assert_not_nil @sponsor.stripe_customer_id\n- assert_not_nil @sponsor.stripe_subscription_id\n- assert_not_nil @sponsor.subscribed_at\n- assert_not_nil @sponsor.subscription_expires_at\n- assert_not_nil @sponsor.subscription_status\n- end\n- end\n-\n- test \"does not create subscription if form data is not valid\" do\n- sign_in @user\n- stripe_helper = StripeMock.create_test_helper\n-\n- stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\n-\n- assert_difference 'SponsorerDetail.count', 0 do\n- post :create, sponsorer_detail: { sponsorer_type: \"ORGANIZATION\", avatar: nil, publish_profile: \"1\", payment_plan: \"abc\" },\n- stripeToken: stripe_helper.generate_card_token(last4: '4242', exp_year: Time.now.year + 1), stripeEmail: @user.email\n- end\n- assert_not_nil flash[:error]\n- end\n-\n- test \"does not create sponsorer if error while creating stripe subscription\" do\n- file = fixture_file_upload(\"#{Rails.root}/test/fixtures/rails.png\", \"image/png\")\n- sign_in @user\n- stripe_helper = StripeMock.create_test_helper\n-\n- stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\n-\n- assert_difference 'SponsorerDetail.count', 0 do\n- post :create, sponsorer_detail: { sponsorer_type: \"ORGANIZATION\", avatar: file, publish_profile: \"1\", payment_plan: \"base\" },\n- stripeToken: 'invalid_token1', stripeEmail: @user.email\n- end\n- assert_not_nil flash[:error]\n- end\n-\n- test \"redirect to sponsorer dashboard on save\" do\n- file = fixture_file_upload(\"#{Rails.root}/test/fixtures/rails.png\", \"image/png\")\n- sign_in(@user)\n- stripe_helper = StripeMock.create_test_helper\n-\n- stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\n-\n- assert_difference 'SponsorerDetail.count' do\n- post :create, sponsorer_detail: { sponsorer_type: \"ORGANIZATION\", avatar: file, publish_profile: \"1\", payment_plan: \"base\" },\n- stripeToken: stripe_helper.generate_card_token(last4: '4242', exp_year: Time.now.year + 1), stripeEmail: @user.email\n- end\n- assert_redirected_to sponsorer_details_path\n- assert_equal flash[:notice], 'saved sponsorship details successfully'\n- end\n-\n- test \"should send a mail after sponsorer is successfully created\" do\n- file = fixture_file_upload(\"#{Rails.root}/test/fixtures/rails.png\", \"image/png\")\n- sign_in(@user)\n- stripe_helper = StripeMock.create_test_helper\n-\n- stripe_helper.create_plan(amount: 15000, name: 'base', id: 'base-organization', interval: 'month', currency: 'usd')\n-\n- assert_enqueued_jobs 2 do\n- post :create, sponsorer_detail: { sponsorer_type: \"ORGANIZATION\", avatar: file, publish_profile: \"1\", payment_plan: \"base\" },\n- stripeToken: stripe_helper.generate_card_token(last4: '4242', exp_year: Time.now.year + 1), stripeEmail: @user.email\n- end\n- end\n-\n-end\n" }, { "change_type": "MODIFY", "old_path": "test/controllers/widgets_controller_test.rb", "new_path": "test/controllers/widgets_controller_test.rb", "diff": "@@ -45,14 +45,4 @@ class WidgetsControllerTest < ActionController::TestCase\n@repo.leaders(@round)\nend\nend\n-\n- test 'should display scores correctly in repo widget' do\n- commit_2 = create(:commit, auto_score: 1, repository: @repo)\n- @user.repositories << @repo\n- @round.commits << commit_2\n- assert_nothing_raised RuntimeError do\n- @repo.leaders(@round)\n- end\n- end\n-\nend\n" }, { "change_type": "DELETE", "old_path": "test/integration/group_flows_test.rb", "new_path": null, "diff": "-require \"test_helper\"\n-\n-class GroupFlowsTest < ActionDispatch::IntegrationTest\n- before(:all) do\n- @round = create(:round, status: 'open')\n- @user = create(:user, name: 'josh', auth_token: 'dah123rty', github_user_since: Date.today, goal: create(:goal))\n- Warden.test_mode!\n- end\n-\n- after(:all) do\n- Capybara.reset_sessions!\n- end\n-\n- test \"clicking on the new group shows the group form\" do\n- login_as @user\n- visit groups_path\n- #checking section-header content\n- within 'section.content-header' do\n- assert page.has_content?('Groups')\n- assert page.has_link?('New Group')\n- click_link('New Group')\n- end\n- #clicking on New Group shows new form\n- within 'section.content' do\n- #checking form\n- page.assert_selector('form')\n- #checking textboxes\n- page.assert_selector('input', count: 1)\n- page.assert_selector('textarea', count: 1)\n- page.has_select?('input', name: 'name')\n- page.has_select?('textarea', name: 'description')\n- #checking create button\n- page.has_button?('Create')\n- end\n- end\n-\n- test \"should not submit form if group name or group description is empty\" do\n- login_as @user\n- visit new_group_path\n- #form validation\n- within 'section.content' do\n- click_button('Create')\n- assert_empty find_field('group_name').value\n- assert_empty find_field('group_description').value\n- assert page.has_content? \"can't be blank\"\n- end\n- end\n-\n- test \"should show created group and users after clicking on create button\" do\n- login_as @user\n- visit new_group_path\n- #filling form\n- within 'section.content' do\n- fill_in 'group_name', with: 'OpensourceContributor'\n- fill_in 'group_description', with: 'participate in this'\n- click_button('Create')\n- end\n- #after clicking on create button it should render show page with group name\n- assert page.find('section.content-header').has_content?('Group: OpensourceContributor')\n- #checking created group contents\n- within 'section.content' do\n- assert page.has_content?('Detail')\n- assert page.has_content?('participate in this')\n- assert page.has_content?('Users')\n- assert page.has_content?('josh')\n- end\n- end\n-\n- test \"only group owner can edit and add members to group\" do\n- login_as @user\n- create_group\n- visit group_path(@group)\n- #edit_link and add members_link should be accessible to only group owner\n- within 'section.content' do\n- assert page.has_link?('Edit')\n- assert page.has_link?('Add Members')\n- end\n- end\n-\n- test \"clicking on the group name in the widget shows the group details\" do\n- login_as @user\n- create_group\n- visit group_widget_path(@group)\n- within '.box' do\n- assert page.has_link?('opensource')\n- click_link('opensource')\n- end\n- #clicking on group name opens group in different window\n- page.switch_to_window(page.windows.last)\n- #page.save_and_open_screenshot\n- #showing group details on clicking group\n- assert page.find('section.content-header').has_content?('Group: opensource')\n- within 'section.content' do\n- assert page.has_content?('participate in this')\n- assert page.has_content?('Users')\n- assert page.has_content?('josh')\n- end\n- end\n-\n- test \"clicking on the group name in the widget shows the group details even if the user is not logged in \" do\n- create_group\n- visit group_widget_path(@group)\n- within '.box' do\n- click_link('opensource')\n- end\n- page.switch_to_window(page.windows.last)\n- #page.save_and_open_screenshot\n- assert page.find('section.content-header').has_content?('Group: opensource')\n- end\n-\n- test \"clicking on the user name in the widget shows the user profile\" do\n- login_as @user\n- sub = create(:subscription, user: @user, :points => 1)\n- @round.subscriptions << sub\n- create_group\n- visit group_widget_path(@group)\n-\n- page.switch_to_window(page.window_opened_by{\n- page.find(:css, 'li', match: :first).click\n- })\n- #page.save_and_open_screenshot\n- assert page.find('section.content-header').has_content?('User Profile')\n- assert page.find('section.content').has_content?('josh'.titleize)\n- end\n-\n- test \"clicking on the user name in the widget shows the user profile even if the user is not logged in\" do\n- sub = create(:subscription, user: @user, :points => 1)\n- @round.subscriptions << sub\n- create_group\n- visit group_widget_path(@group)\n-\n- page.switch_to_window(page.window_opened_by{\n- page.find(:css, 'li', match: :first).click\n- })\n- #page.save_and_open_screenshot\n- assert page.find('section.content-header').has_content?('User Profile')\n- end\n-\n- test \"group widget shows only last 3 months\" do\n- round2 = create(:round, from_date: 1.month.ago, end_date: 1.month.ago + 31.days)\n- round3 = create(:round, from_date: 2.month.ago, end_date: 2.month.ago + 31.days)\n- round4 = create(:round, from_date: 3.month.ago, end_date: 3.month.ago + 31.days)\n- create_group\n- visit group_widget_path(@group)\n- within '.box' do\n- assert page.has_link?(round2.from_date.strftime('%b %y'))\n- assert page.has_link?(round3.from_date.strftime('%b %y'))\n- assert page.has_link?(@round.from_date.strftime('%b %y'))\n- assert page.has_no_link?(round4.from_date.strftime('%b %y'))\n- end\n- end\n-\n- def create_group\n- @group = create(:group, name: 'opensource', description: 'participate in this')\n- @group.owner = @user\n- @user.groups << @group\n- end\n-end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fixed the Home Page CodeCuriosity NavBar Also fixed and removed some specs
332,110
11.05.2018 16:43:46
-19,080
22a5a2b54609d21568b0e32b21e6109f9b705d0e
Removed `Admin Redeem Request` tab from Admin side bar. Not removed controller code and views, as it may be required in the future.
[ { "change_type": "MODIFY", "old_path": "app/views/application/_admin_sidebar.html.haml", "new_path": "app/views/application/_admin_sidebar.html.haml", "diff": "%a{href: admin_ignored_files_path}\n%i.fa.fa-circle-o\n%span Ignored Files\n- %li\n- %a{href: admin_redeem_requests_path}\n- %i.fa.fa-credit-card-alt\n- %span Redeem Requests\n+ / It can be used in the future, hence commenting.\n+ / %li\n+ / %a{href: admin_redeem_requests_path}\n+ / %i.fa.fa-credit-card-alt\n+ / %span Redeem Requests\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -70,12 +70,12 @@ Rails.application.routes.draw do\nresources :rounds, only: [:index] do\nget :mark_as_close\nend\n-\n- resources :redeem_requests, only: [:index, :update, :destroy] do\n- collection do\n- get :download\n- end\n- end\n+ # It can be used in the future, hence commenting.\n+ # resources :redeem_requests, only: [:index, :update, :destroy] do\n+ # collection do\n+ # get :download\n+ # end\n+ # end\nresources :ignored_files, except: [:show] do\nget :search, on: :collection\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed `Admin Redeem Request` tab from Admin side bar. Not removed controller code and views, as it may be required in the future.
332,099
11.05.2018 17:00:39
-19,080
9edfd8a5473643d15ba5a8de2a9ecb1e86ebc0d0
Removed activities tab from dashboard, Remaining to remove activity from graph
[ { "change_type": "MODIFY", "old_path": "app/views/dashboard/index.html.haml", "new_path": "app/views/dashboard/index.html.haml", "diff": ".col-lg-3.col-xs-6\n= react_component 'PointsTile', { color: 'bg-green', title: 'Commits', points: current_user.commits_count,\nlogo: 'ion-stats-bars', path: activities_path(anchor: 'commits')}\n- .col-lg-3.col-xs-6\n- = react_component 'PointsTile', { color: 'bg-yellow', title: 'Activities', points: current_user.activities_count,\n- logo: 'ion-chatboxes', path: activities_path(anchor: 'activities') }\n.row\n= react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed activities tab from dashboard, Remaining to remove activity from graph
332,104
11.05.2018 17:05:29
-19,080
5a1825456363af3e4bf5a20376e989383c15599c
Removed rounds and redeem points buttom from user profile
[ { "change_type": "MODIFY", "old_path": "app/controllers/users_controller.rb", "new_path": "app/controllers/users_controller.rb", "diff": "class UsersController < ApplicationController\n- include ContributionHelper\ninclude SponsorerHelper\nbefore_action :authenticate_user!, except: [:show]\n@@ -10,8 +9,6 @@ class UsersController < ApplicationController\ndef show\n@user = User.find(params[:id])\nif @user\n- @show_transactions = current_user == @user\n- contribution_data(@user)\nrender layout: current_user ? 'application' : 'public'\nelse\nredirect_to root_url, alert: I18n.t('user.not_exist_in_system')\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_sidebar.html.haml", "new_path": "app/views/application/_sidebar.html.haml", "diff": "%span Judging\n= render 'admin_sidebar' if current_user.is_admin?\n= render 'orgs_sidebar' if current_user.organizations.any?\n- %li{class: is_active(params[:action], 'groups') || is_active(params[:action], 'groups/members')}\n- = link_to groups_path do\n- %i.fa.fa-users\n- %span Groups\n- %li{class: is_active(params[:action], 'users')}\n- = link_to user_path(current_user, anchor: 'wallet') do\n- %i.fa.fa-gift\n- %span Redeem points\n-\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%li.list-group-item\n%b Earned\n%a.pull-right $ #{amount_earned @user}\n- - if logged_in_user?\n- - if Offer.is_winner?(current_user) || @user.active_sponsorer_detail || @user.able_to_redeem?\n- = link_to '#', class: \"btn btn-primary btn-block\", data: { toggle: 'modal', target: '#redeem-modal .modal' } do\n- %b Redeem Points\n- - else\n- %span.tool-tip{\"data-placement\" => \"top\", \"data-toggle\" => \"tooltip\", :title => \"Not met the redemption criteria\"}\n- %span.btn.btn-primary.btn-block{:disabled => \"disabled\"} Redeem Points\n-\n.col-sm-8\n.nav-tabs-custom\n%ul.nav.nav-tabs\n- %li.active#rounds_tab_link\n- = link_to 'Rounds', '#rounds', data: { toggle: 'tab'}\n%li#wallet_tab_link\n= link_to 'Points History', '#wallet', data: { toggle: 'tab' }\n- if logged_in_user?\n%li#wallet_tab_link\n= link_to 'Settings', '#settings', data: { toggle: 'tab' }\n.tab-content\n- .tab-pane.active#rounds\n- - if @show_transactions\n- = render partial: 'share_button'\n- .row\n- = react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n- = react_component 'SubscriptionsHistory', { user_id: @user.id }\n- .tab-pane#wallet\n+ .tab-pane.active#wallet\n= render 'transactions'\n- if logged_in_user?\n.tab-pane#settings\n= render 'settings'\n- %b\n- - if logged_in_user?\n- Info:\n- %i= t('transaction.points_credit_info')\n- %br\n- %br\n- %b\n- = t('transaction.free_plan')\n- %i= t('transaction.free_plan_info')\n- %p\n- %b\n- = t('transaction.paid_plan')\n- %i= t('transaction.paid_plan_info')\n-\n-\n- if logged_in_user?\n#redeem-modal\n.modal.fade\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Removed rounds and redeem points buttom from user profile
332,098
14.05.2018 13:40:21
-19,080
dccfdcfc2a244a09924ece96c7de5a9d69a23ae5
Add frequency_factor_calculator service and set frequency_factor before commit save
[ { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -26,7 +26,6 @@ class Commit\nhas_many :comments, as: :commentable\nembeds_many :scores, as: :scorable\n- validates :round, presence: true\nvalidates :message, uniqueness: {:scope => :commit_date}\nscope :for_round, -> (round_id) { where(:round_id => round_id) }\n@@ -45,6 +44,12 @@ class Commit\n#after_create :schedule_scoring_job\n+ before_create :set_frequency_factor\n+\n+ def set_frequency_factor\n+ self.frequency_factor = FrequencyFactorCalculator.new(self).result\n+ end\n+\ndef info\n@info ||= repository ? user.gh_client.repos.commits.get(repository.owner, repository.name, sha, { redirection: true }) : nil\nend\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/services/frequency_factor_calculator.rb", "diff": "+class FrequencyFactorCalculator\n+ def initialize(commit)\n+ @user = commit.user\n+ @commit = commit\n+ end\n+\n+ attr_reader :user, :commit\n+\n+ def result\n+ 1 + (weight / threshold)\n+ end\n+\n+ private\n+\n+ def weight\n+ [weight_sum, 0].max\n+ end\n+\n+ def weight_sum\n+ evaluation_days.collect do |date|\n+ date.in?(number_of_days_commited) ? 1 : -1\n+ end.sum.to_f\n+ end\n+\n+ def threshold\n+ SCORING_ENGINE_CONFIG[:frequency_factor_threshold]\n+ end\n+\n+ def number_of_days_commited\n+ @number_of_days_commited ||= user.commits.where(:commit_date.gt => from_date, :commit_date.lt => to_date)\n+ .asc(:commit_date)\n+ .pluck(:commit_date)\n+ .collect(&:to_date)\n+ end\n+\n+ def evaluation_days\n+ (from_date..to_date).collect(&:to_date)\n+ end\n+\n+ def from_date\n+ @from_date ||= commit.commit_date - threshold.days\n+ end\n+\n+ def to_date\n+ @to_date ||= commit.commit_date - 1.day\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "config/code_curiosity_config.yml", "new_path": "config/code_curiosity_config.yml", "diff": "@@ -52,6 +52,7 @@ scoring_engine:\n:commit_default_weightage: 0.45\n:bugspot_weightage: 0.45\n:bugspot_scores_threshold: 2\n+ :frequency_factor_threshold: 30\nsubscriptions:\nfree: 20\n" }, { "change_type": "MODIFY", "old_path": "test/models/commit_test.rb", "new_path": "test/models/commit_test.rb", "diff": "@@ -65,6 +65,23 @@ class CommitTest < ActiveSupport::TestCase\nassert_equal commit_2.round, round_2\nend\n+ def test_frequency_factor_without_previous_commit\n+ commit_1 = create(:commit, message: Faker::Lorem.sentences, commit_date: Date.today)\n+ assert_equal commit_1.frequency_factor, 1\n+ end\n+\n+ def test_frequency_factor_with_previous_commit\n+ user = create(:user)\n+ 25.times.each do |n|\n+ create(:commit, user: user, message: Faker::Lorem.sentences, commit_date: Date.today - (n + 1).day)\n+ end\n+ commit_1 = create(:commit, user: user, message: Faker::Lorem.sentences, commit_date: Date.today)\n+ assert_equal commit_1.frequency_factor > 1.0, true\n+ end\n+\n+ def test_frequency_factor_should_not_be_negative\n+ end\n+\n=begin\ntest 'commit scoring job is scheduled after the commit is created' do\nclear_enqueued_jobs\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Add frequency_factor_calculator service and set frequency_factor before commit save
332,095
14.05.2018 12:42:03
-19,080
7ec24b9886c622f72b1ff50d95a76b251599f328
fetch git commits for given user, repo, date range
[ { "change_type": "ADD", "old_path": null, "new_path": "app/models/test.rb", "diff": "+class Test\n+ include VCS\n+\n+ attr_reader :user, :git_username, :repo_name,\n+ :branch_name, :from_date, :to_date\n+\n+ def initialize(user: , repo_name: , branch_name: , **options)\n+ @user = user\n+ @repo_name = repo_name\n+ @branch_name = branch_name\n+ @git_username = options[:git_username].presence || user.github_handle\n+ @from_date = options[:from_date].presence || Date.yesterday.beginning_of_day\n+ @to_date = options[:to_date].presence || Date.yesterday.end_of_day\n+ end\n+\n+ def fetch_and_store_commits\n+ commits_list = fetch_commits(repo_name, branch_name)\n+\n+ commits_list.each do |commit|\n+ commit_record = user.commits.find_or_initialize_by( sha: commit['sha'] )\n+\n+ commit_record.message = commit['commit']['message']\n+ commit_record.commit_date = commit['commit']['committer']['date']\n+ commit_record.html_url = commit['html_url']\n+ commit_record.comments_count = commit['commit']['comment_count']\n+\n+ commit_record.save\n+ end\n+ end\n+\n+ def fetch_commits(repo_name, branch_name)\n+ ::VCS::GitCommit.new(\n+ git_username: git_username,\n+ repo_name: repo_name,\n+ branch_name: branch_name\n+ ).list\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/vcs/git_branch.rb", "diff": "+module VCS\n+ class GitBranch\n+ attr_reader :git_username, :repo_name\n+\n+ def initialize(git_username: , repo_name: )\n+ @git_username = git_username\n+ @repo_name = repo_name\n+ end\n+\n+ def list\n+ GITHUB.repos.branches(user: git_username, repo: repo_name).list\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/vcs/git_commit.rb", "diff": "+module VCS\n+ class GitCommit\n+ attr_reader :git_username, :repo_name, :author_username,\n+ :branch_name, :from_date, :to_date\n+\n+ def initialize(**options)\n+ @git_username = options[:git_username]\n+ @repo_name = options[:repo_name]\n+ @author_username = options[:author_username].presence || git_username\n+ @branch_name = options[:branch_name]\n+ @from_date = options[:from_date]\n+ @to_date = options[:to_date]\n+ end\n+\n+ def list\n+ GITHUB.repos.commits.list(\n+ user: git_username,\n+ repo: repo_name,\n+ author: author_username,\n+ sha: branch_name,\n+ since: from_date,\n+ until: to_date\n+ )\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/vcs/git_repository.rb", "diff": "+module VCS\n+ class GitRepository\n+ attr_reader :git_username\n+\n+ def initialize(git_username: )\n+ @git_username = git_username\n+ end\n+\n+ def list\n+ GITHUB.repos(user: git_username).list\n+ end\n+ end\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
fetch git commits for given user, repo, date range
332,090
16.05.2018 18:44:25
-19,080
3a6e6723188fcdfb4068cc3190c633e8bd8611a4
Add commit fetching logic. 1. Add Test Model. 2. classes to fetch commits, repositories and branches. 3. Add branches field in Repository model.
[ { "change_type": "MODIFY", "old_path": "app/models/repository.rb", "new_path": "app/models/repository.rb", "diff": "@@ -19,6 +19,7 @@ class Repository\nfield :ignore_files, type: Array, default: []\nfield :type, type: String\nfield :ignore, type: Boolean, default: false\n+ field :branches, type: Array, default: ['master']\nbelongs_to :popular_repository, class_name: 'Repository', inverse_of: 'repositories'\nbelongs_to :organization\n" }, { "change_type": "MODIFY", "old_path": "app/models/test.rb", "new_path": "app/models/test.rb", "diff": "class Test\ninclude VCS\n- attr_reader :user, :git_username, :repo_name,\n+ attr_reader :repo_owner, :repo_name,\n:branch_name, :from_date, :to_date\n- def initialize(user: , repo_name: , branch_name: , **options)\n- @user = user\n- @repo_name = repo_name\n- @branch_name = branch_name\n- @git_username = options[:git_username].presence || user.github_handle\n- @from_date = options[:from_date].presence || Date.yesterday.beginning_of_day\n- @to_date = options[:to_date].presence || Date.yesterday.end_of_day\n+ def initialize(**options)\n+ @repo_owner = options[:repo_owner]\n+ @repo_name = options[:repo_name]\n+ @branch_name = options[:branch_name]\n+ @from_date = options[:from_date]\n+ @to_date = options[:to_date]\nend\ndef fetch_and_store_commits\ncommits_list = fetch_commits(repo_name, branch_name)\ncommits_list.each do |commit|\n+ user = User.contestants.find_by(email: commit['commit']['author']['email'])\n+ repo = Repository.find_by(name: repo_name, owner: repo_owner)\n+\n+ if user && user.created_at < commit['commit']['committer']['date']\ncommit_record = user.commits.find_or_initialize_by( sha: commit['sha'] )\n+ commit_record.repository = repo\ncommit_record.message = commit['commit']['message']\ncommit_record.commit_date = commit['commit']['committer']['date']\ncommit_record.html_url = commit['html_url']\n@@ -27,12 +31,15 @@ class Test\ncommit_record.save\nend\nend\n+ end\ndef fetch_commits(repo_name, branch_name)\n::VCS::GitCommit.new(\n- git_username: git_username,\n+ repo_owner: repo_owner,\nrepo_name: repo_name,\n- branch_name: branch_name\n+ branch_name: branch_name,\n+ from_date: from_date,\n+ to_date: to_date\n).list\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "lib/vcs/git_commit.rb", "new_path": "lib/vcs/git_commit.rb", "diff": "module VCS\nclass GitCommit\n- attr_reader :git_username, :repo_name, :author_username,\n+ attr_reader :repo_owner, :repo_name,\n:branch_name, :from_date, :to_date\ndef initialize(**options)\n- @git_username = options[:git_username]\n+ @repo_owner = options[:repo_owner]\n@repo_name = options[:repo_name]\n- @author_username = options[:author_username].presence || git_username\n@branch_name = options[:branch_name]\n@from_date = options[:from_date]\n@to_date = options[:to_date]\nend\ndef list\n- GITHUB.repos.commits.list(\n- user: git_username,\n+ GitApp.info.repos.commits.list(\n+ user: repo_owner,\nrepo: repo_name,\n- author: author_username,\nsha: branch_name,\nsince: from_date,\n- until: to_date\n+ \"until\": to_date\n)\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Add commit fetching logic. 1. Add Test Model. 2. classes to fetch commits, repositories and branches. 3. Add branches field in Repository model.
332,090
18.05.2018 17:14:27
-19,080
384f80fb52eb274a59b9169efecb2e0faa27dfd4
Commits Fetch Task 1. Add FetchCommitJob, GitApp model and fetch commits task.
[ { "change_type": "ADD", "old_path": null, "new_path": "app/jobs/fetch_commit_job.rb", "diff": "+class FetchCommitJob < ActiveJob::Base\n+ include Sidekiq::Status::Worker\n+ include ActiveJobRetriesCount\n+ queue_as :git\n+\n+ def perform(repo_owner: , repo_name: , branch_name: , **options)\n+ from_date = options[:from_date].presence || Date.yesterday.beginning_of_day\n+ to_date = options[:to_date].presence || Date.yesterday.end_of_day\n+\n+ Sidekiq.logger.info \"************************ Commit Job Logger Info **************************\"\n+ Sidekiq.logger.info \"Fetching commits of repository: #{repo_name} and owner: #{repo_owner} on the branch: #{branch_name}\"\n+ Sidekiq.logger.info \"from: #{from_date} to: #{to_date}\"\n+\n+ begin\n+ Test.new(\n+ repo_owner: repo_owner,\n+ repo_name: repo_name,\n+ branch_name: branch_name,\n+ from_date: from_date,\n+ to_date: to_date\n+ ).fetch_and_store_commits\n+ rescue Github::Error::NotFound\n+ # repository moved or deleted means we no longer care about this repos.\n+ Sidekiq.logger.info \"Raised Github::Error::NotFound Exception\"\n+ rescue Github::Error::UnavailableForLegalReasons\n+ # repository permission invoked.\n+ Sidekiq.logger.info \"Raised Github::Error::UnavailableForLegalReasons Exception\"\n+ rescue Github::Error::Unauthorized\n+ Sidekiq.logger.info \"Raised Github::Error::Unauthorized Exception\"\n+ GitApp.inc\n+ retry_job wait: 5.minutes if @retries_count < MAX_RETRY_COUNT\n+ rescue Github::Error::Forbidden\n+ Sidekiq.logger.info \"Raised Github::Error::Forbidden Exception\"\n+ GitApp.inc\n+ retry_job wait: 5.minutes if @retries_count < MAX_RETRY_COUNT\n+ rescue Mongo::Error::SocketError\n+ retry_job wait: 5.minutes if @retries_count < MAX_RETRY_COUNT\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/models/git_app.rb", "diff": "+require 'github_client'\n+require 'git_lib_ext'\n+\n+class GitApp\n+ include Mongoid::Document\n+\n+ @@app_num = 1\n+\n+ def self.app_num\n+ @@app_num\n+ end\n+\n+ def self.app_num=(num)\n+ app_num = num\n+ end\n+\n+ def self.info\n+ info = GIT_INFO['App_' + app_num.to_s]\n+ Github.new(\n+ oauth_token: info['access_tokens'],\n+ client_id: info['git_app_id'],\n+ client_secret: info['git_app_secret']\n+ )\n+ end\n+\n+ def self.inc\n+ app_num += 1\n+ app_num = 1 if app_num > 10\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "config/git.yml", "diff": "+App_1:\n+ access_tokens: your_access_token\n+ git_app_id: your_git_app_id\n+ git_app_secret: your_git_app_secret\n" }, { "change_type": "MODIFY", "old_path": "config/initializers/globals.rb", "new_path": "config/initializers/globals.rb", "diff": "@@ -20,6 +20,7 @@ end\nCOMMIT_RATINGS = (0..5).to_a\nACTIVITY_RATINGS = (0..2).to_a\n+GIT_INFO = YAML.load_file('config/git.yml')\nINFO = YAML.load_file('config/info.yml')\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/tasks/fetch_commits.rake", "diff": "+desc \"Fetch commits daily.\"\n+task :fetch_commits, [:from_date, :to_date] => :environment do |t, args|\n+ from_date = args[:from_date].present? ? args[:from_date] : nil\n+ to_date = args[:to_date].present? ? args[:to_date] : nil\n+ repos = Repository.required\n+\n+ repos.each do |repo|\n+ repo.branches.each do |branch|\n+ FetchCommitJob.perform_later(\n+ repo_owner: repo.owner,\n+ repo_name: repo.name,\n+ branch_name: branch,\n+ from_date: from_date,\n+ to_date: to_date\n+ )\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/factories/git_apps.rb", "diff": "+FactoryGirl.define do\n+ factory :git_app do\n+\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/models/git_app_test.rb", "diff": "+require \"test_helper\"\n+\n+class GitAppTest < ActiveSupport::TestCase\n+ def git_app\n+ @git_app ||= GitApp.new\n+ end\n+\n+ def test_valid\n+ assert git_app.valid?\n+ end\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Commits Fetch Task 1. Add FetchCommitJob, GitApp model and fetch commits task.
332,090
25.05.2018 18:09:21
-19,080
fe9f82da8e43dc0bf2cb256ac1a7b0f22505fd20
change app_num to app_credentials_counter
[ { "change_type": "MODIFY", "old_path": "app/models/git_app.rb", "new_path": "app/models/git_app.rb", "diff": "-require 'github_client'\n-require 'git_lib_ext'\n-\nclass GitApp\ninclude Mongoid::Document\n- @@app_num = 1\n+ @@app_credentials_counter = 1\n- def self.app_num\n- @@app_num\n+ def self.app_credentials_counter\n+ @@app_credentials_counter\nend\n- def self.app_num=(num)\n- app_num = num\n+ def self.app_credentials_counter=(number)\n+ @@app_credentials_counter = number\nend\ndef self.info\n- info = GIT_INFO['App_' + app_num.to_s]\n+ info = GIT_INFO[\"App_#{app_credentials_counter}\"]\nGithub.new(\noauth_token: info['access_tokens'],\nclient_id: info['git_app_id'],\n@@ -24,7 +21,7 @@ class GitApp\nend\ndef self.inc\n- app_num += 1\n- app_num = 1 if app_num > 10\n+ self.app_credentials_counter += 1\n+ self.app_credentials_counter = 1 if self.app_credentials_counter > 10\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
change app_num to app_credentials_counter
332,091
25.05.2018 18:50:50
-19,080
b9e582da0eede7d65b236f18ee07656fcf9fd519
Move backup code under DbBackup folder
[ { "change_type": "ADD", "old_path": null, "new_path": "DbBackup/backup.yml", "diff": "+database:\n+ name: 'code_curiosity'\n+ username: ''\n+ password: ''\n+ host: ''\n+ port: ''\n+storage:\n+ access_key_id: \"\"\n+ secret_access_key: \"\"\n+ region: \"region\"\n+ bucket: \"bucket\"\n+encryptor:\n+ passphrase: \"passphrase\"\n+ mail: \"mail@codecuriosity.com\"\n+notify:\n+ authentication: \"plain\"\n+ from: 'mail@codecuriosity.org'\n+ to: 'mail@codecuriosity.com'\n+ domain: \"codecuriosity.org\"\n+ user_name: \"user_name\"\n+ password: \"password\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "DbBackup/config.rb", "diff": "+# encoding: utf-8\n+\n+##\n+# Backup\n+# Generated Main Config Template\n+#\n+# For more information:\n+#\n+# View the Git repository at https://github.com/meskyanichi/backup\n+# View the Wiki/Documentation at https://github.com/meskyanichi/backup/wiki\n+# View the issue log at https://github.com/meskyanichi/backup/issues\n+\n+##\n+# Utilities\n+#\n+# If you need to use a utility other than the one Backup detects,\n+# or a utility can not be found in your $PATH.\n+#\n+# Backup::Utilities.configure do\n+# tar '/usr/bin/gnutar'\n+# redis_cli '/opt/redis/redis-cli'\n+# end\n+\n+##\n+# Logging\n+#\n+# Logging options may be set on the command line, but certain settings\n+# may only be configured here.\n+#\n+# Backup::Logger.configure do\n+# console.quiet = true # Same as command line: --quiet\n+# logfile.max_bytes = 2_000_000 # Default: 500_000\n+# syslog.enabled = true # Same as command line: --syslog\n+# syslog.ident = 'my_app_backup' # Default: 'backup'\n+# end\n+#\n+# Command line options will override those set here.\n+# For example, the following would override the example settings above\n+# to disable syslog and enable console output.\n+# backup perform --trigger my_backup --no-syslog --no-quiet\n+\n+##\n+# Component Defaults\n+#\n+# Set default options to be applied to components in all models.\n+# Options set within a model will override those set here.\n+#\n+# Backup::Storage::S3.defaults do |s3|\n+# s3.access_key_id = \"my_access_key_id\"\n+# s3.secret_access_key = \"my_secret_access_key\"\n+# end\n+#\n+# Backup::Encryptor::OpenSSL.defaults do |encryption|\n+# encryption.password = \"my_password\"\n+# encryption.base64 = true\n+# encryption.salt = true\n+# end\n+\n+\n+# * * * * * * * * * * * * * * * * * * * *\n+# Do Not Edit Below Here.\n+# All Configuration Should Be Made Above.\n+\n+##\n+# Load all models from the models directory.\n+Dir[File.join(File.dirname(Config.config_file), \"models\", \"*.rb\")].each do |model|\n+ instance_eval(File.read(model))\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "DbBackup/models/code_curiosity_backup.rb", "diff": "+# encoding: utf-8\n+\n+##\n+# Backup Generated: code_curiosity_backup\n+# Once configured, you can run the backup with the following command:\n+#\n+# $ backup perform -t code_curiosity_backup [-c <path_to_configuration_file>]\n+#\n+BACKUP = YAML.load_file('backup.yml')\n+\n+Backup::Model.new(:code_curiosity_backup, 'Description for code_curiosity_backup') do\n+ ##\n+ # MongoDB [Database]\n+ #\n+ database MongoDB do |db|\n+ db.name = BACKUP['database']['name']\n+ db.username = \"\"\n+ db.password = \"\"\n+ db.host = BACKUP['database']['host']\n+ db.port = 27017\n+ db.ipv6 = false\n+ db.only_collections = []\n+ db.additional_options = []\n+ db.lock = false\n+ db.oplog = false\n+ end\n+\n+ ##\n+ # Amazon Simple Storage Service [Storage]\n+\n+ store_with S3 do |s3|\n+ # AWS Credentials\n+ s3.access_key_id = BACKUP['storage']['s3_access_key_id']\n+ s3.secret_access_key = BACKUP['storage']['s3_secret_access_key']\n+ # Or, to use a IAM Profile:\n+ # s3.use_iam_profile = true\n+\n+ s3.region = BACKUP['storage']['region']\n+ s3.bucket = BACKUP['storage']['bucket']\n+ #s3.path = \"/backups\"\n+ s3.keep = 5\n+ # s3.keep = Time.now - 2592000 # Remove all backups older than 1 month.\n+ end\n+\n+ ##\n+ # GPG [Encryptor]\n+ #\n+ # Setting up #keys, as well as #gpg_homedir and #gpg_config,\n+ # would be best set in config.rb using Encryptor::GPG.defaults\n+ #\n+ encrypt_with GPG do |encryption|\n+ # Setup public keys for #recipients\n+ encryption.keys = {}\n+ encryption.keys[BACKUP['encryptor']['mail']] = <<-KEY\n+ KEY\n+\n+ # Specify mode (:asymmetric, :symmetric or :both)\n+ encryption.mode = :asymmetric # defaults to :asymmetric\n+\n+ # Specify recipients from #keys (for :asymmetric encryption)\n+ encryption.recipients = BACKUP['encryptor']['mail']\n+\n+ # Specify passphrase or passphrase_file (for :symmetric encryption)\n+ encryption.passphrase = BACKUP['encryptor']['passphrase']\n+ # encryption.passphrase_file = '~/backup_passphrase'\n+ end\n+\n+ ##\n+ # Gzip [Compressor]\n+ #\n+ compress_with Gzip\n+\n+\n+ ##\n+ # Mail [Notifier]\n+ #\n+ # The default delivery method for Mail Notifiers is 'SMTP'.\n+ # See the documentation for other delivery options.\n+ #\n+ notify_by Mail do |mail|\n+ mail.on_success = true\n+ mail.on_warning = true\n+ mail.on_failure = true\n+\n+ mail.from = BACKUP['notify']['from']\n+ mail.to = BACKUP['notify']['to']\n+ mail.address = \"smtp.gmail.com\"\n+ mail.port = 587\n+ mail.domain = BACKUP['notify']['domain']\n+ mail.user_name = BACKUP['notify']['user_name']\n+ mail.password = BACKUP['notify']['password']\n+ mail.authentication = BACKUP['notify']['authentication']\n+ mail.encryption = :starttls\n+ end\n+end\n" }, { "change_type": "DELETE", "old_path": "config.rb", "new_path": null, "diff": "-# encoding: utf-8\n-\n-##\n-# Backup v4.x Configuration\n-#\n-# Documentation: http://backup.github.io/backup\n-# Issue Tracker: https://github.com/backup/backup/issues\n-\n-##\n-# Config Options\n-#\n-# The options here may be overridden on the command line, but the result\n-# will depend on the use of --root-path on the command line.\n-#\n-# If --root-path is used on the command line, then all paths set here\n-# will be overridden. If a path (like --tmp-path) is not given along with\n-# --root-path, that path will use it's default location _relative to --root-path_.\n-#\n-# If --root-path is not used on the command line, a path option (like --tmp-path)\n-# given on the command line will override the tmp_path set here, but all other\n-# paths set here will be used.\n-#\n-# Note that relative paths given on the command line without --root-path\n-# are relative to the current directory. The root_path set here only applies\n-# to relative paths set here.\n-#\n-# ---\n-#\n-# Sets the root path for all relative paths, including default paths.\n-# May be an absolute path, or relative to the current working directory.\n-#\n-# root_path 'my/root'\n-#\n-# Sets the path where backups are processed until they're stored.\n-# This must have enough free space to hold apx. 2 backups.\n-# May be an absolute path, or relative to the current directory or +root_path+.\n-#\n-# tmp_path 'my/tmp'\n-#\n-# Sets the path where backup stores persistent information.\n-# When Backup's Cycler is used, small YAML files are stored here.\n-# May be an absolute path, or relative to the current directory or +root_path+.\n-#\n-# data_path 'my/data'\n-\n-##\n-# Utilities\n-#\n-# If you need to use a utility other than the one Backup detects,\n-# or a utility can not be found in your $PATH.\n-#\n-# Utilities.configure do\n-# tar '/usr/bin/gnutar'\n-# redis_cli '/opt/redis/redis-cli'\n-# end\n-\n-##\n-# Logging\n-#\n-# Logging options may be set on the command line, but certain settings\n-# may only be configured here.\n-#\n-# Logger.configure do\n-# console.quiet = true # Same as command line: --quiet\n-# logfile.max_bytes = 2_000_000 # Default: 500_000\n-# syslog.enabled = true # Same as command line: --syslog\n-# syslog.ident = 'my_app_backup' # Default: 'backup'\n-# end\n-#\n-# Command line options will override those set here.\n-# For example, the following would override the example settings above\n-# to disable syslog and enable console output.\n-# backup perform --trigger my_backup --no-syslog --no-quiet\n-\n-##\n-# Component Defaults\n-#\n-# Set default options to be applied to components in all models.\n-# Options set within a model will override those set here.\n-#\n-# Storage::S3.defaults do |s3|\n-# s3.access_key_id = \"my_access_key_id\"\n-# s3.secret_access_key = \"my_secret_access_key\"\n-# end\n-#\n-# Notifier::Mail.defaults do |mail|\n-# mail.from = 'sender@email.com'\n-# mail.to = 'receiver@email.com'\n-# mail.address = 'smtp.gmail.com'\n-# mail.port = 587\n-# mail.domain = 'your.host.name'\n-# mail.user_name = 'sender@email.com'\n-# mail.password = 'my_password'\n-# mail.authentication = 'plain'\n-# mail.encryption = :starttls\n-# end\n-\n-##\n-# Preconfigured Models\n-#\n-# Create custom models with preconfigured components.\n-# Components added within the model definition will\n-# +add to+ the preconfigured components.\n-#\n-# preconfigure 'MyModel' do\n-# archive :user_pictures do |archive|\n-# archive.add '~/pictures'\n-# end\n-#\n-# notify_by Mail do |mail|\n-# mail.to = 'admin@email.com'\n-# end\n-# end\n-#\n-# MyModel.new(:john_smith, 'John Smith Backup') do\n-# archive :user_music do |archive|\n-# archive.add '~/music'\n-# end\n-#\n-# notify_by Mail do |mail|\n-# mail.to = 'john.smith@email.com'\n-# end\n-# end\n" }, { "change_type": "DELETE", "old_path": "models/code_curiosity_backup.rb", "new_path": null, "diff": "-# encoding: utf-8\n-\n-##\n-# Backup Generated: code_curiosity_backup\n-# Once configured, you can run the backup with the following command:\n-#\n-# $ backup perform -t code_curiosity_backup [-c <path_to_configuration_file>]\n-#\n-# For more information about Backup's components, see the documentation at:\n-# http://backup.github.io/backup\n-#\n-\n-BACKUP = YAML.load_file('config/backup.yml')['backup_data']\n-\n-Model.new(:code_curiosity_backup, 'Description for code_curiosity_backup') do\n-\n- ##\n- # MongoDB [Database]\n- #\n- database MongoDB do |db|\n- db.name = BACKUP['database_name']\n- db.username = \"\"\n- db.password = \"\"\n- db.host = BACKUP['database_host']\n- db.port = 27017\n- db.ipv6 = false\n- db.only_collections = []\n- db.additional_options = []\n- db.lock = false\n- db.oplog = false\n- end\n-\n- ##\n- # Amazon Simple Storage Service [Storage]\n- #\n- store_with S3 do |s3|\n- # AWS Credentials\n- s3.access_key_id = BACKUP['s3_access_key_id']\n- s3.secret_access_key = BACKUP['s3_secret_access_key']\n- # Or, to use a IAM Profile:\n- # s3.use_iam_profile = true\n-\n- s3.region = \"ap-southeast-1\"\n- s3.bucket = \"codecuriosity\"\n- #s3.path = \"/backups\"\n- s3.keep = 5\n- # s3.keep = Time.now - 2592000 # Remove all backups older than 1 month.\n- end\n-\n- ##\n- # GPG [Encryptor]\n- #\n- # Setting up #keys, as well as #gpg_homedir and #gpg_config,\n- # would be best set in config.rb using Encryptor::GPG.defaults\n- #\n- encrypt_with GPG do |encryption|\n- # Setup public keys for #recipients\n- encryption.keys = {}\n- encryption.keys['user@domain.com'] = <<-KEY\n- -----BEGIN PGP PUBLIC KEY BLOCK-----\n- Version: GnuPG v1.4.11 (Darwin)\n-\n- mQENBFq4/RUBCACrmhrL6EBOruu3OaYhzggDgxCw9f77r1Y/XS4OmU/PTtr8NGAe\n- TAoTffwoNZmdi3LQ3AfFlj1egSZnxu3wP0NYpjg/PMZz3yF8DFPQ+OXbZM7hqMio\n- j/+FPVWy8KURrZuZRiP2PolqZP9K376R7iK0ZenNqlFjBwwJoUbMRgacxzyXRbFR\n- DY1TVGXqdykkeLL8ExtZCc6fdFIIMo90/wEjp+GjKWbP9O+8qw9UaZ3sQNTndxxS\n- sgDgJJunAMEKDk/03l2JpGQgpqPwOs/t95fjWHAVSh+52b4CHsvkP+48UDNjZ0GG\n- mbF54zdti3eOZ0zvMAlaHh9WOmbnUjOvySU5ABEBAAG0LiJSYWh1bCBKYWRoYXYi\n- IChwYWluKSA8cmFodWwucmo5NDIxQGdtYWlsLmNvbT6JATgEEwECACIFAlq4/RUC\n- GwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEM3HGI/JkrsDEecH/2SUO2/m\n- VT1jLR4WyZnlgrGZFLHv9HVaOFvaRGGSPqP5+t84wXNSWY0f3JI/77bY0msCCQfb\n- zBJEzN5T8ljeu+RVWB+PgGY3LM4Pq5hpKOF5g8aeKiOCqWOjxu8Ly15cq24V7WbF\n- l1swF+Lp+AaF5LF6/sICinKbr0aWO4g3Gx5Gwyqhfi6a3VHI8sBHxLmPqY2QwqS+\n- cEtQdtVHhdTEgaElt/uOK0TO2tfMsK2NIV/ZohFqAVwsTMoF2mo5EwqKyZ4ZTKWl\n- KHGjMx84vsuemBEyJB7kEjYNmCZ+CKj0DwEDhfooWKQHmZvB+dKn/GcQYgMJyGQj\n- 4cRO6ySPPLa5ymq5AQ0EWrj9FQEIAMC4om0eAZFOia34pL8whzX9D4Jb85srtcS4\n- vrRJaaNhDTJi2T0B+WzK7qTJGs3pQm9cMfn7zxDwWp0cJ+qrE0yCYWP9TtaXckFf\n- DPM73HIDbuMraFQ25/jCi4zWzSvNVi0J8f7p9aGWBoqHOzYpViwnqiX+55uBVgZn\n- mckfqZLMxzJNQRtOAEWFzXdzaqEJdTuQDpHDGPWmbiZ1xCgWSrc+51zO+P7cAX4x\n- qfHITyEviITb7MSAvOoXqwicE4cc0CjuFSnnNSQxBI/BieZqWpJoDO4RX1RiIv/9\n- DCjyvt8GDJIqr38G/EdkN2QMEP0KHjQ/Al2CtbnuhakmgFAQGZ8AEQEAAYkBHwQY\n- AQIACQUCWrj9FQIbDAAKCRDNxxiPyZK7A9gDB/9gdxT+rNAp00wgSc+vUgQgUBn7\n- +wKZXl543ultH9KP22zEc4iXaiLbr+3lQiYbNnGDyPmGfCYcYReX9zwbOzN+VsV8\n- ckYoCx9WOl74HtI802hiFfrokU8lyKECi9IjolRQZbNThn9Px5/1DkflHlvFwYH4\n- lrT3ospW429+UJRQErRAP3OXFNCNvwVsTgQtpdRKRTqICpmdBXLwH7cRU3tBuLTS\n- K0oAIrATXt1QUju3/XWiPFddBhGj5Hv2SBp5ElYT1sOPmzEM6v4xhzhP9WDyzv7/\n- DtpjtchTeUxPcW3HIA5GUpS52Dq3DbtDOHIgqxIIDP2uIHaE2CSdAbbbPkYy\n- =m0Pv\n- -----END PGP PUBLIC KEY BLOCK-----\n- KEY\n-\n- # Specify mode (:asymmetric, :symmetric or :both)\n- encryption.mode = :both # defaults to :asymmetric\n-\n- # Specify recipients from #keys (for :asymmetric encryption)\n- encryption.recipients = BACKUP['mail_username']\n-\n- # Specify passphrase or passphrase_file (for :symmetric encryption)\n- encryption.passphrase = 'a secret'\n- # encryption.passphrase_file = '~/backup_passphrase'\n- end\n-\n- ##\n- # Gzip [Compressor]\n- #\n- compress_with Gzip\n-\n- ##\n- # Mail [Notifier]\n- #\n- # The default delivery method for Mail Notifiers is 'SMTP'.\n- # See the documentation for other delivery options.\n- #\n- notify_by Mail do |mail|\n- mail.on_success = true\n- mail.on_warning = true\n- mail.on_failure = true\n-\n- mail.from = BACKUP['mail_from']\n- mail.to = BACKUP['mail_to']\n- mail.cc = \"cc@email.com\"\n- mail.bcc = \"bcc@email.com\"\n- mail.reply_to = \"reply_to@email.com\"\n- mail.address = \"smtp.gmail.com\"\n- mail.port = 587\n- mail.domain = \"your.host.name\"\n- mail.user_name = BACKUP['mail_username']\n- mail.password = BACKUP['mail_password']\n- mail.authentication = \"plain\"\n- mail.encryption = :starttls\n- end\n-\n-end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Move backup code under DbBackup folder
332,090
25.05.2018 19:20:28
-19,080
080ba8273ea99b663b67576d9d9f037b7794b1ce
Disable redeem points button
[ { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%span.pull-right Not set yet\n- if logged_in_user?\n- if Offer.is_winner?(current_user) || @user.active_sponsorer_detail || @user.able_to_redeem?\n- = link_to '#', class: \"btn btn-primary btn-block\", data: { toggle: 'modal', target: '#redeem-modal .modal' } do\n+ = link_to '#', class: \"btn btn-primary btn-block disabled\", data: { toggle: 'modal', target: '#redeem-modal .modal' } do\n%b Redeem Points\n- else\n%span.tool-tip{\"data-placement\" => \"top\", \"data-toggle\" => \"tooltip\", :title => \"Not met the redemption criteria\"}\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Disable redeem points button
332,091
25.05.2018 19:50:06
-19,080
d526e8fee2702e24662349835b236b45975c416a
Add backup gem to Gemfile
[ { "change_type": "MODIFY", "old_path": "Gemfile", "new_path": "Gemfile", "diff": "@@ -43,6 +43,7 @@ gem 'react-rails'\ngem 'versionist'\ngem 'active_model_serializers', '~> 0.10.0'\ngem 'sidekiq-status'\n+gem 'backup'\ngroup :development, :test do\ngem 'byebug'\n" }, { "change_type": "MODIFY", "old_path": "Gemfile.lock", "new_path": "Gemfile.lock", "diff": "@@ -70,6 +70,9 @@ GEM\nbabel-transpiler (0.7.0)\nbabel-source (>= 4.0, < 6)\nexecjs (~> 2.0)\n+ backup (3.4.0)\n+ open4 (~> 1.3.0)\n+ thor (>= 0.15.4, < 2)\nbcrypt (3.1.11)\nbinding_of_caller (0.7.2)\ndebug_inspector (>= 0.0.1)\n@@ -446,6 +449,7 @@ PLATFORMS\nDEPENDENCIES\nactive_model_serializers (~> 0.10.0)\n+ backup\nbootstrap-datepicker-rails\nbootstrap-sass (~> 3.3.6)\nbrakeman\n@@ -513,4 +517,4 @@ RUBY VERSION\nruby 2.3.0p0\nBUNDLED WITH\n- 1.15.4\n+ 1.16.1\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Add backup gem to Gemfile
332,090
25.05.2018 19:34:20
-19,080
d53232b276b4d594aa42a6b32ebc1a3d4b0d7281
Stop scheduling mails
[ { "change_type": "MODIFY", "old_path": "config/schedule.rb", "new_path": "config/schedule.rb", "diff": "@@ -47,14 +47,13 @@ every '59 23 27-31 * *' do\nend\nevery '1 1 21 * *' do\n- rake 'subscription:send_progress_emails'\n+ # rake 'subscription:send_progress_emails'\nend\nevery '1 10 7 * *' do\n- rake 'subscription:redeem_points'\n+ # rake 'subscription:redeem_points'\nend\nevery :day, :at => '10:30am' do\nrake 'repo:delete_large_repositories'\nend\n-\n" }, { "change_type": "MODIFY", "old_path": "test/integration/user_flow_test.rb", "new_path": "test/integration/user_flow_test.rb", "diff": "@@ -11,37 +11,37 @@ class UserFlowTest < ActionDispatch::IntegrationTest\nCapybara.reset_sessions!\nend\n- test \"user can redeem only when redemption criterias will be met\" do\n- @user.github_user_since = Date.today - 6.months\n- @user.created_at = Date.today - 3.months\n- @user.save\n- login_as @user\n- visit user_path(@user)\n- within 'section.content-header' do\n- assert page.has_content?('User Profile')\n- end\n-\n- within 'section.content' do\n- within '.box' do\n- assert page.has_content?('Redeem Points')\n- assert page.has_link?('Redeem Points')\n- click_link('Redeem Points')\n- #page.save_and_open_screenshot\n- end\n- end\n- #page.save_and_open_screenshot\n- end\n+ # test \"user can redeem only when redemption criterias will be met\" do\n+ # @user.github_user_since = Date.today - 6.months\n+ # @user.created_at = Date.today - 3.months\n+ # @user.save\n+ # login_as @user\n+ # visit user_path(@user)\n+ # within 'section.content-header' do\n+ # assert page.has_content?('User Profile')\n+ # end\n+ #\n+ # within 'section.content' do\n+ # within '.box' do\n+ # assert page.has_content?('Redeem Points')\n+ # assert page.has_link?('Redeem Points')\n+ # # click_link('Redeem Points')\n+ # #page.save_and_open_screenshot\n+ # end\n+ # end\n+ # #page.save_and_open_screenshot\n+ # end\n- test \"user cannot redeem when redemption criterias will not be met\" do\n- login_as @user\n- visit user_path(@user)\n-\n- within 'section.content' do\n- within '.box' do\n- # assert page.has_content?('Redeem Points!')\n- assert page.has_no_link?('Redeem Points')\n- #page.save_and_open_screenshot\n- end\n- end\n- end\n+ # test \"user cannot redeem when redemption criterias will not be met\" do\n+ # login_as @user\n+ # visit user_path(@user)\n+ #\n+ # within 'section.content' do\n+ # within '.box' do\n+ # # assert page.has_content?('Redeem Points!')\n+ # assert page.has_no_link?('Redeem Points')\n+ # #page.save_and_open_screenshot\n+ # end\n+ # end\n+ # end\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Stop scheduling mails
332,090
28.05.2018 18:50:47
-19,080
4cbaf5dde9eaa4abb16a37c472ee71980beb466d
Terms and conditions page for new feature.
[ { "change_type": "MODIFY", "old_path": "app/assets/stylesheets/application.scss", "new_path": "app/assets/stylesheets/application.scss", "diff": "@import \"bootstrap2-toggle\";\n@import 'activities';\n@import 'redeem';\n+@import 'registrations';\n.typeahead.dropdown-menu, .tt-hint, .tt-input, .tt-menu {\nwidth: 90%;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/assets/stylesheets/registrations.scss", "diff": "+h1 {\n+ text-align: center;\n+}\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/registrations_controller.rb", "new_path": "app/controllers/registrations_controller.rb", "diff": "class RegistrationsController < Devise::RegistrationsController\n- before_action :redirect_to_home\n+ before_action :redirect_to_home, except: [:terms_and_conditions]\n+\n+ def terms_and_conditions\n+ if params[:terms_and_conditions]\n+ current_user.set(terms_and_conditions: params[:terms_and_conditions])\n+ redirect_to dashboard_path\n+ else\n+ render 'terms_and_conditions'\n+ end\n+ end\nprivate\ndef redirect_to_home\n- redierect_to root_path\n+ redirect_to root_path\nend\ndef sign_up_params\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/users/omniauth_callbacks_controller.rb", "new_path": "app/controllers/users/omniauth_callbacks_controller.rb", "diff": "@@ -7,8 +7,12 @@ class Users::OmniauthCallbacksController < ApplicationController\n#normal user sign in\nsign_in :user, @user\n+ unless @user.terms_and_conditions\n+ redirect_to terms_and_conditions_path\n+ else\nredirect_to dashboard_path\n- flash[:notice] = \"Signed in\"\n+ flash[:notice] = \"Signed in successfully!\"\n+ end\nend\ndef failure\n" }, { "change_type": "MODIFY", "old_path": "app/models/user.rb", "new_path": "app/models/user.rb", "diff": "@@ -59,6 +59,9 @@ class User\n# User account deletion\nfield :deleted_at, type: Time\n+ # for accepting terms and conditions\n+ field :terms_and_conditions, type: Boolean, default: false\n+\nhas_many :activities, dependent: :destroy\nhas_many :commits, dependent: :destroy\nhas_many :transactions, dependent: :destroy\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/registrations/terms_and_conditions.html.haml", "diff": "+%section.content-header\n+ %h1 Terms and Conditions\n+%section.content\n+ #terms_and_conditions\n+ .row\n+ .col-sm-6.col-sm-offset-3\n+ .panel.panel-info\n+ .panel-body\n+ - INFO['terms_and_conditions'].each do |info|\n+ %ul.list-group.list-group-unbordered\n+ %li.list-group-item\n+ %b= info['title']\n+ %p= info['description']\n+\n+ .panel-footer\n+ = link_to terms_and_conditions_path(terms_and_conditions: true), class: \"btn btn-primary btn-block\" do\n+ %b Accept\n" }, { "change_type": "MODIFY", "old_path": "config/info.yml", "new_path": "config/info.yml", "diff": "+terms_and_conditions:\n+ -\n+ title: Welcome to Code-curiosity!\n+ description: Description of new Code-curiosity.\n+ -\n+ title: New Rules\n+ description: Explain new Code-curiosity rules.\nhome:\n-\nquestion: Who should use CodeCuriosity?\n@@ -95,4 +102,3 @@ benefits:\n- Logo on homepage as well as in all mailers\n- Custom Judging for owned repos\n- Custom CodeCuriosity Badge\n-\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -16,6 +16,7 @@ Rails.application.routes.draw do\ndevise_scope :user do\nget 'sign_in', :to => 'home#index', :as => :new_user_session\ndelete 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session\n+ get 'terms_and_conditions' => 'registrations#terms_and_conditions'\nend\n# The priority is based upon order of creation: first created -> highest priority.\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Terms and conditions page for new feature.
332,091
31.05.2018 20:34:59
-19,080
79faf1ad9790cbc0b9845d806e638da0eb91f0bc
Create associated pull request with commits
[ { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -21,6 +21,7 @@ class Commit\nbelongs_to :user\nbelongs_to :repository\n+ belongs_to :pull_request\nhas_many :comments, as: :commentable\nembeds_many :scores, as: :scorable\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/models/pull_request.rb", "diff": "+class PullRequest\n+ include Mongoid::Document\n+ include Mongoid::Timestamps\n+\n+ field :number, type: Integer\n+ field :created_on, type: String\n+ field :comment_count, type: Integer\n+ field :author_association, type: String\n+ field :label, type: DateTime\n+\n+ has_many :commits\n+end\n" }, { "change_type": "MODIFY", "old_path": "app/models/test.rb", "new_path": "app/models/test.rb", "diff": "@@ -29,10 +29,14 @@ class Test\ncommit_record.comments_count = commit['commit']['comment_count']\ncommit_record.save\n+ asscoiate_with_pull_request(commit_record)\n+\nend\nend\nend\n+ private\n+\ndef fetch_commits(repo_name, branch_name)\n::VCS::GitCommit.new(\nrepo_owner: repo_owner,\n@@ -42,4 +46,21 @@ class Test\nto_date: to_date\n).list\nend\n+\n+ def asscoiate_with_pull_request(commit_record)\n+ pr_info = fetch_pull_request(commit_record.sha)\n+ if pr_info\n+ pr = PullRequest.find_or_initialize_by(number: pr_info.number)\n+ pr.label = pr_info.label\n+ pr.created_on = pr_info.created_at\n+ pr.comment_count = pr_info.comments\n+ pr.author_association = pr_info.author_association\n+ pr.commits << commit_record\n+ pr.save\n+ end\n+ end\n+\n+ def fetch_pull_request(sha)\n+ ::VCS::GitPullRequest.new(sha).get\n+ end\nend\n" }, { "change_type": "ADD", "old_path": null, "new_path": "lib/vcs/git_pull_request.rb", "diff": "+module VCS\n+ class GitPullRequest\n+ attr_reader :sha\n+\n+ def initialize(sha)\n+ @sha = sha\n+ end\n+\n+ def get\n+ pull_requests = GitApp.info.search.issues(\"sha:#{sha}\")\n+ return nil if pull_requests.items.size != 1\n+ pull_requests.items[0]\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/factories/pull_requests.rb", "diff": "+FactoryGirl.define do\n+ factory :pull_request do\n+\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/models/pull_request_test.rb", "diff": "+require \"test_helper\"\n+\n+class PullRequestTest < ActiveSupport::TestCase\n+ def pull_request\n+ @pull_request ||= PullRequest.new\n+ end\n+\n+ def test_valid\n+ assert pull_request.valid?\n+ end\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Create associated pull request with commits
332,091
01.06.2018 15:03:59
-19,080
d6f63817e8b34ac74d6208fb6a8b7b019f68d4f1
Add model test case for pull_request
[ { "change_type": "MODIFY", "old_path": "app/models/pull_request.rb", "new_path": "app/models/pull_request.rb", "diff": "@@ -3,10 +3,12 @@ class PullRequest\ninclude Mongoid::Timestamps\nfield :number, type: Integer\n- field :created_on, type: String\n+ field :created_at_git, type: String\nfield :comment_count, type: Integer\nfield :author_association, type: String\nfield :label, type: DateTime\nhas_many :commits\n+\n+ validates :number, :created_at_git, :author_association, :comment_count, presence: true\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/test.rb", "new_path": "app/models/test.rb", "diff": "@@ -52,7 +52,7 @@ class Test\nif pr_info\npr = PullRequest.find_or_initialize_by(number: pr_info.number)\npr.label = pr_info.label\n- pr.created_on = pr_info.created_at\n+ pr.created_at_git = pr_info.created_at\npr.comment_count = pr_info.comments\npr.author_association = pr_info.author_association\npr.commits << commit_record\n" }, { "change_type": "MODIFY", "old_path": "test/factories/pull_requests.rb", "new_path": "test/factories/pull_requests.rb", "diff": "FactoryGirl.define do\nfactory :pull_request do\n-\n+ number {Faker::Number.number(2)}\n+ comment_count {Faker::Number.number(2)}\n+ author_association \"COLLABORATOR\"\n+ label \"bug\"\n+ created_at_git {Faker::Date.between(1.month.ago, 2.month.ago)}\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "test/models/pull_request_test.rb", "new_path": "test/models/pull_request_test.rb", "diff": "-require \"test_helper\"\n+require_relative \"../test_helper\"\nclass PullRequestTest < ActiveSupport::TestCase\n- def pull_request\n- @pull_request ||= PullRequest.new\n+ test \"number must be present\" do\n+ pull_request = build(:pull_request, number: '')\n+ pull_request.valid?\n+ assert_not_empty pull_request.errors[:number]\nend\n- def test_valid\n- assert pull_request.valid?\n+ test \"created_at_git must be present\" do\n+ pull_request = build(:pull_request, created_at_git: '')\n+ pull_request.valid?\n+ assert_not_empty pull_request.errors[:created_at_git]\n+ end\n+\n+ test \"author_association must be present\" do\n+ pull_request = build(:pull_request, author_association: '')\n+ pull_request.valid?\n+ assert_not_empty pull_request.errors[:author_association]\n+ end\n+\n+ test \"comment_count must be present\" do\n+ pull_request = build(:pull_request, comment_count: '')\n+ pull_request.valid?\n+ assert_not_empty pull_request.errors[:comment_count]\nend\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Add model test case for pull_request
332,091
01.06.2018 15:25:10
-19,080
5a226218f4cf608bfd0e7725ef8931d1760bc84d
Change name of test class to git_fetcher
[ { "change_type": "MODIFY", "old_path": "app/jobs/fetch_commit_job.rb", "new_path": "app/jobs/fetch_commit_job.rb", "diff": "@@ -12,7 +12,7 @@ class FetchCommitJob < ActiveJob::Base\nSidekiq.logger.info \"from: #{from_date} to: #{to_date}\"\nbegin\n- Test.new(\n+ GitFetcher.new(\nrepo_owner: repo_owner,\nrepo_name: repo_name,\nbranch_name: branch_name,\n" }, { "change_type": "RENAME", "old_path": "app/models/test.rb", "new_path": "app/models/git_fetcher.rb", "diff": "-class Test\n+class GitFetcher\ninclude VCS\nattr_reader :repo_owner, :repo_name,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/models/git_fetcher_test.rb", "diff": "+\n+require 'test_helper'\n+\n+class GitFetcherTest < ActiveSupport::TestCase\n+\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Change name of test class to git_fetcher
332,090
23.05.2018 14:01:00
-19,080
548f86c78a527d8a4e04fdb1906ca95d130bd835
Reward table to show user commits 1. Add table to show commits. 2. Add filter to show commits between two dates. 3. Add search feature
[ { "change_type": "MODIFY", "old_path": "app/assets/stylesheets/application.scss", "new_path": "app/assets/stylesheets/application.scss", "diff": "@import \"bootstrap2-toggle\";\n@import 'redeem';\n@import 'registrations';\n+@import 'commits';\n.typeahead.dropdown-menu, .tt-hint, .tt-input, .tt-menu {\nwidth: 90%;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/assets/stylesheets/commits.scss", "diff": "+// Place all the styles related to the Commits controller here.\n+// They will automatically be included in application.css.\n+// You can use Sass (SCSS) here: http://sass-lang.com/\n+\n+form, button#reveal_all {\n+ float: right;\n+}\n+\n+td, th {\n+ text-align: center;\n+}\n+\n+.btn.btn-default, input#to, input#from{\n+ margin-left: 5px;\n+ margin-right: 5px;\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/controllers/commits_controller.rb", "diff": "+class CommitsController < ApplicationController\n+ before_action :user_commits, only: [:index]\n+\n+ def index\n+ @commits = @commits.in_range(params[:from], params[:to])\n+ .search_by(params[:query])\n+ .page(params[:page])\n+ end\n+\n+ private\n+\n+ def user_commits\n+ @commits = current_user.commits.asc(:commit_date)\n+ end\n+end\n" }, { "change_type": "MODIFY", "old_path": "app/models/commit.rb", "new_path": "app/models/commit.rb", "diff": "@@ -28,6 +28,13 @@ class Commit\nvalidates :message, uniqueness: {:scope => :commit_date}\nindex({ user_id: 1 })\n+ scope :in_range, -> (from, to) {\n+ where(:commit_date.gte => from, :commit_date.lte => to) if from.presence && to.presence\n+ }\n+ scope :search_by, -> (query) {\n+ where(message: /#{query}/i) if query.presence\n+ }\n+\nindex({ repository_id: 1 })\nindex({ commit_date: -1 })\nindex({ sha: 1 })\n" }, { "change_type": "MODIFY", "old_path": "app/views/application/_sidebar.html.haml", "new_path": "app/views/application/_sidebar.html.haml", "diff": "%i.fa.fa-dashboard\n%span Dashboard\n= render 'admin_sidebar' if current_user.is_admin?\n+ %li{class: is_active(params[:action], 'commits')}\n+ = link_to commits_path do\n+ %i.fa.fa-gift\n+ %span Rewards\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/commits/_commits.html.haml", "diff": "+- @commits.each do |commit|\n+ %tr\n+ %td= commit.commit_date.strftime(\"%d %B %y\")\n+ %td= commit.repository.name\n+ %td\n+ = commit.message\n+ = link_to commit.html_url, class: 'btn btn-info btn-xs' do\n+ %i.fa.fa-fw.fa-share\n+ View\n+ %td= commit.auto_score\n+ %td\n+ = link_to commits_path, class: 'btn btn-success btn-xs' do\n+ %i.fa.fa-fw.fa-gift\n+ Reveal\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/commits/_commits_table.html.haml", "diff": "+- if @commits.any?\n+ %table.table.table-hover.table-bordered\n+ %thead\n+ %tr\n+ %th.col-xs-2 Commit Date\n+ %th.col-xs-2 Repository Name\n+ %th.col-xs-7 Description\n+ %th.col-xs-1 Points\n+ %th.col-xs-1 Reveal\n+ %tbody\n+ = render partial: 'commits'\n+\n+ .pagination-container\n+ = paginate @commits, remote: true\n+\n+- else\n+ = render partial: 'callout_box', locals: {type: 'success', title: 'Keep Contributing', message: 'There are no commits in this period.'}\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/commits/index.html.haml", "diff": "+%section.content-header\n+ %h1\n+ Rewards :-\n+ %button.btn.btn-success#reveal_all{type: 'button'}\n+ %i.fa.fa-fw.fa-gift\n+ Reveal All\n+\n+ %section.content\n+ .row\n+ .col-xs-12\n+ .box.box-primary\n+ .box-header\n+ %h3.box-title\n+ %span Contributions :-\n+ .box-tools\n+ = form_tag(commits_path, method: :get, remote: true) do\n+ .input-group.input-group-xs\n+ = label_tag 'From:'\n+ = date_field_tag :from, Date.yesterday\n+ = label_tag 'To:'\n+ = date_field_tag :to, Date.today\n+ = text_field_tag :query, nil, placeholder: 'search'\n+ %button.btn.btn-default.btn-sm{type: 'submit'} Go\n+\n+ .box-body.table-responsive#commits\n+ = render partial: 'commits_table'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/views/commits/index.js.haml", "diff": "+:plain\n+ $(\"#commits\").html(\"#{j render(partial: 'commits_table')}\");\n" }, { "change_type": "MODIFY", "old_path": "config/routes.rb", "new_path": "config/routes.rb", "diff": "@@ -23,6 +23,7 @@ Rails.application.routes.draw do\n# See how all your routes lay out with \"rake routes\".\nresources :repositories, only: [:index]\n+ resources :commits, only: [:index]\nresources :users, only: [:index, :show, :destroy, :edit, :update] do\nmember do\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/controllers/commits_controller_test.rb", "diff": "+require \"test_helper\"\n+\n+class CommitsControllerTest < ActionController::TestCase\n+ before do\n+ goal = create :goal, points: 10\n+ round = create :round, :open\n+ user = create :user, :auth_token => 'dah123rty', goal: goal\n+ 5.times.each do |i|\n+ create :commit, user: user, commit_date: Date.today, message: \"commit_#{i}\"\n+ end\n+ sign_in user\n+ end\n+\n+ def test_index\n+ get :index\n+ assert_response :success\n+ assert_template :index\n+ assert_template partial: '_commits_table'\n+ assert_template partial: '_commits'\n+ assert_equal assigns(:commits).count, 5\n+ end\n+\n+ test 'should display commits between two dates' do\n+ get :index, {from: Date.yesterday - 1, to: Date.yesterday}\n+ assert_equal assigns(:commits).count, 0\n+ end\n+\n+ test 'should search commits by search query' do\n+ get :index, {query: 'commit_1'}\n+ assert_equal assigns(:commits).count, 1\n+ end\n+\n+ test 'should display commits between two dates and search by query' do\n+ get :index, {from: Date.yesterday - 1, to: Date.yesterday, query: 'commit'}\n+ assert_equal assigns(:commits).count, 0\n+ end\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Reward table to show user commits 1. Add table to show commits. 2. Add filter to show commits between two dates. 3. Add search feature
332,090
02.06.2018 10:22:49
-19,080
7a8e90c7fee9285988cd5f11bb2aea728095ca7f
Fix test cases of commits controller
[ { "change_type": "MODIFY", "old_path": "test/controllers/commits_controller_test.rb", "new_path": "test/controllers/commits_controller_test.rb", "diff": "@@ -2,9 +2,7 @@ require \"test_helper\"\nclass CommitsControllerTest < ActionController::TestCase\nbefore do\n- goal = create :goal, points: 10\n- round = create :round, :open\n- user = create :user, :auth_token => 'dah123rty', goal: goal\n+ user = create :user, :auth_token => 'dah123rty'\n5.times.each do |i|\ncreate :commit, user: user, commit_date: Date.today, message: \"commit_#{i}\"\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Fix test cases of commits controller
332,090
01.06.2018 10:08:18
-19,080
0c4b7df4ff3c3d1c9d603eee196f8bcc28cf6f66
Modify redeem points feature and user profile 1. Remove activities count from user profile. 2. Update redeem request form and Alert.
[ { "change_type": "MODIFY", "old_path": "app/assets/javascripts/redeem.js", "new_path": "app/assets/javascripts/redeem.js", "diff": "@@ -8,11 +8,10 @@ var alert_user = function() {\nevent.stopImmediatePropagation();\nvar form = $(this).parent('form');\nvar points = $(this).data().points;\n- var paid = $(this).data().paid;\nvar free = $(this).data().free;\nbootbox.confirm({\ntitle: 'Alert',\n- message: \"You're on a free plan. <br> Your \" + points +\" points are worth $\" + (points/free) + \". Please upgrade your account to get $\" + (points/paid) + \" for them. <br> Are you sure you want to continue?\",\n+ message: \"Your \" + points +\" points are worth $\" + (points/free) + \"<br> Are you sure you want to continue?\",\nbuttons: {\nconfirm: {\nlabel: 'Continue',\n" }, { "change_type": "MODIFY", "old_path": "app/assets/stylesheets/registrations.scss", "new_path": "app/assets/stylesheets/registrations.scss", "diff": "-h1 {\n+h1#tac {\ntext-align: center;\n}\n" }, { "change_type": "MODIFY", "old_path": "app/helpers/users_helper.rb", "new_path": "app/helpers/users_helper.rb", "diff": "@@ -7,8 +7,8 @@ module UsersHelper\ndef github_points_options\nREDEEM['github_redeem_amounts'].collect do |v|\n[\n- \"$#{v}\",\n- v\n+ \"$#{v} - #{v * REDEEM['one_dollar_to_points'] * 2} points\",\n+ v * REDEEM['one_dollar_to_points'] * 2\n]\n#v*REDEEM['one_dollar_to_points']]\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/transaction.rb", "new_path": "app/models/transaction.rb", "diff": "@@ -27,8 +27,6 @@ class Transaction\nafter_create :update_user_total_points\nafter_create :set_amount\n- FREE_SUBSCRIPTION = 20\n-\ndef credit?\ntype == 'credit'\nend\n@@ -59,6 +57,7 @@ class Transaction\ndef set_amount\n#for now, using old conversion rate.\n- set(amount: points.to_f/FREE_SUBSCRIPTION)\n+ denominator = REDEEM['one_dollar_to_points'] * 2\n+ set(amount: points.to_f/denominator)\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/redeem/_submit_buttons.html.haml", "new_path": "app/views/redeem/_submit_buttons.html.haml", "diff": "%button.btn.btn-default{'data-dismiss' => 'modal', :type => 'button'} Cancel\n-%button.btn.btn-primary.submit-redeem{ type: \"button\", data: { points: current_user.points } } Redeem\n+%button.btn.btn-primary.submit-redeem{ type: \"button\", data: { points: current_user.total_points, free: REDEEM['one_dollar_to_points'] * 2} }\n+ Redeem\n" }, { "change_type": "MODIFY", "old_path": "app/views/registrations/terms_and_conditions.html.haml", "new_path": "app/views/registrations/terms_and_conditions.html.haml", "diff": "%section.content-header\n- %h1 Terms and Conditions\n+ %h1#tac Terms and Conditions\n%section.content\n#terms_and_conditions\n.row\n" }, { "change_type": "MODIFY", "old_path": "app/views/users/show.html.haml", "new_path": "app/views/users/show.html.haml", "diff": "%li.list-group-item\n%b Commits\n%a.pull-right= @user.commits_count\n- %li.list-group-item\n- %b Activities\n- %a.pull-right= @user.activities_count\n%li.list-group-item\n%b Earned\n%a.pull-right $ #{amount_earned @user}\n- if logged_in_user?\n= link_to '#', class: \"btn btn-primary btn-block\", data: { toggle: 'modal', target: '#redeem-modal .modal' } do\n%b Redeem Points\n- %span.tool-tip{\"data-placement\" => \"top\", \"data-toggle\" => \"tooltip\", :title => \"Not met the redemption criteria\"}\n- %span.btn.btn-primary.btn-block{:disabled => \"disabled\"} Redeem Points\n.col-sm-8\n.nav-tabs-custom\n%ul.nav.nav-tabs\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Modify redeem points feature and user profile 1. Remove activities count from user profile. 2. Update redeem request form and Alert.
332,090
04.06.2018 17:30:41
-19,080
4cb25668a49f03640dbb3c82c33d75a7c2026d54
Update multi-line-charts 1. Add aggregate queries to Show commits and users month wise. 2. Use of Commit and User model instead of Subscription.
[ { "change_type": "MODIFY", "old_path": "app/assets/javascripts/components/user_points_chart.es6.jsx", "new_path": "app/assets/javascripts/components/user_points_chart.es6.jsx", "diff": "@@ -4,7 +4,7 @@ class UserPointsChart extends React.Component {\n}\ncomponentDidMount() {\n- userTrendChart(this.props.xAxis, this.props.commits, this.props.activities, this.props.points, this.props.username);\n+ userTrendChart(this.props.xAxis, this.props.commits, this.props.points, this.props.username);\n}\nrender () {\n@@ -16,4 +16,3 @@ class UserPointsChart extends React.Component {\n);\n}\n}\n-\n" }, { "change_type": "MODIFY", "old_path": "app/assets/javascripts/home.js", "new_path": "app/assets/javascripts/home.js", "diff": "-function userTrendChart(xAxis, commits, activities, points, username) {\n+function userTrendChart(xAxis, commits, points, username) {\n$('#users-chart-container').highcharts({\nchart: {\ntype: 'line'\n@@ -42,12 +42,6 @@ function userTrendChart(xAxis, commits, activities, points, username) {\nmarker: { enabled: true },\ncolor: '#00A65A',\ndataLabels: {color:'#00A65A',style: {\"color\": \"contrast\", \"fontSize\": \"11px\", \"fontWeight\": \"bold\", \"textShadow\": \"0\" }}\n- }, {\n- name: 'Activities',\n- data: activities,\n- marker: { enabled: true },\n- color: '#F39C12',\n- dataLabels: {color:'#F39C12',style: {\"color\": \"contrast\", \"fontSize\": \"11px\", \"fontWeight\": \"bold\", \"textShadow\": \"0\" }}\n}, {\nname: 'Points',\ndata: points,\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/concerns/contribution_helper.rb", "new_path": "app/controllers/concerns/contribution_helper.rb", "diff": "module ContributionHelper\ndef contribution_data(user = current_user)\n- @subscriptions = user.subscriptions.where(:created_at.gt => Date.parse(\"Feb 2016\")).asc(:created_at)\n+ @user_commits = user.commits.group_by {|t| t.commit_date.beginning_of_month }\n+ .sort\n@xAxis = []\n@commits = []\n- @activities = []\n@points = []\n@username = user.eql?(current_user) ? ['Your'] : [\"#{user.name.titleize}'s\"]\n- @subscriptions.map{|s| @xAxis << s.round.name; @commits << s.commits_count; @activities << s.activities_count; @points << s.points}\n+ @user_commits.map do |key, value|\n+ @xAxis << key.strftime('%b %Y')\n+ @commits << value.count\n+ @points << value.sum(&:auto_score)\n+ end\nend\n-\nend\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/dashboard_controller.rb", "new_path": "app/controllers/dashboard_controller.rb", "diff": "@@ -3,7 +3,7 @@ class DashboardController < ApplicationController\nbefore_action :authenticate_user!, except: [:webhook]\ndef index\n- #contribution_data\n+ contribution_data\nend\ndef webhook\n" }, { "change_type": "MODIFY", "old_path": "app/controllers/home_controller.rb", "new_path": "app/controllers/home_controller.rb", "diff": "@@ -2,7 +2,7 @@ class HomeController < ApplicationController\ninclude HomeHelper\n#load the before_actions only if the user is not logged in.\n- #before_action :multi_line_chart, only: [:index], unless: proc { user_signed_in? }\n+ before_action :multi_line_chart, only: [:index], unless: proc { user_signed_in? }\ndef index\nif user_signed_in?\n" }, { "change_type": "MODIFY", "old_path": "app/helpers/home_helper.rb", "new_path": "app/helpers/home_helper.rb", "diff": "@@ -28,12 +28,72 @@ module HomeHelper\ndef multi_line_chart\n- users = Subscription.collection.aggregate( [ { \"$group\" => { _id: \"$round_id\", total: { \"$sum\" => 1 } } } ] ).sort {|x, y| Date.parse(Round.find(y[\"_id\"]).name) <=> Date.parse(Round.find(x[\"_id\"]).name) }.collect { |r| [ Round.find(r[\"_id\"]).name, r[\"total\"] ] }\n- users = users[1..(users.count - 7)].reverse if users.any?\n-\n+ users = User.collection.aggregate(\n+ [\n+ {\n+ \"$match\" => {\"auto_created\" => false }\n+ },\n+ {\n+ \"$project\" => {\n+ \"month\" => { \"$month\" => \"$created_at\"},\n+ \"year\" => {\"$year\" => \"$created_at\"}\n+ }\n+ },\n+ {\n+ \"$group\" => {\n+ _id: {\"month\" => \"$month\", \"year\" => \"$year\"},\n+ total: { \"$sum\" => 1 }\n+ }\n+ }\n+ ]\n+ ).sort_by do |r|\n+ [\n+ Date.parse(\n+ Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" + r[:_id][\"year\"].to_s\n+ )\n+ ]\n+ end\n+ .collect do |r|\n+ [\n+ Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" +r[:_id][\"year\"].to_s,\n+ r[\"total\"]\n+ ]\n+ end\n- contributions = Subscription.collection.aggregate( [ {\"$match\" => { \"created_at\" => { \"$gt\" => Date.parse(\"march 2016\") } } }, { \"$group\" => { _id: \"$round_id\", total: { \"$sum\" => \"$points\" } } } ]).sort {|x, y| Date.parse(Round.find(y[\"_id\"]).name) <=> Date.parse(Round.find(x[\"_id\"]).name) }.collect { |r| [ Round.find(r[\"_id\"]).name, r[\"total\"] ] }\n- contributions = contributions[1..(contributions.count - 2)].reverse if contributions.any?\n+ contributions = Commit.collection.aggregate(\n+ [\n+ {\n+ \"$match\" => {\n+ \"commit_date\" => { \"$gt\" => Date.parse(\"01/04/2016\") }\n+ }\n+ },\n+ {\n+ \"$project\" => {\n+ \"month\" => { \"$month\" => \"$commit_date\"},\n+ \"year\" => {\"$year\" => \"$commit_date\"},\n+ \"auto_score\" => 1\n+ }\n+ },\n+ {\n+ \"$group\" => {\n+ _id: {\"month\" => \"$month\", \"year\" => \"$year\"},\n+ total: { \"$sum\" => \"$auto_score\" }\n+ }\n+ }\n+ ]\n+ ).sort_by do |r|\n+ [\n+ Date.parse(\n+ Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" + r[:_id][\"year\"].to_s\n+ )\n+ ]\n+ end\n+ .collect do |r|\n+ [\n+ Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" +r[:_id][\"year\"].to_s,\n+ r[\"total\"]\n+ ]\n+ end\n@user_trend = []\n@contribution_trend = []\n@@ -41,10 +101,8 @@ module HomeHelper\n@xAxis = []\nusers.map{ |user| @user_trend << user[1]; @user_xAxis << user[0]}\n-\n+ @user_trend = @user_trend.inject([]){ |acc, value| acc << acc.last.to_i + value.to_i }\ncontributions.map{ |contribution| @contribution_trend << contribution[1]; @xAxis << contribution[0]}\n-\n-\nend\nend\n" }, { "change_type": "MODIFY", "old_path": "app/views/dashboard/index.html.haml", "new_path": "app/views/dashboard/index.html.haml", "diff": "= react_component 'PointsTile', { color: 'bg-green', title: 'Commits', points: current_user.commits_count,\nlogo: 'ion-stats-bars', path: commits_path}\n.row\n- = react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, activities: @activities, points: @points, username: @username }\n+ = react_component 'UserPointsChart', { xAxis: @xAxis, commits: @commits, points: @points, username: @username }\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Update multi-line-charts 1. Add aggregate queries to Show commits and users month wise. 2. Use of Commit and User model instead of Subscription.
332,090
05.06.2018 14:32:10
-19,080
2afc4017148432dca503e4cf73611d6f7e5fecb5
Add gh_repo_created_at and gh_repo_updated_at fields in Repository.
[ { "change_type": "MODIFY", "old_path": "app/jobs/user_repos_job.rb", "new_path": "app/jobs/user_repos_job.rb", "diff": "@@ -56,6 +56,7 @@ class UserReposJob < ActiveJob::Base\n=end\nSidekiq.logger.info \"Repository does not include this user... Adding user\" unless repo.users.include?(user)\nrepo.users << user unless repo.users.include?(user)\n+ repo.set(gh_repo_updated_at: gh_repo.updated_at)\nreturn\nend\n" }, { "change_type": "MODIFY", "old_path": "app/models/repository.rb", "new_path": "app/models/repository.rb", "diff": "@@ -20,6 +20,8 @@ class Repository\nfield :type, type: String\nfield :ignore, type: Boolean, default: false\nfield :branches, type: Array, default: ['master']\n+ field :gh_repo_created_at, type: Time\n+ field :gh_repo_updated_at, type: Time\nbelongs_to :popular_repository, class_name: 'Repository', inverse_of: 'repositories'\nhas_many :commits\n@@ -98,7 +100,9 @@ class Repository\nlanguages: [ info.language],\ngh_id: info.id,\nssh_url: info.ssh_url,\n- owner: info.owner.login\n+ owner: info.owner.login,\n+ gh_repo_created_at: info.created_at,\n+ gh_repo_updated_at: info.updated_at\n})\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Add gh_repo_created_at and gh_repo_updated_at fields in Repository.
332,090
05.06.2018 14:58:33
-19,080
0cc121aef2c48714fa8261ae4761bd423e009afc
Use of sort in aggregate query
[ { "change_type": "MODIFY", "old_path": "app/helpers/home_helper.rb", "new_path": "app/helpers/home_helper.rb", "diff": "@@ -18,11 +18,11 @@ module HomeHelper\ndef widget_class\nif @size > 2\n- \"col-md-4\"\n+ 'col-md-4'\nelsif @size == 2\n- \"col-md-6\"\n+ 'col-md-6'\nelse\n- \"col-md-12\"\n+ 'col-md-12'\nend\nend\n@@ -31,67 +31,68 @@ module HomeHelper\nusers = User.collection.aggregate(\n[\n{\n- \"$match\" => {\"auto_created\" => false }\n+ '$match' => {\n+ 'auto_created' => false,\n+ 'created_at' => { '$gt' => Date.parse('Apr 2016') }\n+ }\n},\n{\n- \"$project\" => {\n- \"month\" => { \"$month\" => \"$created_at\"},\n- \"year\" => {\"$year\" => \"$created_at\"}\n+ '$project' => {\n+ 'month' => { '$month' => '$created_at'},\n+ 'year' => {'$year' => '$created_at'}\n}\n},\n{\n- \"$group\" => {\n- _id: {\"month\" => \"$month\", \"year\" => \"$year\"},\n- total: { \"$sum\" => 1 }\n+ '$group' => {\n+ _id: {'month' => '$month', 'year' => '$year'},\n+ total: { '$sum' => 1 }\n+ }\n+ },\n+ {\n+ '$sort' => {\n+ '_id.year' => 1,\n+ '_id.month' => 1\n}\n}\n]\n- ).sort_by do |r|\n- [\n- Date.parse(\n- Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" + r[:_id][\"year\"].to_s\n- )\n- ]\n- end\n- .collect do |r|\n+ ).collect do |r|\n[\n- Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" +r[:_id][\"year\"].to_s,\n- r[\"total\"]\n+ \"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}\",\n+ r['total']\n]\nend\ncontributions = Commit.collection.aggregate(\n[\n{\n- \"$match\" => {\n- \"commit_date\" => { \"$gt\" => Date.parse(\"01/04/2016\") }\n+ '$match' => {\n+ 'commit_date' => { '$gt' => Date.parse('Apr 2016') }\n}\n},\n{\n- \"$project\" => {\n- \"month\" => { \"$month\" => \"$commit_date\"},\n- \"year\" => {\"$year\" => \"$commit_date\"},\n- \"auto_score\" => 1\n+ '$project' => {\n+ 'month' => { '$month' => '$commit_date'},\n+ 'year' => {'$year' => '$commit_date'},\n+ 'auto_score' => 1\n}\n},\n{\n- \"$group\" => {\n- _id: {\"month\" => \"$month\", \"year\" => \"$year\"},\n- total: { \"$sum\" => \"$auto_score\" }\n+ '$group' => {\n+ _id: {'month' => '$month', 'year' => '$year'},\n+ total: { '$sum' => '$auto_score' }\n+ }\n+ },\n+ {\n+ '$sort' => {\n+ '_id.year' => 1,\n+ '_id.month' => 1\n}\n}\n]\n- ).sort_by do |r|\n- [\n- Date.parse(\n- Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" + r[:_id][\"year\"].to_s\n- )\n- ]\n- end\n- .collect do |r|\n+ ).collect do |r|\n[\n- Date::ABBR_MONTHNAMES[r[:_id][\"month\"]] + \" \" +r[:_id][\"year\"].to_s,\n- r[\"total\"]\n+ \"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}\",\n+ r['total']\n]\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Use of sort in aggregate query
332,090
06.06.2018 17:11:10
-19,080
d78909d641c2c844a06b06af46e0b3636e30a865
Test cases for UserReposJob
[ { "change_type": "MODIFY", "old_path": "test/fixtures/repo.json", "new_path": "test/fixtures/repo.json", "diff": "-{\n+[{\n\"id\": 67219068,\n\"name\": \"code-curiosity\",\n\"full_name\": \"prasadsurase/code-curiosity\",\n\"network_count\": 26,\n\"subscribers_count\": 1\n}\n+]\n" }, { "change_type": "MODIFY", "old_path": "test/jobs/user_repos_job_test.rb", "new_path": "test/jobs/user_repos_job_test.rb", "diff": "@@ -166,4 +166,28 @@ class UserReposJobTest < ActiveJob::TestCase\nassert_equal 25, repo.stars\nend\n+ describe 'set gh_repo_updated_at' do\n+ before do\n+ User.any_instance.stubs(:fetch_all_github_repos).returns(\n+ JSON.parse(File.read('test/fixtures/repo.json'))\n+ .collect{|i| Hashie::Mash.new(i)}\n+ )\n+ end\n+\n+ test 'when repo is already present' do\n+ create :repository, gh_id: 67219068\n+\n+ assert_equal 1, Repository.count\n+ UserReposJob.perform_now(@user.id.to_s)\n+ assert_equal 1, Repository.count\n+ assert_not_nil Repository.first.gh_repo_updated_at\n+ end\n+\n+ test 'when new repo is created' do\n+ assert_equal 0, Repository.count\n+ UserReposJob.perform_now(@user.id.to_s)\n+ assert_equal 1, Repository.count\n+ assert_not_nil Repository.first.gh_repo_updated_at\n+ end\n+ end\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Test cases for UserReposJob
332,090
06.06.2018 18:12:48
-19,080
9b0c4d8b75452b4fd43e2163c686fa8f21058d97
Test cases for GitFetcher model
[ { "change_type": "MODIFY", "old_path": "config/mongoid.yml", "new_path": "config/mongoid.yml", "diff": "@@ -132,6 +132,8 @@ test:\noptions:\nread:\nmax_pool_size: 1\n+ options:\n+ raise_not_found_error: false\nproduction:\nclients:\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixtures/git_commit.json", "diff": "+[\n+ {\n+ \"sha\": \"f01d77346dbb58a7d7502b4b9bb1d039c44d7609\",\n+ \"node_id\": \"MDY6Q29tbWl0MTE4NTg1ODY0OmYwMWQ3NzM0NmRiYjU4YTdkNzUwMmI0YjliYjFkMDM5YzQ0ZDc2MDk=\",\n+ \"commit\": {\n+ \"author\": {\n+ \"name\": \"pain11\",\n+ \"email\": \"rahul.rj9421@gmail.com\",\n+ \"date\": \"2018-02-05T07:38:03Z\"\n+ },\n+ \"committer\": {\n+ \"name\": \"pain11\",\n+ \"email\": \"rahul.rj9421@gmail.com\",\n+ \"date\": \"2018-02-05T07:38:03Z\"\n+ },\n+ \"message\": \"testing of models and controllers\",\n+ \"tree\": {\n+ \"sha\": \"1c268cb72da3a422ec7b0fb6ef08ae6bef03cbb5\",\n+ \"url\": \"https://api.github.com/repos/pain11/Facebook/git/trees/1c268cb72da3a422ec7b0fb6ef08ae6bef03cbb5\"\n+ },\n+ \"url\": \"https://api.github.com/repos/pain11/Facebook/git/commits/f01d77346dbb58a7d7502b4b9bb1d039c44d7609\",\n+ \"comment_count\": 0,\n+ \"verification\": {\n+ \"verified\": false,\n+ \"reason\": \"unsigned\",\n+ \"signature\": null,\n+ \"payload\": null\n+ }\n+ },\n+ \"url\": \"https://api.github.com/repos/pain11/Facebook/commits/f01d77346dbb58a7d7502b4b9bb1d039c44d7609\",\n+ \"html_url\": \"https://github.com/pain11/Facebook/commit/f01d77346dbb58a7d7502b4b9bb1d039c44d7609\",\n+ \"comments_url\": \"https://api.github.com/repos/pain11/Facebook/commits/f01d77346dbb58a7d7502b4b9bb1d039c44d7609/comments\",\n+ \"author\": {\n+ \"login\": \"pain11\",\n+ \"id\": 33185700,\n+ \"node_id\": \"MDQ6VXNlcjMzMTg1NzAw\",\n+ \"avatar_url\": \"https://avatars1.githubusercontent.com/u/33185700?v=4\",\n+ \"gravatar_id\": \"\",\n+ \"url\": \"https://api.github.com/users/pain11\",\n+ \"html_url\": \"https://github.com/pain11\",\n+ \"followers_url\": \"https://api.github.com/users/pain11/followers\",\n+ \"following_url\": \"https://api.github.com/users/pain11/following{/other_user}\",\n+ \"gists_url\": \"https://api.github.com/users/pain11/gists{/gist_id}\",\n+ \"starred_url\": \"https://api.github.com/users/pain11/starred{/owner}{/repo}\",\n+ \"subscriptions_url\": \"https://api.github.com/users/pain11/subscriptions\",\n+ \"organizations_url\": \"https://api.github.com/users/pain11/orgs\",\n+ \"repos_url\": \"https://api.github.com/users/pain11/repos\",\n+ \"events_url\": \"https://api.github.com/users/pain11/events{/privacy}\",\n+ \"received_events_url\": \"https://api.github.com/users/pain11/received_events\",\n+ \"type\": \"User\",\n+ \"site_admin\": false\n+ },\n+ \"committer\": {\n+ \"login\": \"pain11\",\n+ \"id\": 33185700,\n+ \"node_id\": \"MDQ6VXNlcjMzMTg1NzAw\",\n+ \"avatar_url\": \"https://avatars1.githubusercontent.com/u/33185700?v=4\",\n+ \"gravatar_id\": \"\",\n+ \"url\": \"https://api.github.com/users/pain11\",\n+ \"html_url\": \"https://github.com/pain11\",\n+ \"followers_url\": \"https://api.github.com/users/pain11/followers\",\n+ \"following_url\": \"https://api.github.com/users/pain11/following{/other_user}\",\n+ \"gists_url\": \"https://api.github.com/users/pain11/gists{/gist_id}\",\n+ \"starred_url\": \"https://api.github.com/users/pain11/starred{/owner}{/repo}\",\n+ \"subscriptions_url\": \"https://api.github.com/users/pain11/subscriptions\",\n+ \"organizations_url\": \"https://api.github.com/users/pain11/orgs\",\n+ \"repos_url\": \"https://api.github.com/users/pain11/repos\",\n+ \"events_url\": \"https://api.github.com/users/pain11/events{/privacy}\",\n+ \"received_events_url\": \"https://api.github.com/users/pain11/received_events\",\n+ \"type\": \"User\",\n+ \"site_admin\": false\n+ },\n+ \"parents\": [\n+ {\n+ \"sha\": \"160d61d28d818514eb42afe841bc3d8a35ec3e52\",\n+ \"url\": \"https://api.github.com/repos/pain11/Facebook/commits/160d61d28d818514eb42afe841bc3d8a35ec3e52\",\n+ \"html_url\": \"https://github.com/pain11/Facebook/commit/160d61d28d818514eb42afe841bc3d8a35ec3e52\"\n+ }\n+ ]\n+ }\n+]\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixtures/pull_request.json", "diff": "+{\n+ \"url\": \"https://api.github.com/repos/pain11/Facebook/issues/2\",\n+ \"repository_url\": \"https://api.github.com/repos/pain11/Facebook\",\n+ \"labels_url\": \"https://api.github.com/repos/pain11/Facebook/issues/2/labels{/name}\",\n+ \"comments_url\": \"https://api.github.com/repos/pain11/Facebook/issues/2/comments\",\n+ \"events_url\": \"https://api.github.com/repos/pain11/Facebook/issues/2/events\",\n+ \"html_url\": \"https://github.com/pain11/Facebook/pull/2\",\n+ \"id\": 294298548,\n+ \"node_id\": \"MDExOlB1bGxSZXF1ZXN0MTY3MDc0OTM2\",\n+ \"number\": 2,\n+ \"title\": \"Testing\",\n+ \"user\": {\n+ \"login\": \"pain11\",\n+ \"id\": 33185700,\n+ \"node_id\": \"MDQ6VXNlcjMzMTg1NzAw\",\n+ \"avatar_url\": \"https://avatars1.githubusercontent.com/u/33185700?v=4\",\n+ \"gravatar_id\": \"\",\n+ \"url\": \"https://api.github.com/users/pain11\",\n+ \"html_url\": \"https://github.com/pain11\",\n+ \"followers_url\": \"https://api.github.com/users/pain11/followers\",\n+ \"following_url\": \"https://api.github.com/users/pain11/following{/other_user}\",\n+ \"gists_url\": \"https://api.github.com/users/pain11/gists{/gist_id}\",\n+ \"starred_url\": \"https://api.github.com/users/pain11/starred{/owner}{/repo}\",\n+ \"subscriptions_url\": \"https://api.github.com/users/pain11/subscriptions\",\n+ \"organizations_url\": \"https://api.github.com/users/pain11/orgs\",\n+ \"repos_url\": \"https://api.github.com/users/pain11/repos\",\n+ \"events_url\": \"https://api.github.com/users/pain11/events{/privacy}\",\n+ \"received_events_url\": \"https://api.github.com/users/pain11/received_events\",\n+ \"type\": \"User\",\n+ \"site_admin\": false\n+ },\n+ \"labels\": [\n+\n+ ],\n+ \"state\": \"closed\",\n+ \"locked\": false,\n+ \"assignee\": null,\n+ \"assignees\": [\n+\n+ ],\n+ \"milestone\": null,\n+ \"comments\": 0,\n+ \"created_at\": \"2018-02-05T07:39:41Z\",\n+ \"updated_at\": \"2018-02-05T07:39:52Z\",\n+ \"closed_at\": \"2018-02-05T07:39:52Z\",\n+ \"author_association\": \"OWNER\",\n+ \"pull_request\": {\n+ \"url\": \"https://api.github.com/repos/pain11/Facebook/pulls/2\",\n+ \"html_url\": \"https://github.com/pain11/Facebook/pull/2\",\n+ \"diff_url\": \"https://github.com/pain11/Facebook/pull/2.diff\",\n+ \"patch_url\": \"https://github.com/pain11/Facebook/pull/2.patch\"\n+ },\n+ \"body\": \"\",\n+ \"score\": 100.0\n+}\n" }, { "change_type": "MODIFY", "old_path": "test/models/git_fetcher_test.rb", "new_path": "test/models/git_fetcher_test.rb", "diff": "-\nrequire 'test_helper'\nclass GitFetcherTest < ActiveSupport::TestCase\n+ before do\n+ options = {\n+ repo_owner: 'pain11',\n+ repo_name: 'Facebook'\n+ }\n+ @git_fetcher = GitFetcher.new(**options)\n+ create :repository, name: 'Facebook', owner: 'pain11'\n+ end\n+\n+ describe 'fetch commits' do\n+ describe 'commits are present' do\n+ before do\n+ GitFetcher.any_instance.stubs(:fetch_commits).returns(\n+ JSON.parse(File.read('test/fixtures/git_commit.json'))\n+ )\n+ GitFetcher.any_instance.stubs(:fetch_pull_request).returns(\n+ Hashie::Mash.new(\n+ JSON.parse(File.read('test/fixtures/pull_request.json'))\n+ )\n+ )\n+ end\n+\n+ test 'do not create commit if Committer is not present in code-curiosity' do\n+ assert_equal 0, Commit.count\n+ assert_equal 1, @git_fetcher.fetch_and_store_commits.count\n+ assert_equal 0, Commit.count\n+ end\n+ describe 'Committer is present in code-curiosity' do\n+ before do\n+ @user = create(\n+ :user,\n+ email: 'rahul.rj9421@gmail.com',\n+ created_at: Date.parse('2018-02-04')\n+ )\n+ end\n+\n+ test 'create commits which are committed after sign up' do\n+ assert_equal 0, Commit.count\n+ @git_fetcher.fetch_and_store_commits\n+ assert_equal 1, Commit.count\n+ end\n+\n+ test 'create pull request associated with commit if present' do\n+ assert_equal 0, PullRequest.count\n+ @git_fetcher.fetch_and_store_commits\n+ assert_equal 1, Commit.count\n+ assert_equal 1, PullRequest.count\n+ end\n+\n+ test 'do not create pull request associated with commit if not present' do\n+ GitFetcher.any_instance.stubs(:fetch_pull_request).returns(nil)\n+ assert_equal 0, PullRequest.count\n+ @git_fetcher.fetch_and_store_commits\n+ assert_equal 1, Commit.count\n+ assert_equal 0, PullRequest.count\n+ end\n+\n+ test 'do not create commits which are commmitted before sign up' do\n+ @user.set(created_at: Date.today)\n+ assert_equal 0, Commit.count\n+ assert_equal 1, @git_fetcher.fetch_and_store_commits.count\n+ assert_equal 0, Commit.count\n+ end\n+ end\n+ end\n+\n+ describe 'commits are not present' do\n+ test 'do not create commit records' do\n+ GitFetcher.any_instance.stubs(:fetch_commits).returns([])\n+ assert_equal 0, Commit.count\n+ @git_fetcher.fetch_and_store_commits\n+ assert_equal 0, Commit.count\n+ end\n+ end\n+ end\nend\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Test cases for GitFetcher model
332,090
09.06.2018 15:25:09
-19,080
cac395c52725e7d80aaf00f80d206e0a0cade7d4
Modified GitFetcher tests
[ { "change_type": "MODIFY", "old_path": "test/models/git_fetcher_test.rb", "new_path": "test/models/git_fetcher_test.rb", "diff": "@@ -10,8 +10,7 @@ class GitFetcherTest < ActiveSupport::TestCase\ncreate :repository, name: 'Facebook', owner: 'pain11'\nend\n- describe 'fetch commits' do\n- describe 'commits are present' do\n+ describe 'Commits found for given date range' do\nbefore do\nGitFetcher.any_instance.stubs(:fetch_commits).returns(\nJSON.parse(File.read('test/fixtures/git_commit.json'))\n@@ -23,11 +22,13 @@ class GitFetcherTest < ActiveSupport::TestCase\n)\nend\n- test 'do not create commit if Committer is not present in code-curiosity' do\n+ describe 'Committer is not present in code-curiosity' do\n+ test 'do not create commit record' do\nassert_equal 0, Commit.count\n- assert_equal 1, @git_fetcher.fetch_and_store_commits.count\n+ @git_fetcher.fetch_and_store_commits\nassert_equal 0, Commit.count\nend\n+ end\ndescribe 'Committer is present in code-curiosity' do\nbefore do\n@@ -44,32 +45,36 @@ class GitFetcherTest < ActiveSupport::TestCase\nassert_equal 1, Commit.count\nend\n- test 'create pull request associated with commit if present' do\n+ describe 'commit has pull request associated with it' do\n+ test 'should create pull request' do\nassert_equal 0, PullRequest.count\n@git_fetcher.fetch_and_store_commits\nassert_equal 1, Commit.count\nassert_equal 1, PullRequest.count\nend\n+ end\n- test 'do not create pull request associated with commit if not present' do\n+ describe 'commit has no pull request associated with it' do\n+ test 'should not create pull request' do\nGitFetcher.any_instance.stubs(:fetch_pull_request).returns(nil)\nassert_equal 0, PullRequest.count\n@git_fetcher.fetch_and_store_commits\nassert_equal 1, Commit.count\nassert_equal 0, PullRequest.count\nend\n+ end\ntest 'do not create commits which are commmitted before sign up' do\n@user.set(created_at: Date.today)\nassert_equal 0, Commit.count\n- assert_equal 1, @git_fetcher.fetch_and_store_commits.count\n+ @git_fetcher.fetch_and_store_commits\nassert_equal 0, Commit.count\nend\nend\nend\n- describe 'commits are not present' do\n- test 'do not create commit records' do\n+ describe 'Commits not found for given date range' do\n+ test 'do not create commit record' do\nGitFetcher.any_instance.stubs(:fetch_commits).returns([])\nassert_equal 0, Commit.count\n@git_fetcher.fetch_and_store_commits\n@@ -77,4 +82,3 @@ class GitFetcherTest < ActiveSupport::TestCase\nend\nend\nend\n-end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Modified GitFetcher tests
332,091
11.06.2018 08:57:45
-19,080
c9ddfbd0ac3edaac2b8947e8cb7c022385830fec
Move aggregation logic from helper to services
[ { "change_type": "MODIFY", "old_path": "app/controllers/home_controller.rb", "new_path": "app/controllers/home_controller.rb", "diff": "class HomeController < ApplicationController\n- include HomeHelper\n-\n- #load the before_actions only if the user is not logged in.\n- before_action :multi_line_chart, only: [:index], unless: proc { user_signed_in? }\n-\ndef index\nif user_signed_in?\nredirect_to dashboard_path\nreturn\n+ else\n+ @user_trend, @contribution_trend, @xAxis = MultiLineChart::Index.get\nend\nend\n@@ -23,5 +20,4 @@ class HomeController < ApplicationController\nrender layout: 'info'\nend\nend\n-\nend\n" }, { "change_type": "MODIFY", "old_path": "app/helpers/home_helper.rb", "new_path": "app/helpers/home_helper.rb", "diff": "@@ -25,85 +25,4 @@ module HomeHelper\n'col-md-12'\nend\nend\n-\n- def multi_line_chart\n-\n- users = User.collection.aggregate(\n- [\n- {\n- '$match' => {\n- 'auto_created' => false,\n- 'created_at' => { '$gt' => Date.parse('Apr 2016') }\n- }\n- },\n- {\n- '$project' => {\n- 'month' => { '$month' => '$created_at'},\n- 'year' => {'$year' => '$created_at'}\n- }\n- },\n- {\n- '$group' => {\n- _id: {'month' => '$month', 'year' => '$year'},\n- total: { '$sum' => 1 }\n- }\n- },\n- {\n- '$sort' => {\n- '_id.year' => 1,\n- '_id.month' => 1\n- }\n- }\n- ]\n- ).collect do |r|\n- [\n- \"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}\",\n- r['total']\n- ]\n- end\n-\n- contributions = Commit.collection.aggregate(\n- [\n- {\n- '$match' => {\n- 'commit_date' => { '$gt' => Date.parse('Apr 2016') }\n- }\n- },\n- {\n- '$project' => {\n- 'month' => { '$month' => '$commit_date'},\n- 'year' => {'$year' => '$commit_date'},\n- 'auto_score' => 1\n- }\n- },\n- {\n- '$group' => {\n- _id: {'month' => '$month', 'year' => '$year'},\n- total: { '$sum' => '$auto_score' }\n- }\n- },\n- {\n- '$sort' => {\n- '_id.year' => 1,\n- '_id.month' => 1\n- }\n- }\n- ]\n- ).collect do |r|\n- [\n- \"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}\",\n- r['total']\n- ]\n- end\n-\n- @user_trend = []\n- @contribution_trend = []\n- @user_xAxis = []\n- @xAxis = []\n-\n- users.map{ |user| @user_trend << user[1]; @user_xAxis << user[0]}\n- @user_trend = @user_trend.inject([]){ |acc, value| acc << acc.last.to_i + value.to_i }\n- contributions.map{ |contribution| @contribution_trend << contribution[1]; @xAxis << contribution[0]}\n- end\n-\nend\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/services/multi_line_chart/contribution.rb", "diff": "+class MultiLineChart::Contribution\n+ class << self\n+ def get\n+ contributions = Commit.collection.aggregate([match, project, group, sort])\n+ contributions.collect do |r|\n+ [\n+ \"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}\",\n+ r['total']\n+ ]\n+ end\n+ end\n+\n+ private\n+\n+ def match\n+ {\n+ '$match' => {\n+ 'commit_date' => { '$gt' => Date.parse('Apr 2016') }\n+ }\n+ }\n+ end\n+\n+ def project\n+ {\n+ '$project' => {\n+ 'month' => { '$month' => '$commit_date'},\n+ 'year' => {'$year' => '$commit_date'},\n+ 'auto_score' => 1\n+ }\n+ }\n+ end\n+\n+ def group\n+ {\n+ '$group' => {\n+ _id: {'month' => '$month', 'year' => '$year'},\n+ total: { '$sum' => '$auto_score' }\n+ }\n+ }\n+ end\n+\n+ def sort\n+ {\n+ '$sort' => {\n+ '_id.year' => 1,\n+ '_id.month' => 1\n+ }\n+ }\n+ end\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/services/multi_line_chart/index.rb", "diff": "+class MultiLineChart::Index\n+ def self.get\n+ users = MultiLineChart::User.get\n+ contributions = MultiLineChart::Contribution.get\n+\n+ xAxis = contributions.map(&:first)\n+ u_trend = users.inject([]){ |acc, value| acc << acc.last.to_i + value[1].to_i }\n+ c_trend = contributions.inject([]){ |acc, value| acc << acc.last.to_i + value[1].to_i }\n+\n+ [u_trend, c_trend, xAxis]\n+ end\n+end\n" }, { "change_type": "ADD", "old_path": null, "new_path": "app/services/multi_line_chart/user.rb", "diff": "+class MultiLineChart::User\n+ class << self\n+ def get\n+ users = User.collection.aggregate([match, project, group, sort])\n+ users.collect do |r|\n+ [\n+ \"#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}\",\n+ r['total']\n+ ]\n+ end\n+ end\n+\n+ private\n+\n+ def match\n+ {\n+ '$match' => {\n+ 'auto_created' => false,\n+ 'created_at' => { '$gt' => Date.parse('Apr 2016') }\n+ }\n+ }\n+ end\n+\n+ def project\n+ {\n+ '$project' => {\n+ 'month' => { '$month' => '$created_at'},\n+ 'year' => {'$year' => '$created_at'}\n+ }\n+ }\n+ end\n+\n+ def group\n+ {\n+ '$group' => {\n+ _id: {'month' => '$month', 'year' => '$year'},\n+ total: { '$sum' => 1 }\n+ }\n+ }\n+ end\n+\n+ def sort\n+ {\n+ '$sort' => {\n+ '_id.year' => 1,\n+ '_id.month' => 1\n+ }\n+ }\n+ end\n+ end\n+end\n" } ]
Ruby
MIT License
joshsoftware/code-curiosity
Move aggregation logic from helper to services