diff --git a/app/models/v_contact.rb b/app/models/v_contact.rb index 916591a..5e8b8ba 100644 --- a/app/models/v_contact.rb +++ b/app/models/v_contact.rb @@ -41,6 +41,9 @@ class VContact < ApplicationRecord vc.save end + to_delete = VContact.where("(last_volume_at is NULL and datecreation < ?) or (last_volume_at < ?)", (Date.today-5.year), (Date.today-5.year)) + VolumePeriodique.where(:codemanaginn => to_delete.map{|a| a.codemanaginn}).destroy_all + to_delete.destroy_all if @gen_past_time diff --git a/app/views/admin/societes/index.html.haml b/app/views/admin/societes/index.html.haml index 4c6ef08..f509594 100644 --- a/app/views/admin/societes/index.html.haml +++ b/app/views/admin/societes/index.html.haml @@ -5,7 +5,11 @@ .qi_pannel.qi_plain.padding + =link_to "Importer les données dispos à ce jour", import_admin_volume_periodiques_path, :remote => true, :onclick => "$(this).hide();$(this).next('#import').html('Import en cours... Ne pas fermer la page');", :data => {:confirm => "Voulez-vous vraiment mettre à jour les données ? L'opération prendra du temps et tous les stats actuels seront effacés..."} + #import + %br + %br =VContact.update_caches diff --git a/app/views/admin/volume_periodiques/import.js.erb b/app/views/admin/volume_periodiques/import.js.erb new file mode 100644 index 0000000..91b7349 --- /dev/null +++ b/app/views/admin/volume_periodiques/import.js.erb @@ -0,0 +1 @@ +$("#import").html("L'import est terminé, vous pouvez cliquer sur ce lien pour mettre à jour les données (l'opétation peut prendre du temps) : Traiter les données") \ No newline at end of file