[from now] 2014/11/18 23:03:34

diff --git a/lib/tasks/diagram.rake b/lib/tasks/diagram.rake
new file mode 100644
index 0000000..f592da6
--- /dev/null
+++ b/lib/tasks/diagram.rake
@@ -0,0 +1,2 @@
+namespace :diagram do
+end
[from now] 2014/11/18 23:53:54

diff --git a/app/controllers/keywords_controller.rb b/app/controllers/keywords_controller.rb
index d9011da..d335ae9 100644
--- a/app/controllers/keywords_controller.rb
+++ b/app/controllers/keywords_controller.rb
@@ -42,6 +42,6 @@ class KeywordsController < ApplicationController
     end

     def keyword_params
-      params.require(:keyword).permit(:name, :article_id, :article_has_keyword_id, :value, :user_id)
+      params.require(:keyword).permit(:name, :article_id, :value_present, :value_last_week, :value_last_month, :user_id, :article_has_keyword_id)
     end
 end
diff --git a/app/models/keyword.rb b/app/models/keyword.rb
index 54d10fc..817d3fd 100644
--- a/app/models/keyword.rb
+++ b/app/models/keyword.rb
@@ -1,5 +1,5 @@
 class Keyword < ActiveRecord::Base
-  has_many :article_has_keywords
   has_many :articles, :through => :article_has_keywords
+  has_many :article_has_keywords
   belongs_to :user
 end
diff --git a/app/views/keywords/_form.html.erb b/app/views/keywords/_form.html.erb
index 36f7702..c4b9245 100644
--- a/app/views/keywords/_form.html.erb
+++ b/app/views/keywords/_form.html.erb
@@ -20,17 +20,25 @@
     <%= f.text_field :article_id %>
   </div>
   <div class="field">
-    <%= f.label :article_has_keyword_id %><br>
-    <%= f.text_field :article_has_keyword_id %>
+    <%= f.label :value_present %><br>
+    <%= f.text_field :value_present %>
+  </div>
+  <div class="field">
+    <%= f.label :value_last_week %><br>
+    <%= f.text_field :value_last_week %>
   </div>
   <div class="field">
-    <%= f.label :value %><br>
-    <%= f.text_field :value %>
+    <%= f.label :value_last_month %><br>
+    <%= f.text_field :value_last_month %>
   </div>
   <div class="field">
     <%= f.label :user_id %><br>
     <%= f.text_field :user_id %>
   </div>
+  <div class="field">
+    <%= f.label :article_has_keyword_id %><br>
+    <%= f.text_field :article_has_keyword_id %>
+  </div>
   <div class="actions">
     <%= f.submit %>
   </div>
diff --git a/app/views/keywords/index.html.erb b/app/views/keywords/index.html.erb
index b51bc7a..50bafaf 100644
--- a/app/views/keywords/index.html.erb
+++ b/app/views/keywords/index.html.erb
@@ -5,9 +5,11 @@
     <tr>
       <th>Name</th>
       <th>Article</th>
-      <th>Article has keyword</th>
-      <th>Value</th>
+      <th>Value present</th>
+      <th>Value last week</th>
+      <th>Value last month</th>
       <th>User</th>
+      <th>Article has keyword</th>
       <th colspan="3"></th>
     </tr>
   </thead>
@@ -17,9 +19,11 @@
       <tr>
         <td><%= keyword.name %></td>
         <td><%= keyword.article %></td>
-        <td><%= keyword.article_has_keyword %></td>
-        <td><%= keyword.value %></td>
+        <td><%= keyword.value_present %></td>
+        <td><%= keyword.value_last_week %></td>
+        <td><%= keyword.value_last_month %></td>
         <td><%= keyword.user %></td>
+        <td><%= keyword.article_has_keyword %></td>
         <td><%= link_to 'Show', keyword %></td>
         <td><%= link_to 'Edit', edit_keyword_path(keyword) %></td>
         <td><%= link_to 'Destroy', keyword, method: :delete, data: { confirm: 'Are you sure?' } %></td>
diff --git a/app/views/keywords/index.json.jbuilder b/app/views/keywords/index.json.jbuilder
index c650095..0bcf6af 100644
--- a/app/views/keywords/index.json.jbuilder
+++ b/app/views/keywords/index.json.jbuilder
@@ -1,4 +1,4 @@
 json.array!(@keywords) do |keyword|
-  json.extract! keyword, :id, :name, :article_id, :article_has_keyword_id, :value, :user_id
+  json.extract! keyword, :id, :name, :article_id, :value_present, :value_last_week, :value_last_month, :user_id, :article_has_keyword_id
   json.url keyword_url(keyword, format: :json)
 end
diff --git a/app/views/keywords/show.html.erb b/app/views/keywords/show.html.erb
index 6795a46..b884e2f 100644
--- a/app/views/keywords/show.html.erb
+++ b/app/views/keywords/show.html.erb
@@ -11,13 +11,18 @@
 </p>

 <p>
-  <strong>Article has keyword:</strong>
-  <%= @keyword.article_has_keyword %>
+  <strong>Value present:</strong>
+  <%= @keyword.value_present %>
+</p>
+
+<p>
+  <strong>Value last week:</strong>
+  <%= @keyword.value_last_week %>
 </p>

 <p>
-  <strong>Value:</strong>
-  <%= @keyword.value %>
+  <strong>Value last month:</strong>
+  <%= @keyword.value_last_month %>
 </p>

 <p>
@@ -25,5 +30,10 @@
   <%= @keyword.user %>
 </p>

+<p>
+  <strong>Article has keyword:</strong>
+  <%= @keyword.article_has_keyword %>
+</p>
+
 <%= link_to 'Edit', edit_keyword_path(@keyword) %> |
 <%= link_to 'Back', keywords_path %>
diff --git a/app/views/keywords/show.json.jbuilder b/app/views/keywords/show.json.jbuilder
index 4511ec1..83e705e 100644
--- a/app/views/keywords/show.json.jbuilder
+++ b/app/views/keywords/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @keyword, :id, :name, :article_id, :article_has_keyword_id, :value, :user_id, :created_at, :updated_at
+json.extract! @keyword, :id, :name, :article_id, :value_present, :value_last_week, :value_last_month, :user_id, :article_has_keyword_id, :created_at, :updated_at
diff --git a/config/routes.rb b/config/routes.rb
index 0c8c580..e8fe89b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,10 +1,10 @@
 Rails.application.routes.draw do
+  resources :keywords
+
   resources :articles

   resources :feeds

-  resources :keywords
-
   resources :categories

   # Devise
diff --git a/db/migrate/20141118105202_create_keywords.rb b/db/migrate/20141118105202_create_keywords.rb
deleted file mode 100644
index 912233f..0000000
--- a/db/migrate/20141118105202_create_keywords.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class CreateKeywords < ActiveRecord::Migration
-  def change
-    create_table :keywords do |t|
-      t.string :name
-      t.references :article, index: true
-      t.references :article_has_keyword, index: true
-      t.float :value
-      t.references :user, index: true
-
-      t.timestamps
-    end
-  end
-end
diff --git a/db/migrate/20141118144837_create_keywords.rb b/db/migrate/20141118144837_create_keywords.rb
new file mode 100644
index 0000000..199233c
--- /dev/null
+++ b/db/migrate/20141118144837_create_keywords.rb
@@ -0,0 +1,15 @@
+class CreateKeywords < ActiveRecord::Migration
+  def change
+    create_table :keywords do |t|
+      t.string :name
+      t.references :article, index: true
+      t.float :value_present
+      t.float :value_last_week
+      t.float :value_last_month
+      t.references :user, index: true
+      t.references :article_has_keyword, index: true
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7d5a615..4d0efab 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.

-ActiveRecord::Schema.define(version: 20141118113443) do
+ActiveRecord::Schema.define(version: 20141118144837) do

   create_table "article_has_keywords", force: true do |t|
     t.integer  "article_id"
@@ -74,9 +74,11 @@ ActiveRecord::Schema.define(version: 20141118113443) do
   create_table "keywords", force: true do |t|
     t.string   "name"
     t.integer  "article_id"
