Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete tickets via admin interface as job #214

Closed
MDXDave opened this issue Oct 19, 2016 · 28 comments
Closed

Delete tickets via admin interface as job #214

MDXDave opened this issue Oct 19, 2016 · 28 comments
Assignees

Comments

@MDXDave
Copy link

MDXDave commented Oct 19, 2016

Please make it possible to delete tickets and not just close them. 馃樃

@MDXDave MDXDave changed the title Delete Ticket Delete tickets Oct 19, 2016
@thorsteneckel
Copy link
Contributor

Hi @MDXDave - since Zammad is revision-proof this is not an option.

@MDXDave
Copy link
Author

MDXDave commented Oct 19, 2016

I understand your objection, but at least admins should have the possibility to delete tickets.

@thorsteneckel
Copy link
Contributor

As an admin you can use the rails c command on the command line. From there on you can go and do whatever possibilities rails is giving you. Tickets can get deleted via Ticket.find(*id*).destroy. Hope that helps? We do not recommend that.

@MDXDave
Copy link
Author

MDXDave commented Oct 19, 2016

I know that this is possible with rails, but it would be easier to delete tickets within Zammad. 馃憤

@monotek
Copy link
Member

monotek commented Oct 20, 2016

At least scheduler should be able to do it.

@monotek monotek reopened this Oct 20, 2016
@martinseener
Copy link

I think @thorsteneckel decision is right. You should be able to audit old tickets after years so deletion shouldn't be an option at least in the UI. For testing zammad (even a production setup) you should be fine using the rails console which is not hard as well!

@monotek
Copy link
Member

monotek commented Oct 20, 2016

I use this function in OTRS to delete spam tickets after 30 days in our spam queue. Sure, one could do this from the command line but its not so comfortable like to do it from the scheduler.

@thorsteneckel
Copy link
Contributor

I see your point! We will implement it in the near future. Maybe something like https://github.com/rubysherpas/paranoia is useful in this context.

@jhf2442
Copy link

jhf2442 commented Nov 6, 2016

It's not only about hiding the tickets,it's also about removing the unnecessary stuff from the DB. Currently our spam to ham mail ratio is pretty high, but we detect most of the messages with spamassassin. Nevertheless, email filtering happens after downloading the mails from the POP3, so the tickets have already been created the database and the disk space allocated (speaking of OTRS)
One solution could be to store a reference to the ticket, and replace the content by the information that the ticket has been deleted. So in case of an audit you can prove that the ticket was created, but no longer exists ?

@jacotec
Copy link

jacotec commented Nov 9, 2016

Is there any documentation of how to get in and use the rails console?

I'm currently testing a lot around, and I'd like to get rid of all the tickets "Test1", "Test2", "Test3" etc ;-)

@martini
Copy link
Collaborator

martini commented Nov 9, 2016

Is there any documentation of how to get in and use the rails console?

shell> rails c
rails> Ticket.destroy_all

If you use the Zammad RPM, you need to do:
shell> zammad run rails c
rails> Ticket.destroy_all

@jacotec
Copy link

jacotec commented Nov 9, 2016

Thanks, works like a charm!

@gitviola
Copy link

in case you're looking for a way to delete all tickets but some you can use this method:

tickets_to_keep = [1, 2, 3] # enter the ids of all tickets you want to keep
(Ticket.all.pluck(:id) - tickets_to_keep).each { |id| Ticket.find(id).destroy }

this will delete all tickets except Ticket with id 1, 2 and 3

@MDXDave
Copy link
Author

MDXDave commented Mar 14, 2017

Still no news about it? 馃槓

@martini martini assigned martini and rolfschmidt and unassigned martini May 2, 2017
zammad-sync pushed a commit that referenced this issue May 5, 2017
commit fb089fd8a0ee2cfeb6882e993bbfe637847ddea5
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Wed May 3 17:12:24 2017 +0200

    Moved touch_reference_by_params to own function.

commit 13971570cba1bf0f437ff810792755c3bfbd8f1c
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Wed May 3 16:20:15 2017 +0200

    Added code to perform ticket deletions in frontend of zammad.

commit 88a079b6a5558cbfe5f4b76bfdc74cde98d79e6a
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Wed May 3 14:03:29 2017 +0200

    Fixed test.

commit c6e44a2027834f2f70b17f821232cbf8501a3f5c
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Wed May 3 13:57:31 2017 +0200

    Fixed pod.

