diff --git a/app/controllers/concerns/repository/languages_percentagable.rb b/app/controllers/concerns/repository/languages_percentagable.rb index dc6abcb9c..53876327a 100644 --- a/app/controllers/concerns/repository/languages_percentagable.rb +++ b/app/controllers/concerns/repository/languages_percentagable.rb @@ -5,7 +5,16 @@ module Repository::LanguagesPercentagable result = Gitea::Repository::Languages::ListService.call(@owner.login, @repository.identifier, current_user&.gitea_token) - result[:status] === :success ? hash_transform_precentagable(result[:body]) : nil + @transform_language = result[:status] === :success ? hash_transform_precentagable(result[:body]) : nil + update_project_language(@transform_language) unless @transform_language.nil? + @transform_language + end + + def update_project_language(language) + db_language = ProjectLanguage.find_or_create_by!(name: language.keys.first.downcase.upcase_first) + @project.update_column(:project_language_id, db_language.id) + rescue + return end # hash eq:{"JavaScript": 301681522,"Ruby": 1444004,"Roff": 578781}