-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data to csv #1900
Merged
Merged
Data to csv #1900
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
73fd907
Data Export To CSV for user : backend apis
7b9d389
Merge branch 'main' of github.com:ifmeorg/ifme into main
e7b8fe5
rubocop
28d1c90
Merge branch 'main' of github.com:ifmeorg/ifme into data_to_csv
3c0195b
Delete reports.scss
akp2603 f88ab4a
changed variable name
68034c4
Merge branch 'data_to_csv' of github.com:ifmeorg/ifme into data_to_csv
aebe22b
request spec added
38cd98b
Delete delete_stale_data_worker_spec.rb
akp2603 e3546db
Delete process_data_request_worker_spec.rb
akp2603 12c1a64
Delete reports_helper_spec.rb
akp2603 1967ff8
data request model specs added
ac9fdea
Merge branch 'data_to_csv' of github.com:ifmeorg/ifme into data_to_csv
aa369ed
rubocop fixes
9b2fa1f
refactoring
47b0af0
refactoring
79085ff
Delete delete_stale_data_worker_spec.rb
akp2603 27a6b7d
Delete process_data_request_worker_spec.rb
akp2603 cbf22e1
added test.example.env
342e0d3
Merge branch 'data_to_csv' of github.com:ifmeorg/ifme into data_to_csv
9e04274
Setup Redis in Circle CI config
julianguyen b1502a6
Update config.yml
akp2603 ba3c682
review changes
31f18b2
Merge branch 'data_to_csv' of github.com:ifmeorg/ifme into data_to_csv
f92ba10
Merge branch 'main' of github.com:ifmeorg/ifme into data_to_csv
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
// Place all the styles related to the Users::Reports controller here. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's delete this file since it's unused! |
||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,25 @@ | ||
class Users::ReportsController < ApplicationController | ||
|
||
before_action :authenticate_user! | ||
include Users::ReportsHelper | ||
|
||
def submit_request | ||
status, response = submit_request_helper(current_user) | ||
render json: response, status: status | ||
end | ||
|
||
def fetch_request_status | ||
status, response = fetch_request_status_helper(current_user, params[:request_id]) | ||
render json: response, status: status | ||
end | ||
|
||
def download_data | ||
status, response = download_data_helper(current_user, params[:request_id]) | ||
if status != 200 | ||
render json: response, status: status | ||
else | ||
send_file(response, status: 200) | ||
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Users::ReportsHelper | ||
|
||
def submit_request_helper(user) | ||
begin | ||
return 200, {request_id: user.generate_data_request()} | ||
rescue => e | ||
return 422, {error: e.message} | ||
end | ||
end | ||
|
||
def fetch_request_status_helper(user, request_id) | ||
return 400, {error: "Request id can be blank."} if request_id.blank? | ||
data_request = user.data_requests.find_by(request_id: request_id) | ||
return 404, {error: "No such request exists for current user."} if data_request.blank? | ||
return 200, {current_status: data_request.status_id} | ||
end | ||
|
||
def download_data_helper(user, request_id) | ||
return 400, {error: "Request id can be blank."} if request_id.blank? | ||
data_request = user.data_requests.find_by(request_id: request_id, status_id: Users::DataRequest::STATUS[:success]) | ||
return 404, {error: "Requested csv not found."} if (data_request.blank? || !File.exist?("#{data_request.file_path}")) | ||
return 200, data_request.file_path | ||
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding comments but I don't think they're absolutely necessary!