Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit c62a9e1

Browse files
authored
v0.2.3 (#12)
* Update webpack dev server * Update email copy * Add pending playbacks path
1 parent c72178c commit c62a9e1

File tree

12 files changed

+358
-329
lines changed

12 files changed

+358
-329
lines changed

app/assets/stylesheets/minireset.sass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ td,
8080
th
8181
padding: 0
8282
text-align: left
83+
border-color: #ccc !important

app/controllers/playbacks_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
class PlaybacksController < ApplicationController
2-
before_action :authenticate_user!, except: %[show]
2+
before_action :authenticate_user!, except: %i[show pending]
33
before_action :set_playback, only: %i[show edit update destroy]
44

5+
def pending
6+
@playbacks = Playback.where(comments_count: params[:comments] || 0)
7+
end
8+
59
def index
610
@playbacks = Playback.all
711
end

app/mailers/application_mailer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class ApplicationMailer < ActionMailer::Base
2-
default from: 'no-reply@fusebox-playbacks.herokuapp.com'
2+
default from: 'CAST <designhops@wearecast.org.uk>'
33
layout 'mailer'
44
end

app/models/comment.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ class Comment < ApplicationRecord
44
validates :author, :body, presence: true
55

66
before_validation :mark_step_as_done!
7+
after_create :update_comments_count!
78

89
private
910

1011
def mark_step_as_done!
1112
step.update_column(:completed_on, Date.today) if done
1213
end
14+
15+
def update_comments_count!
16+
Playback.increment_counter(:comments_count, commentable.playback_id)
17+
end
1318
end
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<h1><%= @comment.author %> <%= comment_done_message(@comment) %></h1>
22

3-
<h3 style="margin: 0;">Step</h3>
3+
<h3 style="margin: 0;">Section</h3>
44
<p style="margin: 5px 0 20px;"><%= raw @comment.commentable.name %></p>
55

66
<h3 style="margin: 0 0 5px;">Comment</h3>
77
<div style="background: #f2f2f2; padding: 20px; margin-bottom: 20px;">
88
<%= raw @comment.body %>
99
</div>
1010

11-
<h3><%= link_to 'Reply here', new_comment_url(@comment.commentable) %></h3>
11+
<h3><%= link_to 'Reply here', new_comment_url(@comment.commentable) %></h3>
12+
13+
<small>This is an automated email for your records.</small>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="maxw1050 mx-auto px15">
2+
<h1 class="h2 bold my40">Pending Playbacks</h1>
3+
4+
<table>
5+
<thead>
6+
<tr>
7+
<th>Organisation Name</th>
8+
<th>No. of comments</th>
9+
<th></th>
10+
</tr>
11+
</thead>
12+
13+
<tbody>
14+
<% @playbacks.each do |playback| %>
15+
<tr>
16+
<td><%= playback.organisation_name %> <small>by <%= playback.author_name %></small></td>
17+
<td><%= playback.comments_count %></td>
18+
<td><%= link_to 'View', playback %></td>
19+
</tr>
20+
<% end %>
21+
</tbody>
22+
</table>
23+
</div>

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
resources :playbacks
55

6+
get '/pending/playbacks/(:count)', to: 'playbacks#pending', as: 'pending_playbacks'
7+
68
get '/support/:commentable_id/comments', to: 'comments#new', as: 'new_comment'
79
post '/support/:commentable_id/comments', to: 'comments#create'
810

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class AddCounterCacheToPlaybacks < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :playbacks, :comments_count, :integer, null: false, default: 0
4+
5+
reversible do |dir|
6+
dir.up do
7+
Section.joins(:comments).group(:playback_id).count(:commentable_id).each do |id, count|
8+
Playback.find(id).update(comments_count: count)
9+
print '.'
10+
end
11+
end
12+
end
13+
end
14+
end

db/schema.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2018_11_27_160118) do
13+
ActiveRecord::Schema.define(version: 2019_02_06_170022) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -52,6 +52,8 @@
5252
t.datetime "created_at", null: false
5353
t.datetime "updated_at", null: false
5454
t.string "source"
55+
t.string "email"
56+
t.integer "comments_count", default: 0, null: false
5557
end
5658

5759
create_table "sections", force: :cascade do |t|

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"vue-template-compiler": "^2.5.17"
99
},
1010
"devDependencies": {
11-
"webpack-dev-server": "2.11.2"
11+
"webpack-dev-server": ">=3.1.11"
1212
}
1313
}

0 commit comments

Comments
 (0)