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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: save orders more often #159

Merged
merged 5 commits into from
Oct 4, 2024
Merged

fix: save orders more often #159

merged 5 commits into from
Oct 4, 2024

Conversation

alfetopito
Copy link
Contributor

Description

This PR introduces more often saving of orders after processing.
For now, after every 20 orders processed, it'll trigger a db save.

There are also some logging improvements to make debugging easier.

How to test

Run the service.
It should start and process orders as usual.

Related Issues

There have been performance issues which I'm not able to tell what's causing it so far.
This change is an attempt to alleviate the in memory load by saving it more often.

@alfetopito alfetopito self-assigned this Oct 3, 2024
@alfetopito alfetopito requested a review from a team October 3, 2024 15:25
Copy link

@shoom3301 shoom3301 left a comment

Choose a reason for hiding this comment

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

LGTM.
Checked the logic, works as expected:

var items = new Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])
var itemsToDelete = []
var index = 0

for (const item of items) {
    index++

    if (index % 5 === 1 && index > 1) {
        for (const itemToDelete of itemsToDelete) {
          const deleted = items.delete(itemToDelete)
          console.log('delete', itemToDelete, deleted)
        }
        itemsToDelete = []
    }
    
    console.log('item', item)
    itemsToDelete.push(item)
}

console.log('items result', items)
image

@alfetopito alfetopito merged commit 4978b50 into main Oct 4, 2024
4 checks passed
@alfetopito alfetopito deleted the fix-watch-tower branch October 4, 2024 07:25
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants