-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from jeferson-sb/spaced-repetition
feat: spaced repetition
- Loading branch information
Showing
19 changed files
with
324 additions
and
98 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
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class NotificationMailer < ApplicationMailer | ||
default from: 'noreply@flashmemo.com' | ||
|
||
def review_email | ||
@user = params[:user] | ||
@url = params[:url] | ||
mail(to: @user.email, subject: 'Hey, Review time!') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> | ||
</head> | ||
<body> | ||
<h1>Hey <%= @user.username %></h1> | ||
<p> | ||
We bring you these questions to review to <strong>reinforce</strong> your learning! | ||
Just follow <a href=<%= @url %> target="_blank" rel="noopener">this link</a> | ||
</p> | ||
<p>Thanks, have a great day!</p> | ||
</body> | ||
</html> |
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 @@ | ||
Hey <%= @user.username %> | ||
========================== | ||
|
||
We bring you these questions to review to improve your learning! | ||
Just follow this link: <%= @url %> | ||
|
||
Thanks, have a great day! |
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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
env :PATH, ENV['PATH'] | ||
set :environment, :development | ||
set :output, "#{path}/log/cron.log" | ||
|
||
every :day do | ||
rake 'send_review_email:all' | ||
end |
5 changes: 5 additions & 0 deletions
5
api/db/migrate/20240212194401_add_last_attempted_to_answers.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 AddLastAttemptedToAnswers < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :answers, :last_attempted_at, :datetime | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
api/db/migrate/20240212200940_add_interval_level_to_answers.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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddIntervalLevelToAnswers < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :answers, :interval_level, :integer, default: 0 | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
namespace :send_review_email do | ||
desc 'Send review email to answer revision' | ||
task all: :environment do | ||
Revision.find_each(batch_size: 100) do |rev| | ||
answer = rev.exam.answer.last | ||
is_enough_questions = rev.questions.length > 1 | ||
if answer && (is_enough_questions && answer.valid_interval?) | ||
puts "[LOG] #{Time.now}: sending e-mail revision #{rev.id}" | ||
NotificationMailer.with(user: rev.user_id, url: "/api/revisions/#{rev.id}").review_email.deliver_now | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.