LanceMcCarthy / MvpApi

An application for Microsoft MVPs to easily browse and upload contributions
MIT License
36 stars 10 forks source link

Previous Submited Contributions not shown #28

Closed pmsousa closed 5 years ago

pmsousa commented 6 years ago

Hi,

On the home Page my previous submitted contributions list is now shown. On the top I can see the number of contributions but they are not listed. Is this a "feature" or a bug?

LanceMcCarthy commented 6 years ago

Are you seeing the same thing as this issue: https://github.com/LanceMcCarthy/MvpApi/issues/21

I released an update (v.1.3 or later) that will let you pick a lower batch count, see if selecting "25" helps. If it doesn't can you take a screenshot so I can get a better understanding of where you stand.

Note: Even though the DataGrid isn't binding the items correctly, you can upload contributions,

pmsousa commented 6 years ago

Hi @LanceMcCarthy,

Selecting a batch size of 25 works/helps; the previous batch was the default 50.

LanceMcCarthy commented 6 years ago

Thanks for letting me know! I think I'm going to set the default to 25, but still need to investigate why when the total results are smaller than the batch size, it doesn't show them.

pmsousa commented 6 years ago

Hi, Of course I had to! This is way simpler to submit than the form on the site... I think the default to 25 is a good workaround for now. I'm gonna clone your repo and see if I can find anything. Not my area of expertise but I still know some code!!! :P

LanceMcCarthy commented 6 years ago

One thing to be aware of, the load on demand behavior has a buffer items count of 20. This means when the DataGrid's scrolling position is less than 20 items from the bottom, it will do another fetch.

nromyn commented 6 years ago

I think it doesn't grab anything when the total number of items is less than the batch size, so if I have 40 items, it'll only show the first 25. Is that expected? Great tool by the way 👍

LanceMcCarthy commented 6 years ago

The app doesn't know the total amount until after it gets the first set of contributions. So if you see a count/total number, that means you already have the contributions in memory.

The issue is "Why aren't those initial items binding until a second fetch it initiated?"

LanceMcCarthy commented 6 years ago

@nromyn If you scroll down, it's supposed to fetch the next set of items.

It calls the API, asking for the items with the following restraint:

"Give me items starting with X and ending with X + batchsize"

Here's the line where that occurs: https://github.com/LanceMcCarthy/MvpApi/blob/5f218f1a7cb1e52f716a81c9600f2856bac6be33/MvpApi.Uwp/ViewModels/HomePageViewModel.cs#L81

Where: currentOffset is total count of the Contributions collection count is the batch count

For example, if you have a batch count of 25 and your current DataGrid is showing 50 of 200:

await App.ApiService.GetContributionsAsync(50, 25);

LanceMcCarthy commented 5 years ago

This was incidentally resolved in 1.8.2 by not using paging based of the TotalContributions number returned from the API (it's not a valid count anymore because the API only returns activities since 2016).

I've contacted the API team to get more info, if that gets fixed I'll introduce paging/load on demand again.