Paginate the outbox responses. Fixes #669 #681

Слито
epsilon-phase слито 7 коммит(ов) из Outbox-pagination в master 5 лет назад
epsilon-phase прокомментировал(а) 5 лет назад (Перенесено из github.com)

This seems to work on our end, so let us know if there's anything else that needs fixing.

This seems to work on our end, so let us know if there's anything else that needs fixing.
codecov[bot] прокомментировал(а) 5 лет назад (Перенесено из github.com)

Codecov Report

Merging #681 into master will decrease coverage by 0.45%.
The diff coverage is 1.65%.

@@            Coverage Diff             @@
##           master     #681      +/-   ##
==========================================
- Coverage    39.8%   39.35%   -0.46%     
==========================================
  Files          72       72              
  Lines        9383     9494     +111     
  Branches     2219     2263      +44     
==========================================
+ Hits         3735     3736       +1     
- Misses       4592     4702     +110     
  Partials     1056     1056
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/681?src=pr&el=h1) Report > Merging [#681](https://codecov.io/gh/Plume-org/Plume/pull/681?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/866465c603cf169d24a65b8f77d4e462c7422f52?src=pr&el=desc) will **decrease** coverage by `0.45%`. > The diff coverage is `1.65%`. ```diff @@ Coverage Diff @@ ## master #681 +/- ## ========================================== - Coverage 39.8% 39.35% -0.46% ========================================== Files 72 72 Lines 9383 9494 +111 Branches 2219 2263 +44 ========================================== + Hits 3735 3736 +1 - Misses 4592 4702 +110 Partials 1056 1056 ```
trinity-1686a прокомментировал(а) 5 лет назад
Владелец

Thanks for participating to Plume dev!

There seems to be a few issues with you patch:

  • it returns the oldest posts first, which is the opposite of what other software are doing (but I'm not sure how much of an issue that actually is)
  • it does not link to previous/next page, so only 12 posts may be accessible. I'm not very familiar with the Activitypub crate, but I guess there is something about using OrderedCollectionPage instead/in addition to OrderedCollection
Thanks for participating to Plume dev! There seems to be a few issues with you patch: - it returns the oldest posts first, which is the opposite of what other software are doing (but I'm not sure how much of an issue that actually is) - it does not link to previous/next page, so only 12 posts may be accessible. I'm not very familiar with the Activitypub crate, but I guess there is something about using `OrderedCollectionPage` instead/in addition to `OrderedCollection`
elegaanz прокомментировал(а) 5 лет назад (Перенесено из github.com)

For ActivityPub, you need to have both an OrderedCollection on /@/USER/outbox, with a first field, containing a link to the first page of the outbox, and an endpoint like /@/USER/outbox/page=PAGE serving a specific OrderedCollectionPage, that should have the items (an array of activities), prev (a link to the previous page, if any) and next (a link to the next page, if any) fields.

I don't know if that's clear, I can try to explain it in another way if you want.

For ActivityPub, you need to have both an `OrderedCollection` on `/@/USER/outbox`, with a `first` field, containing a link to the first page of the outbox, and an endpoint like `/@/USER/outbox/page=PAGE` serving a specific `OrderedCollectionPage`, that should have the `items` (an array of activities), `prev` (a link to the previous page, if any) and `next` (a link to the next page, if any) fields. I don't know if that's clear, I can try to explain it in another way if you want.
epsilon-phase прокомментировал(а) 5 лет назад (Перенесено из github.com)

That's a good start for sure then.

So it does need to also request that the most recent posts are retrieved in an earlier page too right?

That's a good start for sure then. So it does need to also request that the most recent posts are retrieved in an earlier page too right?
epsilon-phase прокомментировал(а) 5 лет назад (Перенесено из github.com)

Okay, so, we think we understand what we need to do, but we're not sure what the proper kind of Link object is for this.

Okay, so, we think we understand what we need to do, but we're not sure what the proper kind of `Link` object is for this.
epsilon-phase прокомментировал(а) 5 лет назад (Перенесено из github.com)

With any luck that does it

With any luck that does it
igalic (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
igalic (Перенесено из github.com) оставил комментарий

igalic (Перенесено из github.com) прокомментировал(а) 5 лет назад

12 is hard coded. for now.?

12 is hard coded. for now.?
@ -557,2 +566,4 @@
user.outbox_page(&*rockets.conn, page.limits()).ok()
}
#[post("/@/<name>/inbox", data = "<data>")]
pub fn inbox(
igalic (Перенесено из github.com) прокомментировал(а) 5 лет назад

does a blog also have such an outbox that could benefit from such a pagination?

does a blog also have such an outbox that could benefit from such a pagination?
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

Oh, we didn't know about the constant elsewhere... But it's in the routes code rather than the models code.

We'll move it over then.

Oh, we didn't know about the constant elsewhere... But it's in the routes code rather than the models code. We'll move it over then.
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
@ -557,2 +566,4 @@
user.outbox_page(&*rockets.conn, page.limits()).ok()
}
#[post("/@/<name>/inbox", data = "<data>")]
pub fn inbox(
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

True enough, we'll get that made then....

... get_activities is a method stub for blogs. Huh.
In any case, we'll write the method stubs for now and see what's up with that.

True enough, we'll get that made then.... ... get_activities is a method stub for blogs. Huh. In any case, we'll write the method stubs for now and see what's up with that.
trinity-1686a рассмотрел(а) изменения 5 лет назад
trinity-1686a оставил комментарий
Владелец

overall this seems good, but I think there are some issues with page numbers at some places

overall this seems good, but I think there are some issues with page numbers at some places
trinity-1686a прокомментировал(а) 5 лет назад
Владелец

I think this does not give the right result, divisions are flooring where in this case we need them ceiling. An easy way to achive that is to add ITEMS_PER_PAGE-1 before dividing

                (self.get_activities(conn)?.len() + ITEMS_PER_PAGE - 1) as u64 / ITEMS_PER_PAGE as u64
I think this does not give the right result, divisions are flooring where in this case we need them ceiling. An easy way to achive that is to add ITEMS_PER_PAGE-1 before dividing ```suggestion (self.get_activities(conn)?.len() + ITEMS_PER_PAGE - 1) as u64 / ITEMS_PER_PAGE as u64 ```
trinity-1686a прокомментировал(а) 5 лет назад
Владелец

why is it commented? It should probably either stay or be deleted

why is it commented? It should probably either stay or be deleted
trinity-1686a прокомментировал(а) 5 лет назад
Владелец

Previous page should not be added if we are already on the first page, and a next page should probable not be added either if get_activities_page returned less entries than it could have.

Also I think there is an out-of-one on the page index, if we are on page n°1 (that is the first with current implementation of outbox above), min is going to be 0, so next page will be 0/12+1 = n°1 again, and previous would be n°-1

Previous page should not be added if we are already on the first page, and a next page should probable not be added either if `get_activities_page` returned less entries than it could have. Also I think there is an out-of-one on the page index, if we are on page n°1 (that is the first with current implementation of `outbox` above), min is going to be 0, so next page will be 0/12+1 = n°1 again, and previous would be n°-1
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

That makes sense. Should be fixed now

That makes sense. Should be fixed now
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

Alright, that makes sense too.

Alright, that makes sense too.
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

That makes sense.

That makes sense.
trinity-1686a рассмотрел(а) изменения 5 лет назад
trinity-1686a прокомментировал(а) 5 лет назад
Владелец

the part about not including previous/next when unnecessary is fixed, but I don't think you addressed the other half about page index

the part about not including previous/next when unnecessary is fixed, but I don't think you addressed the other half about page index
elegaanz (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
elegaanz (Перенесено из github.com) оставил комментарий

Globally, what you have done so far seems to work well. I left a few comments.

The only thing that really needs to be fixed is that fetching old posts for a remote user is no longer working.

Globally, what you have done so far seems to work well. I left a few comments. The only thing that really needs to be fixed is that fetching old posts for a remote user is no longer working.
elegaanz (Перенесено из github.com) прокомментировал(а) 5 лет назад

It starts at 1 for users, but 0 for blogs. Either are fine, but it would be better if it was consistent.

It starts at 1 for users, but 0 for blogs. Either are fine, but it would be better if it was consistent.
elegaanz (Перенесено из github.com) прокомментировал(а) 5 лет назад

Could you please call Blog::outbox_page here, even if it doesn't do anything yet?

Could you please call `Blog::outbox_page` here, even if it doesn't do anything yet?
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

Sure thing.

Sure thing.
epsilon-phase (Перенесено из github.com) рассмотрел(а) изменения 5 лет назад
epsilon-phase (Перенесено из github.com) прокомментировал(а) 5 лет назад

Looks like it should be one given the current Page code.

Let's make it that then.

Looks like it should be one given the current `Page` code. Let's make it that then.
epsilon-phase прокомментировал(а) 5 лет назад (Перенесено из github.com)

@AnaGelez You wouldn't have any recommendations on fixing the retrieval of older messages would you?

@AnaGelez You wouldn't have any recommendations on fixing the retrieval of older messages would you?
elegaanz прокомментировал(а) 5 лет назад (Перенесено из github.com)

The method that needs changing is this one: https://github.com/Plume-org/Plume/blob/master/plume-models/src/users.rs#L333

It should be modified so that it fetches all the pages, and puts all the activities in the returned Vec.

The method that needs changing is this one: https://github.com/Plume-org/Plume/blob/master/plume-models/src/users.rs#L333 It should be modified so that it fetches all the pages, and puts all the activities in the returned `Vec`.
elegaanz прокомментировал(а) 5 лет назад (Перенесено из github.com)

There is an issue with the last/first/prev/next links: the https:// part is doubled (for instance I have https://https://plume.one/@/admin_one/outbox?page=1).

I think it is because User::outbox_url already includes https://, and thus the call to ap_url is superfluous, you can use format! directly.

There is an issue with the `last`/`first`/`prev`/`next` links: the `https://` part is doubled (for instance I have `https://https://plume.one/@/admin_one/outbox?page=1`). I think it is because `User::outbox_url` already includes `https://`, and thus the call to `ap_url` is superfluous, you can use `format!` directly.
epsilon-phase прокомментировал(а) 5 лет назад (Перенесено из github.com)

That's a silly mistake to have made. Should be fixed now.

That's a silly mistake to have made. Should be fixed now.
elegaanz прокомментировал(а) 5 лет назад (Перенесено из github.com)

OK, it now fetches the pages correctly, but it loops infinitely, because on the last page last point the current page (which, indeed, is the last).

OK, it now fetches the pages correctly, but it loops infinitely, because on the last page `last` point the current page (which, indeed, is the last).
elegaanz (Перенесено из github.com) одобрил(а) эти изменения 5 лет назад
elegaanz (Перенесено из github.com) оставил комментарий

It seems to work fine now! Thank you very much for your help (and your patience) 😊

It seems to work fine now! Thank you very much for your help (and your patience) :blush:

Рецензенты

Запрос на слияние был объединен как 52d860d402.
Вы также можете просмотреть инструкции командной строки.

Шаг 1:

В репозитории вашего проекта посмотрите новую ветку и протестируйте изменения.
git checkout -b Outbox-pagination master
git pull origin Outbox-pagination

Шаг 2:

Объединить изменения и обновить на Forgejo.
git checkout master
git merge --no-ff Outbox-pagination
git push origin master
Войдите, чтобы присоединиться к обсуждению.
Нет рецензентов
Нет этапа
Нет назначенных лиц
2 участников
Уведомления
Срок выполнения
Срок действия недействителен или находится за пределами допустимого диапазона. Пожалуйста, используйте формат 'гггг-мм-дд'.

Срок выполнения не установлен.

Зависимости

Зависимостей нет.

Reference: Plume/Plume#681
Загрузка…
Пока нет содержимого.