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

Feature: Add new endpoint to list message hashes #652

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

aliel
Copy link
Member

@aliel aliel commented Nov 21, 2024

Self proofreading checklist

  • Is my code clear enough and well documented
  • Are my files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • Database migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Changes

Add /api/v0/messages/hashes to retreive messages hash item

How to test

# curl -s http://127.0.0.1:4024/api/v0/messages/hashes?pagination=10&page=2&status=processed&start_date=1734355062&sort_order=-1&hash_only=0
# or
curl -s http://127.0.0.1:4024/api/v0/messages/hashes
{
  "hashes": [
    "1ca7aecd5....",
    "...;"
    "11517a0a5...."
  ],
  "pagination_per_page": 20,
  "pagination_page": 1,
  "pagination_total": 5093053,
  "pagination_item": "hashes"
}
#
curl -s http://127.0.0.1:4024/api/v0/messages/hashes?pagination=2&hash_only=0
{
  "hashes": [
    {
      "status": "processed",
      "item_hash": "09a6ef....",
      "reception_time": 1734355052.813517
    },
    {
      "status": "processed",
      "item_hash": "a0a01...",
      "reception_time": 1734355040.583691
    }
  ],
  "pagination_per_page": 2,
  "pagination_page": 1,
  "pagination_total": 5093067,
  "pagination_item": "hashes"
}

@aliel aliel force-pushed the aliel-feature-message-hashes branch 2 times, most recently from 6e7166a to 4f1c062 Compare December 16, 2024 13:21
@aliel aliel requested a review from nesitor December 16, 2024 13:22
@aliel aliel force-pushed the aliel-feature-message-hashes branch from 4f1c062 to 55df22d Compare December 16, 2024 13:37
Copy link
Member

@nesitor nesitor left a comment

Choose a reason for hiding this comment

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

As I understand, this new endpoint is to obtain just the item_hashes between some dates or by status, but why don't integrate it on the same /messages endpoint only adding this new hash_only parameter?
Or maybe I'm missing another functionality that we don't integrate in the other endpoint?

src/aleph/web/controllers/messages.py Outdated Show resolved Hide resolved
@nesitor nesitor self-requested a review December 16, 2024 17:30
Copy link
Member

@nesitor nesitor left a comment

Choose a reason for hiding this comment

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

Okay, if it's more performant because we return so little amount of fields and it's needed for this use case, LGTM 🚀

@aliel aliel marked this pull request as ready for review December 17, 2024 13:04
@aliel aliel merged commit b5ee690 into main Dec 17, 2024
4 checks passed
@Psycojoker Psycojoker deleted the aliel-feature-message-hashes branch January 7, 2025 11:52
@Psycojoker
Copy link
Collaborator

It would have been nice to have at least a basic test for this view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants