autobrr / omegabrr

Omegabrr transforms monitored shows, movies, books and music from arrs into autobrr filters. It also supports adding titles from custom lists to autobrr filters.
https://autobrr.com
MIT License
127 stars 11 forks source link

enhancement: refactor and improve process function and webhook endpoints #59

Closed s0up4200 closed 1 year ago

s0up4200 commented 1 year ago

This PR introduces several improvements and fixes.

Fixed:

arr and lists now only update the given type, not both. (On latest, both commands do the exact same thing: they update everything)

Improvements:

Webhook endpoints now reflect the changes above.

curl -X POST 'http://127.0.0.1:7441/api/webhook/trigger/lists?apikey=api_key' # lists only
curl -X POST 'http://127.0.0.1:7441/api/webhook/trigger/arr?apikey=api_key' # arrs only
curl -X POST 'http://127.0.0.1:7441/api/webhook/trigger?apikey=api_key' # everything

Reduce risk of db locks Changed goroutines in service.go to a range loop to avoid autobrr db locks by updating one filter at a time instead of everything simultaneously. It takes a few more seconds but will improve stability overall.

Better error logging Minor improvements to error logging, resulting in more detailed and informative error messages in the summary displayed at the end of each run.

Improved help message and config search methods Improve help message and add config search methods: The help message has been updated for better clarity, and the application now looks for configuration files in multiple locations, including the default user configuration directory and the specified OMEGABRR_CONFIG environment variable.

s0up4200 commented 1 year ago

Tried to make all the suggestions you mentioned and also moved these into each case in main.go instead of having them in the ProcessArrs and ProcessLists to avoid them being printed twice during run:

if len(processingErrors) == 0 {
    log.Info().Msgf("Run complete.")
} else {
    log.Warn().Msgf("Run complete, with errors.")
    log.Warn().Msg("Errors encountered during processing:")
    for _, errMsg := range processingErrors {
        log.Warn().Msg(errMsg)
    }
}