Skip to content

Commit eba5fc2

Browse files
committed
WIP
1 parent aa03ffc commit eba5fc2

File tree

6 files changed

+57
-62
lines changed

6 files changed

+57
-62
lines changed

app/mailers/user_mailer.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ def send_triage(user:, assignment:, repo:, create: false)
7575
mail(to: @user.email, reply_to: "[email protected]", subject: "[CodeTriage] Help triage #{@repo.full_name}")
7676
end
7777

78-
def poke_inactive(user:, repos_by_need_ids:)
78+
def poke_inactive(user:, min_issue_count: , min_subscriber_count: )
7979
return unless set_and_check_user(user)
80-
@most_repo = Repo.order_by_issue_count.first
8180

82-
repo_need_id = repos_by_need_ids.detect { |id| id != @most_repo.id }
83-
@need_repo = Repo.where(id: repo_need_id).first
81+
if @user.favorite_languages.present?
82+
@repos = Repo.where(language: favorite_languages)
83+
else
84+
@repos = Repo
85+
end
8486

85-
@random_repo = Repo.rand.not_in(@most_repo.id, @need_repo.id).first || @most_repo || @need_repo
87+
@repos = @repos
88+
.rand
89+
.where("issues_count >= ?", min_issue_count)
90+
.where("subscribers_count >= ?", min_subscriber_count).first(3)
8691
mail(to: @user.email, reply_to: "[email protected]", subject: "CodeTriage misses you")
8792
end
8893

app/views/user_mailer/poke_inactive.html.erb

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Hello <%= @user.github %>,
2+
3+
You're getting this email because you've signed up for [CodeTriage](<%= root_url %>), but haven't subscribed to any repos yet. Here are some tips for getting started.
4+
5+
### Tips and tricks
6+
7+
- Open source tip: Not sure which repo to select? See the ["I’m stuck getting started"](<%= university_index_url %>) section of the [CodeTriage University](<%= university_index_url %>).
8+
- Tech tip: Learn about [Real-time Database Events in Postgres with pg_eventserv](https://www.crunchydata.com/blog/real-time-database-events-with-pg_eventserv) (via [Postgres Weekly](https://postgresweekly.com/issues/474))
9+
- Tech tip: Learn about [templating in HTML with \<template\>](https://frontendfoc.us/link/129692/web) (via [Frontend focus](https://frontendfoc.us))
10+
- For a comprehensive manual on open source contribution, [check out the "How to Open Source" book](https://howtoopensource.dev/).
11+
12+
### Suggested repos
13+
14+
<% @repos.each do |repo| %>
15+
- **<%= repo.language %>: <%= repo.full_name %>** ([Subscribe](<%= repo_url(repo) %>))
16+
<% end %>
17+
18+
If you don't like any of those [add your own repo](<%= new_repo_url %>) or [browse all repos](<%= root_url %>).
19+
20+
<% if @user.favorite_languages.blank? %>
21+
22+
23+
### Tell us your favorite progrmaming languages
24+
25+
CodeTriage can help you pick a repo. All you have to do is tell us the programming language(s) you most commonly use:
26+
27+
[Select your favorite languages(s)](user_url(@user))
28+
29+
30+
<% end %>
31+
32+
33+
### See you next week
34+
35+
Subscribe to a repo, or you will get this same email next week, maybe with different suggestions. To unsubscribe entirely, [delete your account](<%= user_url(@user) %>), but don't do that, subscribe to a repo and start your open source journey. We believe in you!
36+
37+
--
38+
For open source tips, follow [@HowToOpenSource](https://twitter.com/HowToOpenSource) on Twitter.

app/views/user_mailer/poke_inactive.text.erb

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/tasks/schedule.rake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ namespace :schedule do
6161
task poke_inactive: :environment do
6262
next unless Date.today.tuesday?
6363

64-
repos_by_need_ids = Repo.order_by_need.limit(10).pluck(:id)
64+
65+
perc_90_issues_count = ActiveRecord::Base.connection.select_one("SELECT PERCENTILE_CONT(0.90) WITHIN GROUP(ORDER BY issues_count) FROM repos;")["percentile_cont"]
66+
perc_90_subscriber_count = ActiveRecord::Base.connection.select_one("SELECT PERCENTILE_CONT(0.90) WITHIN GROUP(ORDER BY subscribers_count) FROM repos;")["percentile_cont"]
67+
6568
User.inactive.find_each(batch_size: 100) do |user|
66-
BackgroundInactiveEmailJob.perform_later(user, repos_by_need_ids: repos_by_need_ids)
69+
BackgroundInactiveEmailJob.perform_later(
70+
user,
71+
min_issue_count: perc_90_issues_count,
72+
min_subscriber_count: perc_90_subscriber_count)
6773
end
6874
end
6975

test/mailers/previews/user_preview.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ def _02_send_daily_triage_issues_only
102102

103103
def poke_inactive
104104
user = User.last
105-
repos_by_need_ids = Repo.order_by_need.limit(10).pluck(:id)
106105

107-
::UserMailer.poke_inactive(user: user, repos_by_need_ids: repos_by_need_ids)
106+
::UserMailer.poke_inactive(user: user, min_issue_count: 0, min_subscriber_count: 0)
108107
end
109108

110109
def daily_docs

0 commit comments

Comments
 (0)