semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Delete tasks history for a task template

Open jhaesselbacher opened this issue 2 years ago • 3 comments

Is it possible to add in the graphical interface the possibility of removing (purge) Tasks ID History for each Task Templates ? image

Have a good day :)

jhaesselbacher avatar Nov 23 '22 09:11 jhaesselbacher

It takes too many mysql database rows. A history delete function is greate.

DesireWithin avatar Jan 12 '23 10:01 DesireWithin

Does someone have a sql query which removes task history records by date?

koakenred avatar Mar 21 '23 15:03 koakenred

Not ideal but they can be deleted one at a time via the API. Could wrap in a for loop in a script. Need to auth to the API first with ID and password to generate a cookie. Then use the cookie to generate an API token.

Auth to generate a cookie

curl -v -c ./semaphore-cookie -XPOST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"auth": "your_username", "password": "your_password"}' \
http://192.168.1.104:3100/api/auth/login

Generate an API token

curl -v -b ./semaphore-cookie 'GET' \
  'http://192.168.1.104:3100/api/user/tokens' \
  -H 'accept: application/json'

Remove task 97

curl -X 'DELETE' \
  'http://192.168.1.104:3100/api/project/1/tasks/97' \
  -H 'accept: application/json' -H 'Authorization: Bearer your_api_token

For loop (deletes tasks from 92 to 85)

 for ((i=92;i>=85;i--)); do curl -X 'DELETE' \
     http://192.168.1.104:3100/api/project/1/tasks/$i \
     -H 'accept: application/json' \
     -H 'Authorization: Bearer your_api_token'; done

samcro1967 avatar May 06 '23 15:05 samcro1967

Is there no simple query? My dat a base is becvery large now. Would be great if something will be added in the ui.

magtimmermans avatar Jul 03 '23 20:07 magtimmermans

Related to: https://github.com/ansible-semaphore/semaphore/issues/978

ansibleguy avatar Jul 21 '23 06:07 ansibleguy