commit f0ed06be7d6759cbfeabaac5e2653b84f9646967
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Wed May 3 13:55:34 2017 +0200

    Improved ticket object to kill all associations on destroy (#214).

commit 56d39992045f5bf8fb91721f3fe7497d5d49f880
Merge: cbbbc00 7647849
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Wed May 3 09:38:03 2017 +0200

    Merge branch 'develop' into private-bugfix-214-rs-develop

commit cbbbc0039e9ecdaab185e7bc2fdee046e636eb3a
Author: Rolf Schmidt <rolf.schmidt@znuny.com>
Date:   Tue May 2 16:53:21 2017 +0200

    Reworked file structure of concerns.

    - can (new methods)
    - checks (events, pre/post function checks)
    - has (model related functions and events)
zammad-sync pushed a commit that referenced this issue May 5, 2017
@rolfschmidt
Copy link
Collaborator

Hi guys,
i added a new ticket action:

grafik

With this action it should be no problem to clean up your system in future. Please use it carefully, there is no way back and thank you very much for this deep conversation and your support.

Changes are already available in the develop branch.

-Rolf

@rolfschmidt rolfschmidt added this to the 1.6.0 milestone May 5, 2017
@strangechoice
Copy link

Hi,

I tried to use the "delete" action and therefore created a macro to use it. Sadly, it's doing nothing with the ticket, only causing lots of activity in the logs (see below).

I'm using the current develop Debian package 1.6.1-1502058507.b2ece283.jessie

Messages from the log file are like attached when I select the delete macro for one ticket (Id 2394 in this case):

I, [2017-08-07T11:29:50.916731 #20037]  INFO -- : Started PUT "/api/v1/tickets/2934?all=true" for 134.99.182.24 at 2017-08-07 11:29:50 +0200
I, [2017-08-07T11:29:50.928520 #20037]  INFO -- : Processing by TicketsController#update as JSON
I, [2017-08-07T11:29:50.928785 #20037]  INFO -- :   Parameters: {"number"=>"201708077203221", "title"=>"Verzoegerte Mail / Delayed Mail (still being retried)", "group_id"=>"1", "owner_id"=>"9", "customer_id"=>2339, "state_id"=>"4", "priority_id"=>"2", "updated_at"=>"2017-08-07T09:22:04.377Z", "pending_time"=>nil, "id"=>"2934", "all"=>"true", "ticket"=>{"id"=>"2934", "group_id"=>"1", "priority_id"=>"2", "state_id"=>"4", "number"=>"201708077203221", "title"=>"Verzoegerte Mail / Delayed Mail (still being retried)", "owner_id"=>"9", "customer_id"=>2339, "pending_time"=>nil, "updated_at"=>"2017-08-07T09:22:04.377Z"}}
I, [2017-08-07T11:29:51.241498 #20037]  INFO -- : Completed 200 OK in 313ms (Views: 9.1ms | ActiveRecord: 33.0ms)
I, [2017-08-07T11:29:51.263816 #20037]  INFO -- : Started DELETE "/api/v1/ticket_attachment_upload" for 134.99.182.24 at 2017-08-07 11:29:51 +0200
I, [2017-08-07T11:29:51.267849 #20037]  INFO -- : Processing by TicketArticlesController#ticket_attachment_upload_delete as JSON
I, [2017-08-07T11:29:51.267922 #20037]  INFO -- :   Parameters: {"form_id"=>"097621992", "ticket_article"=>{"form_id"=>"097621992"}}
I, [2017-08-07T11:29:51.287497 #20037]  INFO -- : Completed 200 OK in 19ms (Views: 0.3ms | ActiveRecord: 3.5ms)
I, [2017-08-07T11:29:51.817125 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::UserDeviceLogJob (id=15352) RUNNING
I, [2017-08-07T11:29:51.839587 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::UserDeviceLogJob (id=15352) COMPLETED after 0.0222
I, [2017-08-07T11:29:51.844069 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::Ticket::UserTicketCounter::BackgroundJob (id=15353) RUNNING
I, [2017-08-07T11:29:51.853673 #20039]  INFO -- : 2017-08-07T11:29:51+0200: [Worker(host:zammad pid:20039)] Job Observer::Ticket::UserTicketCounter::BackgroundJob (id=15353) COMPLETED after 0.0093
I, [2017-08-07T11:29:52.067159 #20037]  INFO -- : Started GET "/api/v1/users/2339?full=true&_=1502091684037" for 134.99.182.24 at 2017-08-07 11:29:52 +0200
I, [2017-08-07T11:29:52.074838 #20037]  INFO -- : Processing by UsersController#show as JSON
I, [2017-08-07T11:29:52.074990 #20037]  INFO -- :   Parameters: {"full"=>"true", "_"=>"1502091684037", "id"=>"2339", "user"=>{}}
I, [2017-08-07T11:29:52.124370 #20037]  INFO -- : Completed 200 OK in 49ms (Views: 9.2ms | ActiveRecord: 5.2ms)
I, [2017-08-07T11:29:52.162360 #20037]  INFO -- : Started GET "/api/v1/ticket_customer?customer_id=2339&_=1502091684038" for 134.99.182.24 at 2017-08-07 11:29:52 +0200
I, [2017-08-07T11:29:52.171857 #20037]  INFO -- : Processing by TicketsController#ticket_customer as JSON
I, [2017-08-07T11:29:52.172077 #20037]  INFO -- :   Parameters: {"customer_id"=>"2339", "_"=>"1502091684038", "ticket"=>{}}
I, [2017-08-07T11:29:52.269458 #20037]  INFO -- : Completed 200 OK in 97ms (Views: 30.2ms | ActiveRecord: 4.1ms)
I, [2017-08-07T11:29:53.149049 #20037]  INFO -- : Started GET "/api/v1/users/2339?full=true&_=1502087532475" for 134.99.182.76 at 2017-08-07 11:29:53 +0200
I, [2017-08-07T11:29:53.158434 #20037]  INFO -- : Processing by UsersController#show as JSON
I, [2017-08-07T11:29:53.158857 #20037]  INFO -- :   Parameters: {"full"=>"true", "_"=>"1502087532475", "id"=>"2339", "user"=>{}}
I, [2017-08-07T11:29:53.227291 #20037]  INFO -- : Completed 200 OK in 68ms (Views: 13.2ms | ActiveRecord: 3.8ms)
I, [2017-08-07T11:29:53.424242 #20037]  INFO -- : Started PUT "/api/v1/taskbar/74" for 134.99.182.24 at 2017-08-07 11:29:53 +0200
I, [2017-08-07T11:29:53.434444 #20037]  INFO -- : Processing by TaskbarController#update as JSON
I, [2017-08-07T11:29:53.434747 #20037]  INFO -- :   Parameters: {"key"=>"Ticket-2934", "client_id"=>"123", "callback"=>"TicketZoom", "state"=>{"ticket"=>{}, "article"=>{}}, "params"=>{"ticket_id"=>2934, "overview_id"=>2, "shown"=>true}, "prio"=>16, "notify"=>false, "active"=>true, "updated_at"=>"2017-08-07T09:19:33.085Z", "id"=>"74", "taskbar"=>{"id"=>"74", "client_id"=>"123", "key"=>"Ticket-2934", "callback"=>"TicketZoom", "state"=>{"ticket"=>{}, "article"=>{}}, "params"=>{"ticket_id"=>2934, "overview_id"=>2, "shown"=>true}, "prio"=>16, "notify"=>false, "active"=>true, "updated_at"=>"2017-08-07T09:19:33.085Z"}}
I, [2017-08-07T11:29:53.500058 #20037]  INFO -- : Completed 200 OK in 65ms (Views: 1.4ms | ActiveRecord: 3.2ms)
I, [2017-08-07T11:29:54.323682 #20037]  INFO -- : Started GET "/api/v1/ticket_overviews?_=1502091684039" for 134.99.182.24 at 2017-08-07 11:29:54 +0200
I, [2017-08-07T11:29:54.324343 #20037]  INFO -- : Started GET "/api/v1/ticket_overviews?view=all_unassigned&_=1502091684040" for 134.99.182.24 at 2017-08-07 11:29:54 +0200
I, [2017-08-07T11:29:54.331526 #20037]  INFO -- : Processing by TicketOverviewsController#show as JSON
I, [2017-08-07T11:29:54.336974 #20037]  INFO -- : Processing by TicketOverviewsController#show as JSON
I, [2017-08-07T11:29:54.337380 #20037]  INFO -- :   Parameters: {"view"=>"all_unassigned", "_"=>"1502091684040", "ticket_overview"=>{}}
I, [2017-08-07T11:29:54.337205 #20037]  INFO -- :   Parameters: {"_"=>"1502091684039", "ticket_overview"=>{}}
I, [2017-08-07T11:29:54.519933 #20037]  INFO -- : Completed 200 OK in 181ms (Views: 0.8ms | ActiveRecord: 78.1ms)

@martini martini changed the title Delete tickets Delete tickets via admin interface as job Sep 6, 2017
@ghost
Copy link

ghost commented Nov 7, 2017

@rolfschmidt Is your delete action already available in the latest official Zammad2? I can't find it.
I'm using:

# apt policy zammad
zammad:
  Installed: 2.1.0-1509936117.b8f98730.xenial
  Candidate: 2.1.0-1509936117.b8f98730.xenial
  Version table:
 *** 2.1.0-1509936117.b8f98730.xenial 500
        500 https://dl.packager.io/srv/deb/zammad/zammad/stable/ubuntu 16.04/main amd64 Packages
        100 /var/lib/dpkg/status

@rolfschmidt
Copy link
Collaborator

Hey guys,

@strangechoice : yes this was a mistake. The delete action will be only supported in the scheduler. We removed the action from the macros.

@passboltUser : Please take a look at the scheduler.

grafik

Best regards,
Rolf

@ghost
Copy link

ghost commented Nov 28, 2017

@rolfschmidt Thanks. Unfortunately I can't get it running, don't see the New Scheduler. I'm under /#manage/time_accounting.

zammad

@rolfschmidt
Copy link
Collaborator

rolfschmidt commented Nov 28, 2017

Hello @passboltUser ,
i think you just missclicked.

  • Click on the menu Scheduler
  • Then on the top right on New scheduler
  • Below you choose the time where the tickets should get deleted.
  • Below you choose the conditions for the deletion of the tickets
  • Below you see some example tickets which will get deleted
  • Below you see the action you can do on the tickets. Here you can choose Action -> Delete

grafik

Best regards,


Hallo @passboltUser ,
ich glaube du hast dich nur verklickt.

  • Klick mal auf Automatisierungen
  • Dann rechts oben auf Neue zeitgesteuerte Aktion
  • Dann w盲hlst du als erstes den Zeitpunkt aus wann die Tickets immer gel枚scht werden
  • Darunter die Bedingungen die ein Ticket erhalten muss damit es gel枚scht wird
  • Darunter sieht man einen Ausschnitt der Liste der Tickets die dann gel枚scht wird.
  • Und darunter sieht man die Aktion, welche bei den Tickets ausgef眉hrt werden soll. Hier w盲hlst du dann
    Aktion -> L枚schen aus.

grafik

Gru脽

@ghost
Copy link

ghost commented Nov 28, 2017

@rolfschmidt Danke, habs gefunden. So werden alle bestimmten Tickets gel枚scht? Kann man auch einzelne l枚schen? Wir haben geschlossene Tickets die wir mit einem Tutorial tag getaggt haben, um nachzugucken, wie mal ein Problem gel枚st wurde (und diese Tickets k枚nnen dann in einer benutzerdefinierten Ansicht praktisch als alle Tutorials angezeigt werden).

Added eng: Thanks, found it. But this way all tickets are doing to be deleted? It it possible to delete individual ones? We have closed tickets which we tagged 'Tutorial' to lookup later how a problem was once solved (these tickes can be displayed nicely in a self-created view).

@rolfschmidt
Copy link
Collaborator

rolfschmidt commented Nov 28, 2017

Hi @passboltUser ,
if you choose the right conditions it should.

I'm sorry guys, i added the english translation for my last post. We should write english here on the issue tracker.

@ghost
Copy link

ghost commented Nov 28, 2017

Ok, thanks, I'll try. (also added english translation)

@ghost
Copy link

ghost commented Nov 28, 2017

Thanks, it works 馃憤 I added a second condition where I filtered by tickets which contain the tag "Spam" (so one has to add the tag "Spam" to such tickets).

@DjMagicFingers
Copy link
Contributor

First, i am happy to be able to delete tickets that creates loops - like tickets out techs sent to wrong email address of the client and the NDR keeps returning as we try to close the ticket since there is a close notification...

The problem we face is having a batch of 30 different numbered tickets that has loops or other issues that we want to delete and the schedule way is a way to learn what is patience... one manually entered ticket number for every 5 minutes...

My 2c is that there should be an admin-only, password protected form to delete tickets directly at the web interface.

@DjMagicFingers
Copy link
Contributor

I think i have found a nice solution with the great genius tools Zammad has to offer but it is not working for some reason :)
I used "Objects" at the System section of settings to create a new text field for tickets, called it "to be deleted by admin" and default text: "Please enter code".
Updated database and restartde Zammad.
Now that i have this new field, i can schedule deletion by it so i went to scheduler and created a new schedule with a condition that the "to be deleted by admin" field must contain the words for example: "delete me now!".

Now all i have to do is find the tickets i want to delete and enter this text string at the new field i have created.

image

The problem is it does not work (not deleting tickets) :)

Another option to accomplish deletion of many tickets without the need to wait for the schedule timer is to have a "run now" button for the scheduler :)

@rolfschmidt rolfschmidt reopened this Feb 26, 2018
@rolfschmidt
Copy link
Collaborator

Hi @DjMagicFingers ,
i added a object with the name "to_be_deleted_by_admin" as a input field and set some tickets with the value "delete me please". Afterwards i added a scheduler job to remove them. Works for me. It looks like you did not fill the values correctly at the ticket, because else they would show up in the preview in the screenshot you pasted. Could you please check again? Which version of zammad are you using?

Best regards,
Rolf

@thorsteneckel thorsteneckel removed this from the 2.0.0 milestone Aug 6, 2018
@MrGeneration
Copy link
Member

This is already part of Zammad and has been adressed with: 7d2409b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests