Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ikiEduDashboard into @fix/mock-flaky-test
  • Loading branch information
Formasitchijoh committed Jan 8, 2025
2 parents 3886f35 + 531960e commit c1f9cd7
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 6 deletions.
6 changes: 6 additions & 0 deletions config/locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Author: Alshamiri1
# Author: Ayatun
# Author: Azouz.anis
# Author: Cigaryno
# Author: Dr. Mohammed
# Author: Eyas
# Author: FShbib
Expand Down Expand Up @@ -1691,4 +1692,9 @@ ar:
assignment_status: مهمة التدريب (%{status})
multi_wiki:
selector_placeholder: ابدأ في كتابة نطاق الويكي
weekday_picker:
aria:
weekday_select: '{{weekday}} اضغط على مفتاح الرجوع للتحديد'
weekday_selected: '{{weekday}} تم ضغط على مفتاح الرجوع لإلغاء التحديد'
weekday_unselected: '{{weekday}} غير محدد'
...
6 changes: 6 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2113,4 +2113,10 @@ fr:
de serveur. Veuillez réessayer plus tard.
tagged_courses:
download_csv: Télécharger en CSV
weekday_picker:
aria:
weekday_select: '{{weekday}} Appuyez sur la touche Entrée pour sélectionner'
weekday_selected: '{{weekday}} sélectionné, Appuyez sur la touche Entrée pour
désélectionner'
weekday_unselected: '{{weekday}} non sélectionné'
...
1 change: 1 addition & 0 deletions config/locales/se.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ se:
label: Ođđa geavaheaddjinamma
uploads:
file_name: Fiilanamma
license: 'Liseansa:'
users:
editors: Geavaheddjiid mearri
first_name: Ovdanamma
Expand Down
2 changes: 2 additions & 0 deletions config/locales/smn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ smn:
download_stats_data: Luođii lovottuvâid
feedback: Macâttâs
home_wiki: Päikkiwiki
loading: Luođiimin…
new_account_email: Šleđgâpostâčujottâs
overview: Päikki
please_log_in: Čáládât siisâ.
Expand Down Expand Up @@ -134,6 +135,7 @@ smn:
label: Uđđâ kevtteenommâ
uploads:
image: Kove
license: 'Liiseens:'
users:
first_name: Ovdânommâ
last_name: Suhânommâ
Expand Down
1 change: 1 addition & 0 deletions config/locales/sms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ sms:
file_name: Teâttõsnõmm
image: Kartt leʼbe snimldõk
label: Ruõkkmõõžž
license: 'Liseʹnss:'
uploaded_by: 'Ruõkkâm:'
users:
contributions: Õõʹnni muttâz
Expand Down
6 changes: 6 additions & 0 deletions config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Author: Wwycheuk
# Author: Xiplus
# Author: 列维劳德
# Author: 張詠涵
# Author: 捍粵者
---
zh-TW:
Expand Down Expand Up @@ -1609,4 +1610,9 @@ zh-TW:
JSONP_request_failed: 從維基百科取得資料的請求已逾時。這可能是由於網路連線速度太慢,或是臨時伺服器問題造成的。請稍後重試。
tagged_courses:
download_csv: 下載 CSV
weekday_picker:
aria:
weekday_select: '{{weekday}},按下返回鍵以選擇'
weekday_selected: '{{weekday}} 已選擇,按下返回鍵以取消選擇'
weekday_unselected: '{{weekday}} 未選擇'
...
7 changes: 7 additions & 0 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ If you are using Linux you may encounter permission error when trying to change
$ sudo chown $USER:$GROUPS -R ./
```
The command will change the owner of all file inside project directory to the `$USER:$GROUPS`

If you encounter the following error when connecting to the database: _"There is an issue connecting with your hostname mysql"_, please run the following command:
```sh
bash ./update_hosts.sh
```
This script automatically resolves the issue by ensuring proper network mapping in your system's ```/etc/hosts``` file, facilitating seamless database connections. It retrieves the IP address of the MySQL Docker container, checks for any existing hostname entries, and updates or removes outdated ones. This process ensures that the hostname ```mysql``` is correctly mapped to the container’s IP address.
This bash script is designed for Linux distributions like Fedora.
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For Windows, the easiest way to get an environment set up is to [use Ubuntu with
## Prerequisite
There are some basic requirements for the script to work:
- git (to clone the repository)
- node version 14 or 16
- node version 14 or newer
- python 3.5 or newer
- ruby 3.1.2
- apt (debian) or homebrew (MacOS)
Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Your system has cmdtest installed, which provides a different program as yarn. U

- **To check if redis is running as a daemon in Linux** `ps aux | grep redis-server`

- Use node v10 or lower to avoid any errors.
- Use node v14 or newer to avoid any errors.
- **For WSL users , if rspec tests are taking too long to run** make sure to fork the repo in the linux file system and not in the windows partition. Use command `pwd` to know the exact path of your repo. If the path starts with `/mnt/`, the repo is in windows partition. Follow the documentation available at link: https://learn.microsoft.com/en-us/windows/wsl/filesystems to know more about storing and moving files in the linux file system.

If you have received error related to dependencies(`sudo apt-get install -y redis-server mariadb-server libmariadb-dev rvm nodejs npm pandoc`), try to install packages one by one and figure out which packages are creating problems.
Expand Down
2 changes: 1 addition & 1 deletion lib/alerts/continued_course_activity_alert_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create_alerts

private

MINIMUM_CHARACTERS_ADDED_AFTER_COURSE_END = 1000
MINIMUM_CHARACTERS_ADDED_AFTER_COURSE_END = 200
def significant_activity_after_course_end?(course)
user_ids = course.students.pluck(:id)
post_course_characters = Revision
Expand Down
2 changes: 1 addition & 1 deletion lib/importers/user_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def self.get_global_id(username)

def self.update_user_from_wiki(user, wiki)
user_data = WikiApi.new(wiki).get_user_info(user.username)
return if user_data['missing']
return if user_data.nil? || user_data['missing']
user.update!(username: user_data['name'],
registered_at: user_data['registration'],
global_id: user_data&.dig('centralids', 'CentralAuth'))
Expand Down
2 changes: 1 addition & 1 deletion lib/wiki_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_user_info(username)
ususers: username,
usprop: 'centralids|registration' }
user_data = mediawiki('query', user_query)
return unless user_data.data['users'].any?
return unless user_data&.data&.dig('users')&.any?
user_data.data['users'][0]
end

Expand Down
12 changes: 12 additions & 0 deletions spec/features/multiwiki_assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
end

it 'creates valid assignments from multiple article titles' do
pending 'Fails in CI caused by Assign all button not found'

VCR.use_cassette 'multiwiki_assignment' do
visit "/courses/#{course.slug}/students/articles"
first('.student-selection .student').click
Expand All @@ -74,6 +76,8 @@
expect(page).to have_css('a[href="https://fr.wikipedia.org/wiki/Anglais"]')
expect(page).to have_css('a[href="https://fr.wikipedia.org/wiki/Terre"]')
end

pass_pending_spec
end

it 'creates a valid assignment from an article and a project and language from tracked Wikis' do
Expand Down Expand Up @@ -108,6 +112,8 @@
end

it 'will create a valid assignment for multilingual wikisource projects' do
pending 'Fails in CI caused by Heyder Cansa content not found'

VCR.use_cassette 'multiwiki_assignment' do
visit "/courses/#{course.slug}/students/articles"
first('.student-selection .student').click
Expand All @@ -128,9 +134,13 @@
expect(link[:href]).to include('wikisource')
end
end

pass_pending_spec
end

it 'will create a valid assignment for multilingual wikimedia incubator projects' do
pending 'Fails in CI caused by Wp/kiu/Hey content not found'

VCR.use_cassette 'multiwiki_assignment' do
visit "/courses/#{course.slug}/students/articles"
first('.student-selection .student').click
Expand All @@ -151,5 +161,7 @@
expect(link[:href]).to include('incubator.wikimedia')
end
end

pass_pending_spec
end
end
11 changes: 10 additions & 1 deletion spec/lib/importers/user_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@

describe '.update_user_from_wiki' do
let(:course) { create(:course) }
let(:enwiki) { Wiki.get_or_create(language: 'en', project: 'wikipedia') }

context 'when get_user_info returns nil' do
it 'returns early without raising an error and does not update the user' do
user = create(:user, username: 'RageSoss')
allow_any_instance_of(WikiApi).to receive(:get_user_info).and_return(nil)
expect(user).not_to receive(:update!)
expect { described_class.update_user_from_wiki(user, enwiki) }.not_to raise_error
end
end

it 'cleans up records when there are collisions' do
VCR.use_cassette 'user/new_from_renamed_user' do
Expand All @@ -197,7 +207,6 @@
it 'sets the registration date from English Wikipedia' do
VCR.use_cassette 'user/enwiki_only_account' do
user = create(:user, username: 'Brady2421')
enwiki = Wiki.get_or_create(language: 'en', project: 'wikipedia')
described_class.update_user_from_wiki(user, enwiki)
expect(user.registered_at).not_to be_nil
end
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/wiki_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ class UnexpectedError < StandardError; end
end
end

describe '#get_user_info' do
let(:wiki) { Wiki.new(language: 'en', project: 'wikipedia') }

context 'when mediawiki query returns nil' do
it 'returns early without raising an error' do
allow_any_instance_of(described_class).to receive(:mediawiki).and_return(nil)
expect { described_class.new.get_user_info('Ragesoss') }.not_to raise_error
expect(described_class.new.get_user_info('Ragesoss')).to be_nil
end
end
end

describe '#redirect?' do
let(:wiki) { Wiki.new(language: 'en', project: 'wikipedia') }
let(:subject) { described_class.new(wiki).redirect?(title) }
Expand Down
41 changes: 41 additions & 0 deletions update_hosts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Get the MySQL container ID
MYSQL_CONTAINER_ID=$(docker ps --format '{{.ID}} {{.Names}}' | grep 'wikiedudashboard-mysql-1' | awk '{print $1}')

echo $MYSQL_CONTAINER_ID

# Fetch the IP address of the MySQL container
MYSQL_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$MYSQL_CONTAINER_ID")

# Check if we successfully fetched the IP address
if [ -z "$MYSQL_IP" ]; then
echo "Failed to retrieve the MySQL container IP address. Please ensure the Docker containers are running by executing 'docker compose up -d'."
if grep -q "$MYSQL_IP mysql" /etc/hosts; then
sudo sed -i '/[[:space:]]mysql$/d' /etc/hosts
echo "MySQL entry removed from /etc/hosts."
fi

exit 1
fi

# Print the IP address
echo "MySQL IP address: $MYSQL_IP"

# Backup /etc/hosts file
sudo cp /etc/hosts /etc/hosts.bak

# Add MySQL container IP to /etc/hosts
if grep -q "$MYSQL_IP mysql" /etc/hosts; then
echo "MySQL entry already exists in /etc/hosts."
# Remove existing MySQL entry from /etc/hosts (if it exists)
sudo sed -i '/[[:space:]]mysql$/d' /etc/hosts
echo "Removed old MySQL entry from /etc/hosts."
fi

# Add new MySQL container IP address to /etc/hosts
echo "Adding MySQL container IP address to /etc/hosts"
echo "$MYSQL_IP mysql" | sudo tee -a /etc/hosts > /dev/null

# Print success message
echo "MySQL IP address has been added to /etc/hosts."

0 comments on commit c1f9cd7

Please sign in to comment.