Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Commit c73e3c4

Browse files
committed
Mark individual exercises as fetched
When someone fetches the next exercise (whichever it is) either across all their active tracks or in a specific track, we post back to the app so that we can show people their current status. When someone fetches an individual exercise, we weren't posting back. This fixes it for the individual fetch. This does presume that the CLI passes along the API key, which it originally was not doing. That's fixed in exercism/cli#307 and it will be a part of the 2.2.6 release.
1 parent ceb98c8 commit c73e3c4

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/xapi/exercism_io.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.code_for(key)
2727
end
2828

2929
def self.fetch_for(key, language, slug)
30-
post("/api/v1/iterations/#{language}/#{slug}/fetch", key)
30+
post("/api/v1/iterations/#{language}/#{slug}/fetch", key) if !!key
3131
end
3232

3333
def self.conn

v1/routes/exercises.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def homework
3636
# no need to authenticate for this one
3737
problem = config.find(language).find(slug)
3838
problem.validate or halt 404, { error: problem.error }.to_json
39+
begin
40+
Xapi::ExercismIO.fetch_for(params[:key], problem.track_id, problem.slug)
41+
rescue
42+
# don't fail just because we can't track it.
43+
end
3944
pg :problems, locals: { problems: [problem] }
4045
end
4146

0 commit comments

Comments
 (0)