Merge branch 'dev'

This commit is contained in:
gregoirenovel 2017-10-17 14:18:05 +02:00
commit ecb475e0b0
12 changed files with 76 additions and 21 deletions

View file

@ -1 +1 @@
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><title>Shape</title><path d="M18.34 7.287L7.038 17.73a3.358 3.358 0 0 1-2.292.877c-.867 0-1.68-.312-2.291-.877a2.867 2.867 0 0 1-.948-2.118c0-.801.337-1.554.948-2.119L14.94 1.954c.785-.725 2.159-.724 2.944 0 .812.751.812 1.972 0 2.722L6.675 15.036c-.33.306-.912.307-1.243 0a.779.779 0 0 1-.258-.574c0-.217.092-.422.258-.575l8.08-7.468a.669.669 0 0 0 .221-.492.67.67 0 0 0-.221-.494.816.816 0 0 0-1.065.001l-8.08 7.469c-.451.416-.699.969-.699 1.559s.248 1.143.698 1.56c.9.83 2.473.832 3.375 0L18.95 5.66C19.627 5.035 20 4.202 20 3.315c0-.886-.373-1.72-1.05-2.345A3.718 3.718 0 0 0 16.412 0c-.959 0-1.86.344-2.538.97L1.389 12.51C.493 13.336 0 14.44 0 15.612c0 1.173.493 2.276 1.39 3.103C2.283 19.544 3.475 20 4.745 20s2.463-.456 3.359-1.284l11.3-10.444a.667.667 0 0 0 .222-.492c0-.187-.08-.361-.222-.493a.818.818 0 0 0-1.065 0z" fill-rule="nonzero" fill="#4393F3"/></svg>
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>ic_attach</title><g fill="none" fill-rule="evenodd"><path d="M13.153 6.701l-4.512 7.815a1.638 1.638 0 0 0 .604 2.237 1.638 1.638 0 0 0 2.24-.596l3.324-5.758 1.843-3.193a3.277 3.277 0 0 0-1.207-4.475 3.277 3.277 0 0 0-4.478 1.192L7.642 9.681l-.395.686-2.533 4.387a4.23 4.23 0 0 0 1.557 5.774l.458.265a4.229 4.229 0 0 0 5.779-1.539l6.464-11.196" stroke="#4393F3" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M0 0h24v24H0z"/></g></svg>

Before

Width:  |  Height:  |  Size: 952 B

After

Width:  |  Height:  |  Size: 551 B

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="18" viewBox="0 0 22 18"><g fill="none" fill-rule="evenodd"><path stroke="#35D49E" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 3h-8L9 1H3c-1.1 0-1.99.9-1.99 2L1 15c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"/><path d="M14 10H6.533M11 7l4 3-4 3" stroke="#35D49E" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/><path d="M-1-3h24v24H-1z"/></g></svg>
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>ic_follow_folder</title><g fill="none" fill-rule="evenodd"><path d="M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2z" stroke="#35D49E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><g stroke="#35D49E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 13H7.533M12 10l4 3-4 3"/></g><path d="M0 0h24v24H0z"/></g></svg>

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 494 B