-    t.integer  "article_has_keyword_id"
-    t.float    "value"
+    t.float    "value_present"
+    t.float    "value_last_week"
+    t.float    "value_last_month"
     t.integer  "user_id"
+    t.integer  "article_has_keyword_id"
     t.datetime "created_at"
     t.datetime "updated_at"
   end
diff --git a/doc/mensagg TableDesign.numbers/Index.zip b/doc/mensagg TableDesign.numbers/Index.zip
index 2eb36f6..f5eeefb 100644
Binary files a/doc/mensagg TableDesign.numbers/Index.zip and b/doc/mensagg TableDesign.numbers/Index.zip differ
diff --git a/doc/mensagg TableDesign.numbers/Metadata/Properties.plist b/doc/mensagg TableDesign.numbers/Metadata/Properties.plist
index 3391ae3..2a09f60 100644
Binary files a/doc/mensagg TableDesign.numbers/Metadata/Properties.plist and b/doc/mensagg TableDesign.numbers/Metadata/Properties.plist differ
diff --git a/doc/mensagg TableDesign.numbers/preview-micro.jpg b/doc/mensagg TableDesign.numbers/preview-micro.jpg
index 2959bc3..883285b 100644
Binary files a/doc/mensagg TableDesign.numbers/preview-micro.jpg and b/doc/mensagg TableDesign.numbers/preview-micro.jpg differ
diff --git a/doc/mensagg TableDesign.numbers/preview-web.jpg b/doc/mensagg TableDesign.numbers/preview-web.jpg
index 2ea7a8d..5c5697f 100644
Binary files a/doc/mensagg TableDesign.numbers/preview-web.jpg and b/doc/mensagg TableDesign.numbers/preview-web.jpg differ
diff --git a/doc/mensagg TableDesign.numbers/preview.jpg b/doc/mensagg TableDesign.numbers/preview.jpg
index 750daf7..a54897c 100644
Binary files a/doc/mensagg TableDesign.numbers/preview.jpg and b/doc/mensagg TableDesign.numbers/preview.jpg differ
diff --git a/spec/views/keywords/edit.html.erb_spec.rb b/spec/views/keywords/edit.html.erb_spec.rb
index dec8456..ee231b0 100644
--- a/spec/views/keywords/edit.html.erb_spec.rb
+++ b/spec/views/keywords/edit.html.erb_spec.rb
@@ -4,10 +4,12 @@ RSpec.describe "keywords/edit", :type => :view do
   before(:each) do
     @keyword = assign(:keyword, Keyword.create!(
       :name => "MyString",
-      :article_id => nil,
-      :article_has_keyword_id => nil,
-      :value => 1.5,
-      :user_id => nil
+      :article => nil,
+      :value_present => 1.5,
+      :value_last_week => 1.5,
+      :value_last_month => 1.5,
+      :user => nil,
+      :article_has_keyword => nil
     ))
   end

@@ -20,11 +22,15 @@ RSpec.describe "keywords/edit", :type => :view do

       assert_select "input#keyword_article_id[name=?]", "keyword[article_id]"

-      assert_select "input#keyword_article_has_keyword_id[name=?]", "keyword[article_has_keyword_id]"
+      assert_select "input#keyword_value_present[name=?]", "keyword[value_present]"
+
+      assert_select "input#keyword_value_last_week[name=?]", "keyword[value_last_week]"

-      assert_select "input#keyword_value[name=?]", "keyword[value]"
+      assert_select "input#keyword_value_last_month[name=?]", "keyword[value_last_month]"

       assert_select "input#keyword_user_id[name=?]", "keyword[user_id]"
+
+      assert_select "input#keyword_article_has_keyword_id[name=?]", "keyword[article_has_keyword_id]"
     end
   end
 end
