Skip to content

Commit

Permalink
Remove features for generating CSVs of course/campaign revisions
Browse files Browse the repository at this point in the history
This is necessary as part of the project to deprecate the Revisions table.
  • Loading branch information
ragesoss committed Dec 17, 2024
1 parent f951240 commit 998d4af
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const CampaignStatsDownloadModal = ({ campaign_slug }) => {

const courseDataLink = `/campaigns/${campaign_slug}/courses.csv`;
const articlesEditedLink = `/campaigns/${campaign_slug}/articles_csv.csv`;
const RevisionsLink = `/campaigns/${campaign_slug}/revisions_csv.csv`;
const editorsLink = `/campaigns/${campaign_slug}/students.csv`;
const editorsByCourseLink = `/campaigns/${campaign_slug}/students.csv?course=true`;
const instructorsLink = `/campaigns/${campaign_slug}/instructors.csv?course=true`;
Expand All @@ -32,11 +31,6 @@ const CampaignStatsDownloadModal = ({ campaign_slug }) => {
{I18n.t('campaign.data_articles_info')}
</p>
<hr />
<p>
<a href={RevisionsLink} className="button right">{I18n.t('campaign.data_revisions')}</a>
{I18n.t('campaign.data_revisions_info')}
</p>
<hr />
<p>
<a href={editorsLink} className="button right">{I18n.t('campaign.data_editor_usernames')}</a>
{I18n.t('campaign.data_editor_usernames_info')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const CourseStatsDownloadModal = ({ course }) => {
const uploadsCsvLink = `/course_uploads_csv?course=${course.slug}`;
const studentsCsvLink = `/course_students_csv?course=${course.slug}`;
const articlesCsvLink = `/course_articles_csv?course=${course.slug}`;
const revisionsCsvLink = `/course_revisions_csv?course=${course.slug}`;
const wikidataCsvLink = `/course_wikidata_csv?course=${course.slug}`;

let wikidataLink;
Expand Down Expand Up @@ -61,10 +60,6 @@ const CourseStatsDownloadModal = ({ course }) => {
{I18n.t('courses.data_articles_info')}
</p>
<hr />
<p>
<a href={revisionsCsvLink} className="button right">{I18n.t('courses.data_revisions')}</a>
{I18n.t('courses.data_revisions_info')}
</p>
{wikidataLink}
</div>
);
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/analytics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
require_dependency "#{Rails.root}/lib/analytics/course_uploads_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_students_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_articles_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_revisions_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_wikidata_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/campaign_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/ungreeted_list"
Expand All @@ -18,7 +17,7 @@ class AnalyticsController < ApplicationController
include CourseHelper
before_action :require_signed_in, only: :ungreeted
before_action :set_course, only: %i[course_csv course_uploads_csv
course_students_csv course_articles_csv course_revisions_csv
course_students_csv course_articles_csv
course_wikidata_csv]

########################
Expand Down Expand Up @@ -76,11 +75,6 @@ def course_articles_csv
filename: "#{@course.slug}-articles-#{Time.zone.today}.csv"
end

def course_revisions_csv
send_data CourseRevisionsCsvBuilder.new(@course).generate_csv,
filename: "#{@course.slug}-revisions-#{Time.zone.today}.csv"
end

def course_wikidata_csv
send_data CourseWikidataCsvBuilder.new(@course).generate_csv,
filename: "#{@course.slug}-wikidata-#{Time.zone.today}.csv"
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
get 'course_students_csv' => 'analytics#course_students_csv'
get 'course_articles_csv' => 'analytics#course_articles_csv'
get 'tagged_courses_csv/:tag' => 'analytics#tagged_courses_csv'
get 'course_revisions_csv' => 'analytics#course_revisions_csv'
get 'course_wikidata_csv' => 'analytics#course_wikidata_csv'
get 'all_courses_csv' => 'analytics#all_courses_csv'
get 'all_courses' => 'analytics#all_courses'
Expand Down
13 changes: 0 additions & 13 deletions lib/analytics/campaign_csv_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'csv'
require_dependency "#{Rails.root}/lib/analytics/course_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_articles_csv_builder"
require_dependency "#{Rails.root}/lib/analytics/course_revisions_csv_builder"
require_dependency "#{Rails.root}/app/workers/campaign_csv_worker"
require "#{Rails.root}/lib/analytics/course_wikidata_csv_builder"

Expand Down Expand Up @@ -33,18 +32,6 @@ def articles_to_csv
CSV.generate { |csv| csv_data.each { |line| csv << line } }
end

def revisions_to_csv
csv_data = [CourseRevisionsCsvBuilder::CSV_HEADERS + ['course_slug']]
@campaign.courses.find_each do |course|
CourseRevisionsCsvBuilder.new(course).revisions_rows.each do |row|
row_with_slug = row + [course.slug]
csv_data << row_with_slug
end
end

CSV.generate { |csv| csv_data.each { |line| csv << line } }
end

def wikidata_to_csv
csv_data = [CourseWikidataCsvBuilder::CSV_HEADERS]
courses = @campaign.courses
Expand Down
105 changes: 0 additions & 105 deletions lib/analytics/course_revisions_csv_builder.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/controllers/analytics_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@
end
end

describe '#course_revisions_csv' do
let(:course) { create(:course, slug: 'foo/bar_(baz)') }

it 'returns a CSV' do
get '/course_revisions_csv', params: { course: course.slug }
expect(response.body).to include('references_added')
end
end

describe '#course_wikidata_csv' do
let(:wikidata) { Wiki.get_or_create(language: nil, project: 'wikidata') }
let(:course) { create(:course, slug: 'foo/bar_(baz)', home_wiki: wikidata) }
Expand Down
11 changes: 0 additions & 11 deletions spec/controllers/campaigns_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,6 @@
expect(csv).to include(article.title)
end

it 'return a csv of revision data' do
expect(CsvCleanupWorker).to receive(:perform_at)
get "/campaigns/#{campaign.slug}/revisions_csv", params: request_params
get "/campaigns/#{campaign.slug}/revisions_csv", params: request_params
follow_redirect!
csv = response.body.force_encoding('utf-8')
expect(csv).to include(course.slug)
expect(csv).to include(article.title)
expect(csv).to include('references_added')
end

it 'returns a csv of wikidata' do
expect(CsvCleanupWorker).to receive(:perform_at)
get "/campaigns/#{campaign.slug}/wikidata.csv"
Expand Down
32 changes: 0 additions & 32 deletions spec/lib/analytics/course_revisions_csv_builder_spec.rb

This file was deleted.

0 comments on commit 998d4af

Please sign in to comment.