-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create Uphold Report * UpholdReport -> UpholdStatusReport * Tests pass * Apply suggestions from code review Co-Authored-By: Albert Wang <amwang217@gmail.com> * Apply suggestions from code review Co-Authored-By: Albert Wang <amwang217@gmail.com> * Apply suggestions from code review Co-Authored-By: Albert Wang <amwang217@gmail.com> * Rename relevant files from uphold_reports to uphold_status_reports (#2240) * KYC report route fix (#2241) * Fix route to use uphold_status_report
- Loading branch information
Cory McDonald
authored
Sep 19, 2019
1 parent
a95106b
commit f3627df
Showing
11 changed files
with
108 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'csv' | ||
|
||
module Admin | ||
class UpholdStatusReportsController < AdminController | ||
def index | ||
@uphold_status_reports = UpholdStatusReport. | ||
group('(EXTRACT(YEAR FROM created_at))::integer'). | ||
group('(EXTRACT(MONTH FROM created_at))::integer'). | ||
order('2 DESC, 3 DESC').count | ||
end | ||
|
||
def show | ||
date = DateTime.strptime(params[:id], "%Y-%m") | ||
start_date = date.at_beginning_of_month | ||
end_date = date.at_end_of_month | ||
|
||
uphold_status_reports = UpholdStatusReport.where("created_at >= :start AND created_at <= :finish", start: start_date, finish: end_date) | ||
|
||
generated = [] | ||
generated << ["publisher id", "publisher created at", "uphold id", "uphold connected time"].to_csv | ||
|
||
uphold_status_reports.each do |report| | ||
generated << [report.publisher_id, report.publisher.created_at, report.uphold_id, report.created_at].to_csv | ||
end | ||
|
||
send_data generated.join(''), filename: "uphold-#{params[:id]}.csv" | ||
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
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 @@ | ||
class UpholdStatusReport < ApplicationRecord | ||
belongs_to :publisher | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.panel-heading | ||
h4 Uphold Reports | ||
|
||
div | ||
.font-weight-bold How this works: | ||
p Anytime a publisher connects their uphold account we create an entry in our database that logs this. If an uphold id has already been reported we do not create an entry. This data is then aggregated and grouped by month and displayed here. | ||
|
||
table.table | ||
thead | ||
tr | ||
td Period | ||
td Number of users | ||
td | ||
tbody | ||
- @uphold_status_reports.each do |report| | ||
tr | ||
td | ||
- date = report.as_json.first | ||
= Date::MONTHNAMES[date.second] | ||
= " #{date.first}" | ||
td= report.as_json.second | ||
td= link_to("Download", admin_uphold_status_report_path(date.join('-')), class:'btn btn-default') |
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,13 @@ | ||
class CreateUpholdStatusReport < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :uphold_connections, :member_at, :datetime | ||
|
||
create_table :uphold_status_reports, id: :uuid, default: -> { "uuid_generate_v4()"}, force: :cascade do |t| | ||
t.belongs_to :publisher, index: true, type: :uuid | ||
t.uuid :uphold_id, index: true | ||
t.timestamps | ||
end | ||
|
||
add_index :uphold_status_reports, :created_at | ||
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