Skip to content

Commit

Permalink
Merge pull request #6133 from gabina/data-rearchitecture-sync-with-ma…
Browse files Browse the repository at this point in the history
…ster

[Data rearchitecture] sync with master
  • Loading branch information
gabina authored Jan 17, 2025
2 parents 14ea16d + f75b305 commit 7c89a2e
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 28 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ jobs:
with:
pandoc-version: '2.9.2.1'

- name: install ImageMagick
uses: mfinelli/setup-imagemagick@v6
with:
cache: true

# Cache ImageMagick binaries
- name: Cache Latest ImageMagick
uses: actions/cache@v3
with:
path: /home/runner/bin/magick
key: ${{ runner.os }}-imagemagick-latest
restore-keys: |
${{ runner.os }}-imagemagick-latest
# Update PATH for ImageMagick
- name: Update PATH for ImageMagick
run: echo "/home/runner/bin" >> $GITHUB_PATH

- name: Create symlink for identify and convert
run: |
for cmd in identify convert; do
if ! [ -x "$(command -v $cmd)" ]; then
sudo ln -s $(which magick) /usr/bin/$cmd
fi
done
- name: setup Redis
uses: supercharge/[email protected]

Expand Down Expand Up @@ -87,8 +113,8 @@ jobs:
if: failure()
with:
name: dist-without-markdown
path: tmp/capybara/*.png
path: tmp/screenshots/*.png
if-no-files-found: ignore

- name: Ruby linting
run: bundle exec rubocop
run: bundle exec rubocop
40 changes: 24 additions & 16 deletions app/assets/javascripts/components/course_creator/course_form.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { Link } from 'react-router-dom';
import TextAreaInput from '../common/text_area_input.jsx';
import CreatableInput from '../common/creatable_input.jsx';
Expand All @@ -12,6 +13,7 @@ import selectStyles from '../../styles/select';
import WikiSelect from '../common/wiki_select.jsx';
import AcademicSystem from '../common/academic_system.jsx';
import WIKI_OPTIONS from '../../utils/wiki_options';
import { updateCourse } from '@actions/course_actions.js';

const CourseForm = (props) => {
const handleWikiChange = (wiki) => {
Expand All @@ -31,6 +33,15 @@ const CourseForm = (props) => {
props.updateCourseProps({ wikis });
};

const dispatch = useDispatch();

useEffect(() => {
if (props.course.wikis && !props.course.wikis.length) {
dispatch(updateCourse({ wikis: [{ language: 'en', project: 'wikipedia' }] }));
}
}, []);


let term;
let courseSubject;
let expectedStudents;
Expand Down Expand Up @@ -133,17 +144,11 @@ const CourseForm = (props) => {
);
}



let privacyCheckbox;
let campaign;
let home_wiki;
let multi_wiki;

if (props.course.wikis && !props.course.wikis.length) {
props.course.wikis.push({ language: 'en', project: 'wikipedia' });
}

if (props.defaultCourse !== 'ClassroomProgramCourse') {
home_wiki = (
<div className="form-group home-wiki">
Expand Down Expand Up @@ -181,6 +186,7 @@ const CourseForm = (props) => {
/>
);
}

if (props.course.initial_campaign_title) {
campaign = (
<TextInput
Expand All @@ -189,7 +195,9 @@ const CourseForm = (props) => {
/>
);
}

let backCondition;

if (Features.wikiEd) {
backCondition = props.previousWikiEd;
} else {
Expand All @@ -198,15 +206,15 @@ const CourseForm = (props) => {

let backOrCancelButton;

// Displays "Back" button if the user has clonable courses or is on the P&E dashboard; otherwise shows "Cancel" link.
if (props.hasClonableCourses || props.defaultCourse !== 'ClassroomProgramCourse') {
backOrCancelButton = (
<button onClick={backCondition} className="button dark">{I18n.t('application.back')}</button>
);
} else {
backOrCancelButton = (
<Link className="button" to="/" id="course_cancel">{I18n.t('application.cancel')}</Link>
);
// Displays "Back" button if the user has clonable courses or is on the P&E dashboard; otherwise shows "Cancel" link.
if (props.hasClonableCourses || props.defaultCourse !== 'ClassroomProgramCourse') {
backOrCancelButton = (
<button onClick={backCondition} className="button dark">{I18n.t('application.back')}</button>
);
} else {
backOrCancelButton = (
<Link className="button" to="/" id="course_cancel">{I18n.t('application.cancel')}</Link>
);
}

return (
Expand Down
7 changes: 3 additions & 4 deletions app/services/copy_course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ def copy_tracked_categories_data
end

def maybe_copy_user_data
if @user_data.present? && @user_data != '0'
@users_data = retrieve_users_data
copy_users_data
end
return unless @user_data.present? && @user_data != '0'
@users_data = retrieve_users_data
copy_users_data
end

def copy_users_data
Expand Down
9 changes: 4 additions & 5 deletions app/services/update_course_wiki_timeslices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ def fetch_data(wiki, timeslice_start, timeslice_end)
update_service: self)

# Only for wikidata project, fetch wikidata stats
if wiki.project == 'wikidata' && @revisions.present?
wikidata_revisions = @revisions[wiki][:revisions].reject(&:deleted)
@revisions[wiki][:revisions] =
@wikidata_stats_updater.update_revisions_with_stats(wikidata_revisions)
end
return unless wiki.project == 'wikidata' && @revisions.present?
wikidata_revisions = @revisions[wiki][:revisions].reject(&:deleted)
@revisions[wiki][:revisions] =
@wikidata_stats_updater.update_revisions_with_stats(wikidata_revisions)
# TODO: replace the logic on ArticlesCourses.update_from_course to remove all
# the ArticlesCourses that do not correspond to course revisions.
# That may happen if the course dates changed, so some revisions are no
Expand Down
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def dump_js_coverage
# Settings specified here will take
# precedence over those in config/application.rb.

Paperclip.options[:command_path] = "/usr/bin"

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
Expand Down
2 changes: 1 addition & 1 deletion lib/revision_data_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize(wiki, course, update_service: nil)
# As a side effect, it imports Article records.
def fetch_revision_data_for_course(timeslice_start, timeslice_end)
all_sub_data, scoped_sub_data = get_course_revisions(@course.students, timeslice_start,
timeslice_end)
timeslice_end)
@revisions = []

# Extract all article data from the slice. Outputs a hash with article attrs.
Expand Down

0 comments on commit 7c89a2e

Please sign in to comment.