Skip to content

Commit

Permalink
Merge pull request #38187 from code-dot-org/retrieve-user-model-ids
Browse files Browse the repository at this point in the history
[AiLab] Retrieve user model ids and names from db
  • Loading branch information
Erin007 committed Dec 16, 2020
2 parents aa1b90d + 0cd71db commit 043945b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dashboard/app/controllers/api/v1/ml_models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ def save
name: params["ml_model"]["name"]
)
upload_to_s3(model_id, params["ml_model"].to_json)

render json: "hooray!"
end

# GET api/v1/ml_models/names
# Retrieve the names and ids of a user's trained ML models.
def user_ml_model_names
user_ml_model_data = UserMlModel.where(user_id: current_user.id).map {|user_ml_model| {"id": user_ml_model.model_id, "name": user_ml_model.name}}
render json: user_ml_model_data.to_json
end

# GET api/v1/ml_models/:model_id
# Retrieve a trained ML model from S3
def get_trained_model
Expand Down
1 change: 1 addition & 0 deletions dashboard/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@
get 'peer_review_submissions/report_csv', to: 'peer_review_submissions#report_csv'

post 'ml_models/save', to: 'ml_models#save'
get 'ml_models/names', to: 'ml_models#user_ml_model_names'
get 'ml_models/:model_id', to: 'ml_models#get_trained_model'

resources :teacher_feedbacks, only: [:index, :create] do
Expand Down

0 comments on commit 043945b

Please sign in to comment.