Skip to content
Snippets Groups Projects

Add a with_zone option on ListProcessElements

Merged Erwan Rouchet requested to merge list-process-elements-with-zone into master
All threads resolved!

Closes #684 (closed)

The SQL queries take 5 to 10 ms with with_zone=False and 40ms with with_zone=True, with the page size not having any influence on the queries. In total, the endpoint takes 210-230ms to output 1000 elements without image info, and 240-260ms to output 1000 elements with image info. In HTML mode (when opening the endpoint in the browser), the endpoint takes 400 to 460ms instead as it has to do some more syntax highlighting.

The get_object_or_404 call to retrieve the DataImport in get_queryset has been moved to a cached property, as it sometimes caused duplicate queries to be made with the HTML output.

Image URL

The image URL is normally retrieved in other lists by calling the image.url property, which in turns calls image.server.build_url(image.path). This would require removing values() and using regular Image instances, which can make the endpoint twice as slow, so I made a URL using database functions.

I concatenated the server's URL with the image path. Since the server's URL might not always include slashes, I added a slash in between, and to avoid duplicate slashes, I trimmed the trailing slashes from the server's URL. PostgreSQL allows trimming any character using RTRIM(url, '/'), the equivalent of url.rstrip('/'); but Django only allows trimming spaces (RTRIM(url) alone), so I added a RTrimChr function to provide that.

When the element has no image, this causes the URL to be /, because NULL is just ignored in concatenations. I added a NullIf clause to just have the query return NULL, which returns None in the serializer without doing any further Python processing.

Edited by Erwan Rouchet

Merge request reports

Checking pipeline status.

Approval is optional

Merged by Bastien AbadieBastien Abadie 4 years ago (Mar 24, 2021 2:16pm UTC)

Merge details

  • Changes merged into master with 1359d819 (commits were squashed).
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Bastien Abadie
  • Erwan Rouchet resolved all threads

    resolved all threads

  • Erwan Rouchet added 1 commit
  • Erwan Rouchet added 1 commit

    added 1 commit

    Compare with previous version

  • Bastien Abadie
  • Erwan Rouchet added 1 commit

    added 1 commit

    Compare with previous version

  • Erwan Rouchet resolved all threads

    resolved all threads

  • Bastien Abadie mentioned in commit 1359d819

    mentioned in commit 1359d819

  • Please register or sign in to reply
    Loading