-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now tracking doc clicks Populate & Send doc tasks
- Loading branch information
Showing
13 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class SubscribeUserToDocs < ActiveJob::Base | ||
queue_as :default | ||
|
||
def perform(id) | ||
User.find(id).subscribe_docs! | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,14 @@ def send_daily_triage(options = {}) | |
mail(to: @user.email, reply_to: "[email protected]", subject: subject) | ||
end | ||
|
||
def daily_docs(options = {}) | ||
@user = options[:user] | ||
@write_docs = options[:write_docs] | ||
@read_docs = options[:read_docs] | ||
count = (@write_docs.try(:count) || 0) + (@read_docs.try(:count) || 0) | ||
subject = "Check out #{count} Open Source #{"Doc".pluralize(count)}" | ||
mail(to: @user.email, subject: subject) | ||
end | ||
|
||
def send_triage(options = {}) | ||
raise "no assignment" unless assignment = options[:assignment] | ||
|
@@ -85,6 +93,18 @@ def poke_inactive | |
user = User.last | ||
::UserMailer.poke_inactive(user) | ||
end | ||
|
||
def daily_docs | ||
user = User.last | ||
|
||
write_docs = DocMethod.order("RANDOM()").missing_docs.first(rand(0..8)) | ||
read_docs = DocMethod.order("RANDOM()").with_docs.first(rand(0..8)) | ||
|
||
write_docs = DocMethod.order("RANDOM()").first(rand(0..8)) if write_docs.blank? | ||
read_docs = DocMethod.order("RANDOM()").first(rand(0..8)) if read_docs.blank? | ||
|
||
::UserMailer.daily_docs(user: user, write_docs: write_docs, read_docs: read_docs) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
class DocAssignment < ActiveRecord::Base | ||
belongs_to :repo_subscription | ||
has_one :doc_method | ||
has_one :doc_class | ||
belongs_to :doc_method | ||
belongs_to :doc_class | ||
|
||
delegate :user, to: :repo_subscription | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Hi @<%= @user.github %>, | ||
|
||
<% if @write_docs.present? %> | ||
## Write Docs | ||
|
||
<% @write_docs.sort_by {|d| d.repo.full_name }.each do |doc| %> | ||
**<%= doc.repo.full_name %>** ([source](<%= doc.to_github %>)): [<%= doc.path %>](<%= doc_method_url doc %>) | ||
|
||
<% end %> | ||
<% end %> | ||
<% if @read_docs.present? %> | ||
|
||
## Read Docs | ||
|
||
<% @read_docs.sort_by {|d| d.repo.full_name }.each do |doc| %> | ||
**<%= doc.repo.full_name %>** ([source](<%= doc.to_github %>)): [<%= doc.path %>](<%= doc_method_url doc %>) | ||
|
||
<%= doc_method_click_url(doc.id, @user.id) %> | ||
<%= doc_source_click_url(doc.id, @user.id) %> | ||
|
||
<pre> | ||
<%= doc.doc_comments.first.try(:comment) %> | ||
</pre> | ||
|
||
<% end %> | ||
<% end %> | ||
|
||
-- | ||
|
||
Go forth and make the world a better place | ||
|
||
[@schneems](http://twitter.com/schneems) | ||
|
||
[Help doctor more docs at docsdoctor.org](<%= root_url%>) | ||
|
||
[Delete Account](<%= token_delete_user_url(@user.account_delete_token) %>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddClickToDocAssignments < ActiveRecord::Migration[5.0] | ||
def change | ||
add_column :doc_assignments, :clicked, :boolean, default: false | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20160404173429_remove_user_from_doc_assignments.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveUserFromDocAssignments < ActiveRecord::Migration[5.0] | ||
def change | ||
remove_column :doc_assignments, :user_id | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters