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 only returning one item from /Item/Latest api. #12492

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

scampower3
Copy link
Member

Changes

Adds an extra function to the SqliteItemRepository to do a sub query to get the top N number of unique series/albums names sorted by datecreated. The min value of the datecreated from the subquery is then used to retrieve the rows for use for the /item/latest api.

Issues

Fixes #10993
Fixes #1880

@@ -2592,6 +2592,106 @@ public List<BaseItem> GetItemList(InternalItemsQuery query)
return items;
}

public List<BaseItem> GetLatestItemList(InternalItemsQuery query, CollectionType collectionType)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public List<BaseItem> GetLatestItemList(InternalItemsQuery query, CollectionType collectionType)
public IReadOnlyList<BaseItem> GetLatestItemList(InternalItemsQuery query, CollectionType collectionType)

// Early exit if the distinct column is null
if (string.IsNullOrEmpty(distintColumn))
{
return Enumerable.Empty<BaseItem>().ToList();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return Enumerable.Empty<BaseItem>().ToList();
return Array.Empty<BaseItem>();

The whole point of using the static method is to share the instance, a ToList does negate that advantage

@@ -1339,6 +1339,21 @@ public List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> paren
return _itemRepository.GetItemList(query);
}

public List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents, CollectionType collectionType)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents, CollectionType collectionType)
public IReadOnlyList<BaseItem> GetItemList(InternalItemsQuery query, IEnumerable<BaseItem> parents, CollectionType collectionType)

/// <param name="parents">Items to use for query.</param>
/// <param name="collectionType">Collection Type.</param>
/// <returns>List of items.</returns>
List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents, CollectionType collectionType);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents, CollectionType collectionType);
IReadOnlyList<BaseItem> GetItemList(InternalItemsQuery query, IEnumerable<BaseItem> parents, CollectionType collectionType);

/// <param name="query">The query.</param>
/// <param name="collectionType">Collection Type.</param>
/// <returns>List&lt;BaseItem&gt;.</returns>
List<BaseItem> GetLatestItemList(InternalItemsQuery query, CollectionType collectionType);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
List<BaseItem> GetLatestItemList(InternalItemsQuery query, CollectionType collectionType);
IReadOnlyList<BaseItem> GetLatestItemList(InternalItemsQuery query, CollectionType collectionType);

@JPVenson JPVenson added the enhancement Improving an existing function, or small fixes label Aug 24, 2024
}
}

return items;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return items;
return items.ToReadOnlyArray();

@jordanwalster
Copy link

@Bond-009 it would be good to know if this is on your radar?

@JPVenson JPVenson added the blocked Blocked by another pull request label Dec 15, 2024
Copy link
Member

@JPVenson JPVenson left a comment

Choose a reason for hiding this comment

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

Blocked by EFCore rewrite

@JPVenson JPVenson self-requested a review December 15, 2024 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by another pull request enhancement Improving an existing function, or small fixes
Projects
Status: In progress
3 participants