Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/domain/ptime/assign_employee_ids.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ def map_employees(should_map)
@mapped_people_count = 0

@provider_employees.each do |ptime_employee|
email = ptime_employee[:attributes][:email]
employee_attributes = ptime_employee[:attributes]
email = employee_attributes[:email]
matched_person = Person.where(ptime_employee_id: nil, ptime_data_provider: nil)
.find_by(email:)

is_employed = ptime_employee[:attributes][:is_employed]
is_employed = employee_is_or_will_be_employed?(employee_attributes)
next record_unmatched_entry(ptime_employee) unless matched_person && is_employed

@mapped_people_count += 1
Expand Down
4 changes: 2 additions & 2 deletions app/domain/ptime/people_employees.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def update_people_data(is_manual_sync: false)
def update_all_people
fetch_data_of_ptime_employees_by_provider.each do |provider, provider_employees|
active_employees, inactive_employees = provider_employees.partition do |ptime_employee|
ptime_employee.dig(:attributes, :is_employed)
employee_is_or_will_be_employed?(ptime_employee[:attributes])
end
@provider = provider
@update_failed_names[provider] = []
Expand Down Expand Up @@ -82,7 +82,7 @@ def update_directly_mappable_attributes
end

def update_indirectly_mappable_attributes
is_employed = @ptime_employee_attributes[:is_employed]
is_employed = employee_is_or_will_be_employed?(@ptime_employee_attributes)
@person.company = is_employed ? @employed_company : @unemployed_company
@person.department = Department.find_or_create_by!(
name: @ptime_employee_attributes[:department_name]
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/ptime_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ def employee_full_name(ptime_employee)
"#{ptime_employee[:firstname]} #{ptime_employee[:lastname]}"
end

def employee_is_or_will_be_employed?(ptime_employee_attributes)
ptime_employee_attributes[:is_employed] ||
ptime_employee_attributes[:employed_within_three_months]
end

def ptime_providers
@provider_configs = ENV.filter { |env_var| env_var.start_with?('PTIME_PROVIDER') }
.sort
Expand Down
6 changes: 3 additions & 3 deletions config/locales/de-CH.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,20 @@ de-CH:
index:
delete_inactive_profiles: Inaktivi Profiu löschä
unify_skills: Skills vereinä
update_people_manually: Persone manuell aktualisiere
update_people_manually: Members manuell aktualisiere
reminder_mail: Aktivier Erinnerigs E-Mails für d Firma.
manual_ptime_sync:
manual_sync:
failed_people_updates: Bi dr Aktualisierig vo %{names} isch öppis schiefgloffe. Versuechs nomau und überprüef auefaus d Date im PuzzleTime.
fetching_data_failed: Öppis ische bim fetche vo de Date usem PuzzleTime schief gloffe. Bitte probiers nomau und kontaktier auefaus dr Support.
names_by_provider: "%{names} vom Provider %{provider}"
people_updated: D Datä vo aunä Personä si erfolgriich aktualisiert wordä
people_updated: D Datä vo aunä Members si erfolgriich aktualisiert wordä
unified_skills:
create:
success: Skill %{skill1} isch erfolgriich mit Skill %{skill2} zum neuä Skill %{new_skill} vereint wordä
admin/manual_ptime_sync:
index:
description: We dä wunderschön Chnopf drückt wird, de wärde d Date vo aune Persone mit de Date usem PuzzleTime aktualisiert. Ds cha einigi Sekunde duure.
description: We dä wunderschön Chnopf drückt wird, de wärde d Date vo aune Members mit de Date usem PuzzleTime aktualisiert. Ds cha einigi Sekunde duure.
admin/people_management:
index:
ex_members_title: Di folgendä Profiu si aus 'Ex-Mitarbeiter' markiert
Expand Down
6 changes: 3 additions & 3 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,20 @@ de:
index:
delete_inactive_profiles: Inaktive Profile löschen
unify_skills: Skills vereinen
update_people_manually: Personen manuell aktualisieren
update_people_manually: Members manuell aktualisieren
reminder_mail: Aktiviere Erinnerungs E-Mails für die Firma.
manual_ptime_sync:
manual_sync:
failed_people_updates: Bei der Aktualisierung von %{names} ist etwas schiefgelaufen. Versuche es erneut und überprüfe allenfalls die Daten im PuzzleTime.
fetching_data_failed: Etwas ist schiefgelaufen, als versucht wurde die Daten aus dem PuzzleTime zu fetchen. Bitte versuche es erneut und kontaktiere allenfalls den Support.
names_by_provider: "%{names} vom Provider %{provider}"
people_updated: Die Daten aller Personen wurden erfolgreich aktualisiert
people_updated: Die Daten aller Members wurden erfolgreich aktualisiert
unified_skills:
create:
success: Skill %{skill1} wurde erfolgreich mit Skill %{skill2} zum neuen Skill %{new_skill} vereint
admin/manual_ptime_sync:
index:
description: Wenn dieser wunderschöne Knopf gedrückt wird, dann werden die Daten aller Personen mit den Daten aus dem PuzzleTime aktualisiert. Dies kann einige Sekunden dauern.
description: Wenn dieser wunderschöne Knopf gedrückt wird, dann werden die Daten aller Members mit den Daten aus dem PuzzleTime aktualisiert. Dies kann einige Sekunden dauern.
admin/people_management:
index:
ex_members_title: Die folgenden Profile sind als Ex-Mitarbeiter markiert
Expand Down
6 changes: 3 additions & 3 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ fr:
index:
delete_inactive_profiles: Supprimer les profils inactifs
unify_skills: Unifier les compétences
update_people_manually: Mise à jour manuelle des personnes
update_people_manually: Mettre à jour les membres manuellement
reminder_mail: Activez les e-mails de rappel pour votre entreprise.
manual_ptime_sync:
manual_sync:
failed_people_updates: Une erreur s'est produite lors de la mise à jour de %{names}. Veuillez réessayer et, si nécessaire, vérifier les données dans PuzzleTime.
fetching_data_failed: Une erreur s'est produite lors de la récupération des données de PuzzleTime. Veuillez réessayer et contacter le support si nécessaire.
names_by_provider: "%{names} du fournisseur %{provider}"
people_updated: Les données de toutes les personnes ont été mises à jour avec succès
people_updated: Les données de tous les membres ont été mises à jour avec succès
unified_skills:
create:
success: La compétence %{skill1} a été unifiée avec succès avec la compétence %{skill2} en la nouvelle compétence %{new_skill}
admin/manual_ptime_sync:
index:
description: Lorsque vous appuyez sur ce magnifique bouton, les données de toutes les personnes sont mises à jour avec celles de PuzzleTime. Ceci peut prendre quelques secondes.
description: Lorsque vous appuyez sur ce magnifique bouton, les données de tous les membres sont mises à jour avec les données provenant de PuzzleTime. Cela peut prendre quelques secondes.
admin/people_management:
index:
ex_members_title: Les profils suivants sont marqués comme anciens employés
Expand Down
6 changes: 3 additions & 3 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ it:
index:
delete_inactive_profiles: Elimina profili inattivi
unify_skills: Unire le competenze
update_people_manually: Aggiornare le persone manualmente
update_people_manually: Aggiornare manualmente i membri
reminder_mail: Attiva le email di promemoria per la tua azienda.
manual_ptime_sync:
manual_sync:
failed_people_updates: Si è verificato un errore durante l'aggiornamento di %{names}. Si prega di riprovare e, se necessario, controllare i dati in PuzzleTime.
fetching_data_failed: Si è verificato un errore durante il recupero dei dati da PuzzleTime. Si prega di riprovare e contattare il supporto se necessario.
names_by_provider: "%{names} del fornitore %{provider}"
people_updated: I dati di tutte le persone sono stati aggiornati con successo
people_updated: I dati di tutti i membri sono stati aggiornati con successo
unified_skills:
create:
success: La competenza %{skill1} è stata unificata con successo con la competenza %{skill2} nella nuova competenza %{new_skill}
admin/manual_ptime_sync:
index:
description: Quando questo bellissimo pulsante viene premuto, i dati di tutte le persone verranno aggiornati con i dati di PuzzleTime. Questo potrebbe richiedere alcuni secondi.
description: Quando questo bellissimo pulsante viene premuto, i dati di tutti i membri verranno aggiornati con i dati di PuzzleTime. Questo potrebbe richiedere alcuni secondi.
admin/people_management:
index:
ex_members_title: I seguenti profili sono contrassegnati come ex dipendenti
Expand Down
6 changes: 3 additions & 3 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ ja:
index:
delete_inactive_profiles: 無効なプロファイルを削除
unify_skills: スキル統合
update_people_manually: ユーザーを手動で更新
update_people_manually: メンバーを手動で更新
reminder_mail: 会社のリマインダーメールを有効にする
manual_ptime_sync:
manual_sync:
failed_people_updates: "%{names}の更新に失敗しました。再度お試しください。また、念のためPuzzleTime内のデータもご確認ください。"
fetching_data_failed: PuzzleTimeからデータを取得しようとした際に問題が発生しました。お手数ですが再度お試しいただき、それでも解決しない場合はサポートにご連絡ください。
names_by_provider: "%{provider}の%{names}"
people_updated: すべてのユーザーのデータの更新に成功しました
people_updated: すべてのメンバーのデータが正常に更新されました
unified_skills:
create:
success: スキル %{skill1} はスキル %{skill2} と統合され、新しいスキル %{new_skill} が作成されました
admin/manual_ptime_sync:
index:
description: この素敵なボタンが押されると、すべてのユーザーのデータがPuzzleTimeのデータをもとに更新されます。この処理には数秒かかる場合があります
description: このボタンを押すと、すべてのメンバーのデータが「PuzzleTime」のデータで更新されます。処理には数秒かかる場合があります
admin/people_management:
index:
ex_members_title: 以下のプロファイルは元従業員としてマークされています
Expand Down
2 changes: 1 addition & 1 deletion spec/domain/ptime/people_employees_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
end

def check_person_data_updated(person, employee_data)
is_employed = employee_data[:is_employed]
is_employed = employee_data[:is_employed] || employee_data[:employed_within_three_months]

expect(person.name.eql?(employee_full_name(employee_data))).to eql(is_employed)
expect(person.email.eql?(employee_data[:email])).to eql(is_employed)
Expand Down
8 changes: 4 additions & 4 deletions spec/features/manual_ptime_sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
end

it 'should successfully run manual ptime sync method and show flash' do
click_button('Personen manuell aktualisieren')
expect(page).to have_content('Die Daten aller Personen wurden erfolgreich aktualisiert')
click_button('Members manuell aktualisieren')
expect(page).to have_content('Die Daten aller Members wurden erfolgreich aktualisiert')

longmax_attributes = ptime_company_employee_data.first[:attributes]
bob_attributes = ptime_partner_employee_data.first[:attributes]
Expand All @@ -27,7 +27,7 @@
it 'should show flash when employees have unexpected values' do
longmax_attributes, bob_attributes = stub_invalid_ptime_response

click_button('Personen manuell aktualisieren')
click_button('Members manuell aktualisieren')
expect(page).to have_content("Bei der Aktualisierung von #{employee_full_name(longmax_attributes)} vom Provider Firma und #{employee_full_name(bob_attributes)}
vom Provider Partner ist etwas schiefgelaufen. Versuche es erneut und überprüfe allenfalls die Daten im PuzzleTime.".squish)

Expand All @@ -37,7 +37,7 @@
it 'should show flash when something goes wrong while fetching data in client' do
stub_ptime_request(*ptime_company_request_data.values, ptime_company_employee_data.to_json, "employees?per_page=1000", 404)

click_button('Personen manuell aktualisieren')
click_button('Members manuell aktualisieren')
expect(page).to have_content('Etwas ist schiefgelaufen, als versucht wurde die Daten aus dem PuzzleTime zu fetchen. Bitte versuche es erneut und kontaktiere allenfalls den Support.')
end
end
5 changes: 4 additions & 1 deletion spec/fixtures/files/json/all_ptime_employees_company.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"city" : "Bern",
"birthday" : "1990-03-10",
"is_employed" : true,
"employed_within_three_months" : false,
"department_shortname" : "UX",
"department_name" : "/ux",
"employment_roles" : [
Expand Down Expand Up @@ -43,7 +44,8 @@
"graduation" : "MSc in writing",
"city" : "Genf",
"birthday" : "2001-01-05",
"is_employed" : true,
"is_employed" : false,
"employed_within_three_months" : true,
"department_shortname" : "D3",
"department_name" : "/dev/tre",
"employment_roles" : [
Expand Down Expand Up @@ -74,6 +76,7 @@
"city" : "Thun",
"birthday" : "1980-10-25",
"is_employed" : false,
"employed_within_three_months" : false,
"department_shortname" : "UX",
"department_name" : "/ux",
"employment_roles" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"city" : "Zürich",
"birthday" : "1990-03-10",
"is_employed" : true,
"employed_within_three_months" : false,
"department_shortname" : "UX",
"department_name" : "/ux",
"employment_roles" : [
Expand Down