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

New: (Cardigann) Paging Support - v9 #1479

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft

New: (Cardigann) Paging Support - v9 #1479

wants to merge 5 commits into from

Conversation

Qstick
Copy link
Contributor

@Qstick Qstick commented Feb 26, 2023

Database Migration

NO

Description

  • Add PageSize to Cardigann Search block - this is used to calculate proper paging based on offset and limit passed into API.
  • Add ability to use {{ .Query.Page }} and {{ .PageSize }} in yml, this page is auto calculated based on the offset and limit passed to Prowlarr and the page size defined in the YML
  • Cleanup some paging logic to simplify some code

This should handle all paging scenarios

Examples
Indexer Page Size: 100 - User Search: Offset 100, Limit 100 - We should get page 2
Indexer Page Size: 100 - User Search: Offset 50, Limit 100 - We should pull page 1 and 2 and return correct items
Indexer Page Size: 100 - User Search: Offset 0, Limit 200 - We should pull page 1 and 2 and return all
Indexer Page Size: 100 - User Search: Offset 120, Limit 40 - We should get page 2 and return the correct results
Indexer Page Size 20 - User Search: Offset 40, Limit 100 - We should get and return pages 3,4,5,6,7

Todos

Fixes #379
Fixes #1470

@Qstick
Copy link
Contributor Author

Qstick commented Feb 26, 2023

Example indexer change to Blu

search:
  pageSize: 100
  firstPageNumber: 1
  paths:
    # https://hdinnovations.github.io/UNIT3D-Community-Edition-Docs/api_endpoints.html
    # https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/master/app/Http/Controllers/API/TorrentController.php
    - path: "/api/torrents/filter"
      response:
        type: json

  inputs:
  # if we have an id based search, add Season and Episode as query in name for UNIT3D < v6.  Else pass S/E Params for UNIT3D >= v6
    api_token: "{{ .Config.apikey }}"
    name: "{{ .Keywords }}"
    $raw: "{{ if .Query.Season }}&seasonNumber={{ .Query.Season }}{{ else }}{{ end }}{{ if .Query.Ep }}&episodeNumber={{ .Query.Ep }}{{ else }}{{ end }}{{ if .Query.TMDBID }}&tmdbId={{ .Query.TMDBID }}{{ else }}{{ end }}{{ if .Query.IMDBIDShort }}&imdbId={{ .Query.IMDBIDShort }}{{ else }}{{ end }}{{ if  .Query.TVDBID }}&tvdbId={{ .Query.TVDBID }}{{ else }}{{ end }}{{ range .Categories }}&categories[]={{.}}{{end}}{{ if .Config.freeleech }}&free[]=100{{ else }}{{ end }}"
    sortField: "{{ .Config.sort }}"
    sortDirection: "{{ .Config.type }}"
    perPage: "{{ .PageSize }}"
    page: "{{ .Query.Page }}"

@Qstick
Copy link
Contributor Author

Qstick commented Feb 26, 2023

@ilike2burnthing Thoughts? This expands on what you were doing with a POF to full paging support for Cardigann.

b42bf2c is the relevant commit

@ilike2burnthing
Copy link
Contributor

Looks good, and firstPageNumber seems like a smart addition.

@Qstick Qstick changed the title New: (Cardigann) Paging Support New: (Cardigann) Paging Support - v9 Feb 26, 2023
Qstick and others added 3 commits February 26, 2023 16:41
Co-Authored-By: Bogdan <mynameisbogdan@users.noreply.github.com>
Co-Authored-By: Bogdan <mynameisbogdan@users.noreply.github.com>
@sonarcloud
Copy link

sonarcloud bot commented Feb 26, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

3.8% 3.8% Coverage
33.6% 33.6% Duplication

@mynameisbogdan mynameisbogdan linked an issue Feb 27, 2023 that may be closed by this pull request
1 task
@bakerboy448 bakerboy448 added the Area: Indexer Issue is related to indexers. label Feb 27, 2023
@bakerboy448 bakerboy448 added Status: Waiting for OP Action Required from OP conflict conflict - cannot merge, needs resolution and removed Status: In Progress In Progress labels Mar 30, 2023
@Qstick Qstick marked this pull request as draft May 3, 2023 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Indexer Issue is related to indexers. conflict conflict - cannot merge, needs resolution Status: Waiting for OP Action Required from OP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ignoreblankinputs is not supported [BUG]: Non-Newznab/Torznab pagination issues
3 participants