Skip to content

Commit

Permalink
Merge branch 'release/0.17.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashnikovisme committed Apr 8, 2017
2 parents 83e7334 + b9a5299 commit 396fad1
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/web/admin/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
@import 'bootstrap-datetimepicker'
@import 'font-awesome'

.container
width: 90%

.link
cursor: pointer

Expand Down
16 changes: 15 additions & 1 deletion app/controllers/web/admin/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ class Web::Admin::WelcomeController < Web::Admin::ApplicationController

def index
@report = if signed_as_admin?
most_viewed_news_count = News.joins(:page_views).select('news.*, count(views.id) as vcount').group('news.id').order('vcount DESC').first
most_viewed_event_count = Event.joins(:page_views).select('events.*, count(views.id) as vcount').group('events.id').order('vcount DESC').first
counts = {}
member_id = View.where(record_type: 'Member').map(&:record_id).group_by(&:itself).each do |k, v|
counts[k] = v.length
end.max_by do |element|
element.last.count
end
member = Member.find member_id[0]
{
users_count: User.count,
event_registrations_count: Event::Registration.count,
Expand All @@ -15,7 +24,12 @@ def index
news_views: View.where(record_type: 'News').count,
article_views: View.where(record_type: 'Article').count,
email_sended: Delivery::Campaign.done.map(&:contacts).flatten.count,
email_sended_this_month: Delivery::Campaign.done.where('created_at > ?', DateTime.now - 1.month).map(&:contacts).flatten.count
email_sended_this_month: Delivery::Campaign.done.where('created_at > ?', DateTime.now - 1.month).map(&:contacts).flatten.count,
event_views: View.where(record_type: 'Event').count,
member_views: View.where(record_type: 'Member').count,
most_viewed_news: "#{most_viewed_news_count.title} (#{most_viewed_news_count.page_views.count})",
most_viewed_event: "#{most_viewed_event_count.title} (#{most_viewed_event_count.page_views.count})",
member: "#{member.decorate.short_name} (#{member_id[1].count})"
}
end
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/web/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def index

def show
@event = ::Event.includes(:online_conference).find(params[:id]).decorate
View.create! user_id: current_user&.id, record_id: @event.id, record_type: 'Event'
organizers = @event.registrations.organizers
attenders = @event.registrations.attenders
@all_registrations = Event::RegistrationDecorator.decorate_collection(organizers + attenders)
Expand Down
1 change: 1 addition & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Event < ActiveRecord::Base
has_many :admin_comments, -> { where(comment_type: :admin) }, class_name: 'Comment', as: :record
has_one :online_conference, class_name: 'ActivityLines::Corporative::OnlineConference'
has_and_belongs_to_many :places
has_many :page_views, class_name: 'View', as: :record

mount_uploader :main_photo, PhotoUploader

Expand Down
5 changes: 5 additions & 0 deletions config/locales/ru/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ ru:
uniq_users_event_registrations_count: Количество уникальных пользователей, участвоваших в мероприятиях
email_sended: Всего Email отправлено
email_sended_this_month: Email отправлено в этом месяце
event_views: Всего просмотров мероприятий
member_views: Всего просмотров профилей членов МИЦ
most_viewed_news: Самая просматриваемая новость
most_viewed_event: Самое просматриваемое мероприятие
member: Самый просматриваемый профиль члена МИЦ
unviewed:
index:
title: Непросмотренные
Expand Down
1 change: 1 addition & 0 deletions test/factories/members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
member_state { Member.state_machines[:member_state].states.map(&:name).sample }
role 'user'
type 'Member'
questionary_state { User.state_machines[:questionary_state].states.map(&:name).sample.to_s }

trait :corporate_head do
ticket 238
Expand Down
2 changes: 2 additions & 0 deletions test/factories/questionaries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
type 'Questionary'
municipality { Member.municipality.values.sample }
locality { Member.locality.values.sample }
source_to_know { generate :string }
questionary_state { Questionary.state_machines[:questionary_state].states.map(&:name).sample.to_s }
end
end
1 change: 1 addition & 0 deletions test/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
state { User.state_machines[:state].states.map(&:name).first.to_s }
member_state { User.state_machines[:state].states.map(&:name).first.to_s }
role { 'user' }
questionary_state { User.state_machines[:questionary_state].states.map(&:name).sample.to_s }
end
end

0 comments on commit 396fad1

Please sign in to comment.