diff --git a/spec/views/keywords/index.html.erb_spec.rb b/spec/views/keywords/index.html.erb_spec.rb
index 40add89..9c30c2a 100644
--- a/spec/views/keywords/index.html.erb_spec.rb
+++ b/spec/views/keywords/index.html.erb_spec.rb
@@ -6,16 +6,20 @@ RSpec.describe "keywords/index", :type => :view do
       Keyword.create!(
         :name => "Name",
         :article => nil,
-        :article_has_keyword => nil,
-        :value => 1.5,
-        :user => nil
+        :value_present => 1.5,
+        :value_last_week => 1.5,
+        :value_last_month => 1.5,
+        :user => nil,
+        :article_has_keyword => nil
       ),
       Keyword.create!(
         :name => "Name",
         :article => nil,
-        :article_has_keyword => nil,
-        :value => 1.5,
-        :user => nil
+        :value_present => 1.5,
+        :value_last_week => 1.5,
+        :value_last_month => 1.5,
+        :user => nil,
+        :article_has_keyword => nil
       )
     ])
   end
@@ -24,8 +28,10 @@ RSpec.describe "keywords/index", :type => :view do
     render
     assert_select "tr>td", :text => "Name".to_s, :count => 2
     assert_select "tr>td", :text => nil.to_s, :count => 2
-    assert_select "tr>td", :text => nil.to_s, :count => 2
     assert_select "tr>td", :text => 1.5.to_s, :count => 2
+    assert_select "tr>td", :text => 1.5.to_s, :count => 2
+    assert_select "tr>td", :text => 1.5.to_s, :count => 2
+    assert_select "tr>td", :text => nil.to_s, :count => 2
     assert_select "tr>td", :text => nil.to_s, :count => 2
   end
 end
diff --git a/spec/views/keywords/new.html.erb_spec.rb b/spec/views/keywords/new.html.erb_spec.rb
index 9232f12..499373a 100644
--- a/spec/views/keywords/new.html.erb_spec.rb
+++ b/spec/views/keywords/new.html.erb_spec.rb
@@ -5,9 +5,11 @@ RSpec.describe "keywords/new", :type => :view do
     assign(:keyword, Keyword.new(
       :name => "MyString",
       :article => nil,
-      :article_has_keyword => nil,
-      :value => 1.5,
-      :user => nil
+      :value_present => 1.5,
+      :value_last_week => 1.5,
+      :value_last_month => 1.5,
+      :user => nil,
+      :article_has_keyword => nil
     ))
   end

@@ -20,11 +22,15 @@ RSpec.describe "keywords/new", :type => :view do

       assert_select "input#keyword_article_id[name=?]", "keyword[article_id]"

-      assert_select "input#keyword_article_has_keyword_id[name=?]", "keyword[article_has_keyword_id]"
+      assert_select "input#keyword_value_present[name=?]", "keyword[value_present]"
+
+      assert_select "input#keyword_value_last_week[name=?]", "keyword[value_last_week]"

-      assert_select "input#keyword_value[name=?]", "keyword[value]"
+      assert_select "input#keyword_value_last_month[name=?]", "keyword[value_last_month]"

       assert_select "input#keyword_user_id[name=?]", "keyword[user_id]"
+
+      assert_select "input#keyword_article_has_keyword_id[name=?]", "keyword[article_has_keyword_id]"
     end
   end
 end
diff --git a/spec/views/keywords/show.html.erb_spec.rb b/spec/views/keywords/show.html.erb_spec.rb
index ac5016d..56dfc2d 100644
--- a/spec/views/keywords/show.html.erb_spec.rb
+++ b/spec/views/keywords/show.html.erb_spec.rb
@@ -5,9 +5,11 @@ RSpec.describe "keywords/show", :type => :view do
     @keyword = assign(:keyword, Keyword.create!(
       :name => "Name",
       :article => nil,
-      :article_has_keyword => nil,
-      :value => 1.5,
-      :user => nil
+      :value_present => 1.5,
+      :value_last_week => 1.5,
+      :value_last_month => 1.5,
+      :user => nil,
+      :article_has_keyword => nil
     ))
   end

@@ -15,8 +17,10 @@ RSpec.describe "keywords/show", :type => :view do
     render
     expect(rendered).to match(/Name/)
     expect(rendered).to match(//)
-    expect(rendered).to match(//)
     expect(rendered).to match(/1.5/)
+    expect(rendered).to match(/1.5/)
+    expect(rendered).to match(/1.5/)
+    expect(rendered).to match(//)
     expect(rendered).to match(//)
   end
 end