View file

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="640.5 640.5 512 512"><path d="M820.864 861.591h151.273v-56.727c0-20.879-7.387-38.705-22.159-53.478-14.773-14.772-32.599-22.159-53.478-22.159s-38.705 7.387-53.477 22.159c-14.773 14.773-22.159 32.599-22.159 53.478v56.727zm245.818 28.364v170.182c0 7.879-2.758 14.575-8.272 20.091-5.516 5.515-12.212 8.272-20.091 8.272H754.682c-7.879 0-14.576-2.758-20.091-8.272-5.515-5.516-8.272-12.212-8.272-20.091V889.955c0-7.879 2.757-14.576 8.272-20.091s12.212-8.273 20.091-8.273h9.455v-56.727c0-36.243 13-67.364 39-93.364s57.121-39 93.364-39c36.242 0 67.363 13 93.363 39s39 57.121 39 93.364v56.727h9.455c7.879 0 14.575 2.758 20.091 8.273 5.514 5.515 8.272 12.212 8.272 20.091z" fill="#999999"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="640.5 640.5 512 512"><path d="M820.864 861.591h151.273v-56.727c0-20.879-7.387-38.705-22.159-53.478-14.773-14.772-32.599-22.159-53.478-22.159s-38.705 7.387-53.477 22.159c-14.773 14.773-22.159 32.599-22.159 53.478v56.727zm245.818 28.364v170.182c0 7.879-2.758 14.575-8.272 20.091-5.516 5.515-12.212 8.272-20.091 8.272H754.682c-7.879 0-14.576-2.758-20.091-8.272-5.515-5.516-8.272-12.212-8.272-20.091V889.955c0-7.879 2.757-14.576 8.272-20.091s12.212-8.273 20.091-8.273h9.455v-56.727c0-36.243 13-67.364 39-93.364s57.121-39 93.364-39c36.242 0 67.363 13 93.363 39s39 57.121 39 93.364v56.727h9.455c7.879 0 14.575 2.758 20.091 8.273 5.514 5.515 8.272 12.212 8.272 20.091z" fill="#999999"/></svg>

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 758 B

View file

@ -1 +1 @@
<svg width="22" height="22" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>ic_form</title><defs><rect id="a" x="3" y="8" width="18" height="7" rx="1"/><path d="M7 3h10a1 1 0 0 1 1 1v2H6V4a1 1 0 0 1 1-1z" id="b"/><path d="M0 0h12v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V0z" id="c"/></defs><g fill="none" fill-rule="evenodd"><path d="M-1-1h24v24H-1z"/><g transform="translate(-1 -1)"><use fill="#FFF" xlink:href="#a"/><rect stroke="#4393F3" stroke-width="2" x="2" y="7" width="20" height="9" rx="1"/></g><g transform="translate(-1 -1)"><use fill="#FFF" xlink:href="#b"/><path stroke="#4393F3" stroke-width="2" d="M7 2h10a2 2 0 0 1 2 2v3H5V4a2 2 0 0 1 2-2z"/></g><g transform="translate(5 13)"><use fill="#FFF" xlink:href="#c"/><path stroke="#4393F3" stroke-width="2" d="M-1-1h14v7a2 2 0 0 1-2 2H1a2 2 0 0 1-2-2v-7z"/><rect fill="#4393F3" x="1" y="4" width="6" height="1.5" rx=".75"/><rect fill="#4393F3" x="1" y="1.5" width="10" height="1.5" rx=".75"/></g></g></svg>
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>Imprimer</title><defs><rect id="a" x="3" y="8" width="18" height="7" rx="1"/><path d="M7 3h10a1 1 0 0 1 1 1v2H6V4a1 1 0 0 1 1-1z" id="b"/><path d="M0 0h12v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V0z" id="c"/></defs><g fill="none" fill-rule="evenodd"><path d="M0 0h24v24H0z"/><use fill="#FFF" xlink:href="#a"/><rect stroke="#4393F3" stroke-width="2" x="2" y="7" width="20" height="9" rx="1"/><use fill="#FFF" xlink:href="#b"/><path stroke="#4393F3" stroke-width="2" d="M7 2h10a2 2 0 0 1 2 2v3H5V4a2 2 0 0 1 2-2z"/><g transform="translate(6 14)"><use fill="#FFF" xlink:href="#c"/><path stroke="#4393F3" stroke-width="2" d="M-1-1h14v7a2 2 0 0 1-2 2H1a2 2 0 0 1-2-2v-7z"/><rect fill="#4393F3" x="1" y="4" width="6" height="1.5" rx=".75"/><rect fill="#4393F3" x="1" y="1.5" width="10" height="1.5" rx=".75"/></g></g></svg>

Before

Width:  |  Height:  |  Size: 1,014 B

After

Width:  |  Height:  |  Size: 941 B

View file

@ -32,8 +32,8 @@
a {
display: inline-block;
height: 71px;
line-height: 71px;
height: 72px;
line-height: 72px;
font-size: 18px;
color: $black;

View file

@ -36,13 +36,16 @@ class StatsController < ApplicationController
private
def max_date
if administration_signed_in?
Time.now.to_date
else
Time.now.beginning_of_month - 1.second
end
end
def last_four_months_hash(association, date_attribute)
min_date = 3.months.ago.beginning_of_month.to_date
if administration_signed_in?
max_date = Time.now.to_date
else
max_date = Time.now.beginning_of_month - 1.second
end
association
.where(date_attribute => min_date..max_date)
@ -56,6 +59,7 @@ class StatsController < ApplicationController
def cumulative_hash(association, date_attribute)
sum = 0
association
.where("#{date_attribute.to_s} < ?", max_date)
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
.count
.to_a

View file

@ -60,7 +60,7 @@ class Dossier < ActiveRecord::Base
scope :termine, -> { not_archived.state_termine }
scope :downloadable, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private) }
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
scope :without_followers, -> { includes(:follows).where(follows: { id: nil }) }
scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) }
scope :with_unread_notifications, -> { where(notifications: { already_read: false }) }
accepts_nested_attributes_for :individual

View file

@ -35,5 +35,7 @@ module TPS
end
config.active_job.queue_adapter = :delayed_job
config.action_view.sanitized_allowed_tags = ActionView::Base.sanitized_allowed_tags + ['u']
end
end

View file

@ -26,8 +26,7 @@ worker_processes 2
# we use a shorter backlog for quicker failover when busy
listen "127.0.0.1:3000", :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
timeout 60
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,

View file

@ -62,4 +62,25 @@ EOF
file.write(content)
file.close
end
def run_and_stop_if_error(cmd)
sh cmd do |ok, res|
if !ok
abort "#{cmd} failed with result : #{res.exitstatus}"
end
end
end
task :import_db do
filename = "tps_prod_#{1.day.ago.strftime("%d-%m-%Y")}.sql"
local_file = "/tmp/#{filename}"
run_and_stop_if_error "scp deploy@sgmap_backup:/var/backup/production1/db/#{filename} #{local_file}"
Rake::Task["db:drop"].invoke
Rake::Task["db:create"].invoke
run_and_stop_if_error "psql tps_development -f #{local_file}"
Rake::Task["db:migrate"].invoke
Rake::Task["db:environment:set"].invoke("RAILS_ENV=development")
end
end

View file

@ -51,20 +51,42 @@ describe StatsController, type: :controller do
describe '#cumulative_hash' do
before do
Timecop.freeze(Time.new(2016, 10, 2))
FactoryGirl.create(:procedure, :created_at => 55.days.ago, :updated_at => 43.days.ago)
FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 40.days.ago)
FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago)
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 20.days.ago)
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 10.days.ago)
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 1.hour.ago)
end
let (:association) { Procedure.all }
subject { StatsController.new.send(:cumulative_hash, association, :updated_at) }
context "while a super admin is logged in" do
before { allow(@controller).to receive(:administration_signed_in?).and_return(true) }
it { expect(subject).to eq({
20.days.ago.beginning_of_month => 2,
10.days.ago.beginning_of_month => 3
})
}
subject { @controller.send(:cumulative_hash, association, :updated_at) }
it { expect(subject).to eq({
2.month.ago.beginning_of_month => 2,
1.month.ago.beginning_of_month => 4,
1.hour.ago.beginning_of_month => 5
})
}
end
context "while a super admin is not logged in" do
before { allow(@controller).to receive(:administration_signed_in?).and_return(false) }
subject { @controller.send(:cumulative_hash, association, :updated_at) }
it { expect(subject).to eq({
2.month.ago.beginning_of_month => 2,
1.month.ago.beginning_of_month => 4
})
}
end
after { Timecop.return }
end
describe "#procedures_count_per_administrateur" do

View file

@ -3,6 +3,13 @@ require 'spec_helper'
describe Dossier do
let(:user) { create(:user) }
describe "without_followers scope" do
let!(:dossier) { create(:dossier, :followed, :with_entreprise, user: user) }
let!(:dossier2) { create(:dossier, :with_entreprise, user: user) }
it { expect(Dossier.without_followers.to_a).to eq([dossier2]) }
end
describe 'methods' do
let(:dossier) { create(:dossier, :with_entreprise, user: user) }