Mobile-Security-Framework-MobSF icon indicating copy to clipboard operation
Mobile-Security-Framework-MobSF copied to clipboard

feat(page): recent scans add page jumper

Open miaoyc666 opened this issue 1 year ago • 8 comments

Describe the Pull Request

When MobSF has a large amount of sample data in the system, the recent scans api speed has been very slow because it will retrieve full table data from the database.

To fix this, recent scans api add page jump, default display 10 items per page

Renderings image

Checklist for PR

  • [x] Run MobSF unit tests and lint tox -e lint,test
  • [x] Tested Working on Linux, Mac, Windows, and Docker
  • [x] Add unit test for any new Web API (Refer: StaticAnalyzer/tests.py)
  • [x] Make sure tests are passing on your PR MobSF tests

Additional Comments (if any)

DESCRIBE HERE

miaoyc666 avatar Mar 01 '24 07:03 miaoyc666

Can you also include the changes in UI as well?

ajinabraham avatar Mar 07 '24 05:03 ajinabraham

Can you also include the changes in UI as well?

Do you mean adding paging parameters in the fe as well? Of course, it's just that it takes time. 😂

miaoyc666 avatar Mar 07 '24 07:03 miaoyc666

Can you also include the changes in UI as well?

@ajinabraham ui done!

miaoyc666 avatar Apr 05 '24 04:04 miaoyc666

@miaoyc666 Do you have any suggestions for optimizing the database? I found that when the amount of data exceeds 30,000, data query will become extremely slow, even if the page display is still very slow

ohyeah521 avatar Apr 05 '24 06:04 ohyeah521

@miaoyc666 Do you have any suggestions for optimizing the database? I found that when the amount of data exceeds 30,000, data query will become extremely slow, even if the page display is still very slow

@ohyeah521

When you query a database, the first thing to control is the number of rows you query. You need to add offset and limit parameters to your SQL statement for pagination queries, limiting the number of rows returned. Secondly, you need to select the fields that need to be displayed for select queries. Do not search for useless fields and cannot use select * because it will query all fields in a record, which will consume additional network bandwidth and CPU computing resources. You can take a look at the code I commited, perform pagination queries in django, and only query the fields displayed on the page in the recent list of samples.

miaoyc666 avatar Apr 05 '24 06:04 miaoyc666

@miaoyc666 thanks

ohyeah521 avatar Apr 05 '24 06:04 ohyeah521

@miaoyc666 Thanks for taking your time and working on the UI bits. I will review this soon and get back to you.

ajinabraham avatar May 20 '24 16:05 ajinabraham

Initial testing looks good. I will see if I can improve up on the UI based on https://realpython.com/django-pagination/

ajinabraham avatar May 20 '24 20:05 ajinabraham