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

Send last read chapter in Mangas in Category API #507

Merged
merged 3 commits into from
Feb 20, 2023

Conversation

akabhirav
Copy link
Contributor

@akabhirav akabhirav commented Feb 19, 2023

What

This PR starts sending last read chapter details in the manga object. The provision to send this was already there but was not utilized for some reason(perhaps performance reasons, but that's just speculation)

Why

This will enable us to implement the sort by last read manga feature

Performance report for API api/v1/category/{categoryId}

JS code used for benchmarking:

var url = "http://127.0.0.1:4567/api/v1/category/0"
const numRequests = 10
let totalFetchTime = 0;

for (let i = 0; i < numRequests; i++) {
    const startTime = performance.now();
    fetch(url)
        .then(response => {
            const endTime = performance.now();
            const fetchTime = endTime - startTime;
            console.log(`Request ${i+1}: ${fetchTime} ms`);
            totalFetchTime += fetchTime;
        })
        .catch(error => console.error(error));
}

const averageFetchTime = totalFetchTime / numRequests;
console.log(`Average fetch time: ${averageFetchTime} ms`);

Total Number of Rows in Manga table: 909

Total Number of Manga in Library: 93

Total Number of Rows in Chapter table: 18760

Total Number of Chapters for Mangas in Library: 18345

TIMINGS

Optimized Query after Last Read Chapter change

Average Request time over 10 requests ran 3 times: 392.173333333 ms

Non Optimized query after Last Read Chapter change

Average Request time over 10 requests ran 3 times: 430.143333333 ms

Optimized Query without Last Read Chapter change

Average Request time over 10 requests ran 3 times: 286.22 ms

Optimized Query with new column instead of Chapter object

Average Request time over 10 requests ran 3 times: 304.553333333 ms

Baseline(master branch)

Average Request time over 10 requests ran 3 times: 315.47 ms

Server Hardware details:

CPU: AMD Ryzen 9 5900X 12-Core Processor
RAM: 32GB DDR4 3200 MT/s
STORAGE: Samsung SSD 970 EVO Plus 500GB

@DattatreyaReddy
Copy link
Contributor

#307

@AriaMoradi
Copy link
Member

I hope h2 knows how to optimize queries, oof we are now hitting chapters multiple times, at least it's in the number of hundreds to thousands so hopefully it won't become slower and slower as we make more high level data available...

@AriaMoradi AriaMoradi merged commit 783787e into Suwayomi:master Feb 20, 2023
@akabhirav akabhirav deleted the send-last-read-chapter branch February 24, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants