Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

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

Merged
merged 12 commits into from
May 15, 2023

Conversation

s0up4200
Copy link
Contributor

@s0up4200 s0up4200 commented May 3, 2023

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 added 2 commits May 3, 2023 16:51
to avoid sqlite locks
its probably a bit slower, but should not get a "database is locked" anymore
@s0up4200 s0up4200 added the enhancement New feature or request label May 3, 2023
@s0up4200 s0up4200 marked this pull request as draft May 3, 2023 17:58
s0up4200 added 2 commits May 3, 2023 20:46
you can now trigger arrs or lists individually via POST
`omegabrr arr` and `omegabrr lists` now only trigger the given type
@s0up4200 s0up4200 changed the title enhancement(updateFilter): change to regular range loop to avoid db locks enhancement: refactor and improve process function and webhook endpoints May 3, 2023
@s0up4200 s0up4200 marked this pull request as ready for review May 3, 2023 21:26
@s0up4200 s0up4200 requested a review from zze0s May 6, 2023 22:08
Copy link
Contributor

@zze0s zze0s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good a good improvement but I would still split the logic out a bit more. It will function the same but give some separation to it.

@s0up4200
Copy link
Contributor Author

s0up4200 commented May 7, 2023

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)
    }
}

@s0up4200 s0up4200 requested a review from zze0s May 7, 2023 16:09
@s0up4200 s0up4200 marked this pull request as draft May 7, 2023 20:05
@s0up4200 s0up4200 marked this pull request as ready for review May 7, 2023 20:06
Copy link
Contributor

@zze0s zze0s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big PR :D looks good!

@zze0s zze0s merged commit 851eda8 into main May 15, 2023
@zze0s zze0s deleted the fix/change-to-regular-range-loop branch May 15, 2023 20:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants