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

Activity feed: JSON API #814

Open
Tracked by #767
rouk1 opened this issue Nov 26, 2024 · 15 comments
Open
Tracked by #767

Activity feed: JSON API #814

rouk1 opened this issue Nov 26, 2024 · 15 comments
Assignees

Comments

@rouk1
Copy link
Contributor

rouk1 commented Nov 26, 2024

As a frontend developer I want to request the project's activity using an HTTP API.

Disclaimer: even if this a perfect use case for web sockets, we will stick to a REST endpoint.

Needs

We need to serialize a list of item version for the frontend to display them from most recent to oldest one.

Note

This means that: if a user asks for the last 5 minutes of activity, and one item has changed 2 times during this time frame (same identifier, two different values), they will receive 2 versions of this item.

Proposed API

GET /api/project/activity?after={creation_datetime} (fetch the project activity)

Parameters
name type data type description
after optional datetime as UTC string (iso 8601) A search filter (every item that have been added after the given datetime). Adding this parameter will allow frontend to only request new data after the initial call.
Response
http code content-type response description
200 application/json;charset=UTF-8 [{...}, {...}, ...] A list of item ordered by descending create_at datetime.
Data layout
[
  {
    "name": "md_item",
    "media_type": "text/markdown",
    "value": "# hello",
    "created_at": "2020-07-10 15:00:00.000"
  },
  {
    "name": "df_item",
    "media_type": "application/vnd.dataframe+json",
    "value": {},
    "created_at": "2020-07-10 14:00:00.000"
  },
  //...
]
@rouk1 rouk1 mentioned this issue Nov 26, 2024
6 tasks
@rouk1 rouk1 changed the title REST endpoints defined Activity feed JSON API Nov 26, 2024
@rouk1 rouk1 self-assigned this Nov 26, 2024
@rouk1 rouk1 changed the title Activity feed JSON API Activity feed: JSON API Nov 26, 2024
@rouk1
Copy link
Contributor Author

rouk1 commented Nov 26, 2024

@augustebaum & @thomass-dev may I have your review on this ?

@tuscland
Copy link
Member

I have a few questions:

  • The spec includes support for warnings and potentially other types of objects. The proposed API does not seem to cover this.
  • Can we still leave without identifiers for items or anything that is stored? It feels like we are pushing the model to its limits for nothing.

@tuscland
Copy link
Member

Note: warnings are removed from this first iteration.

@rouk1
Copy link
Contributor Author

rouk1 commented Nov 26, 2024

  • Can we still leave without identifiers for items or anything that is stored? It feels like we are pushing the model to its limits for nothing.

Hmmm your right I forgot that. Editing...

@rouk1
Copy link
Contributor Author

rouk1 commented Nov 26, 2024

Note: warnings are removed from this first iteration.

It could be quite easy to add warnings.
A warning could have a media_type and be persisted in a dedicated repository (like we did for views).

[
  {
    "name": "High class imbalance",
    "media_type": "application/vnd.warning+text",
    "value": "It seems that you have a classification problem with at least one class with...",
    "updated_at": "2020-07-10 15:00:00.000",
    "created_at": "2020-07-10 15:00:00.000"
  }
  //...
]

@augustebaum
Copy link
Contributor

Does after refer to created_at or updated_at? Should there be created_after and updated_after parameters instead?

@augustebaum
Copy link
Contributor

Disclaimer: even if this a perfect use case for web sockets, we will stick to a REST endpoint.

Can you give more details? Why is it a perfect use-case, and if so, why would we not do that?

@rouk1
Copy link
Contributor Author

rouk1 commented Nov 27, 2024

Does after refer to created_at or updated_at? Should there be created_after and updated_after parameters instead?

It's a good question. Those naming comes directly from what we have in the project API. I prefer to have consistent naming for the same thing. But you're right to have consistent data and as each item will have only one creation_date we can change the data layout to:

{
    "name": "High class imbalance",
    "media_type": "application/vnd.warning+text",
    "value": "It seems that you have a classification problem with at least one class with...",
    "created_at": "2020-07-10 15:00:00.000"
}

and avoid confusion.

Disclaimer: even if this a perfect use case for web sockets, we will stick to a REST endpoint.

Can you give more details? Why is it a perfect use-case, and if so, why would we not do that?

It's an activity feed. The term feed could let you think that it's real time. Hence a real time communication protocol sounds appropriate. But to implement this without some message broker we would need to watch the db changes. As far as I know, because we use diskcache, we cant have easily access to the sqlite driver to register some hooks. As a first approach polling with incremental search will have good performances and abstracts us from complex communication between process.

@augustebaum
Copy link
Contributor

each item will have only [a] creation_date [not a update_date]

Works for me

@rouk1
Copy link
Contributor Author

rouk1 commented Nov 27, 2024

edit: added @augustebaum feedbacks

@thomass-dev
Copy link
Collaborator

thomass-dev commented Dec 2, 2024

Just a naive question: what about mixing history and activity?

If you ask for the last 5 minutes activity, and one item has changed 2 times during this period (same identifier, two different values). Would you receive the two versions of the items? Or the latest one?

Otherwise, perfect proposition, thanks @rouk1 .

@rouk1
Copy link
Contributor Author

rouk1 commented Dec 2, 2024

Just a naive question: what about mixing history and activity?

If you ask for the last 5 minutes activity, and one item has changed 2 times during this period (same identifier, two different values). Would you receive the two versions of the items? Or the latest one?

You should receive all events that happens during that time frame. Hence 2 versions of your item.

@thomass-dev
Copy link
Collaborator

thomass-dev commented Dec 2, 2024

Can you update your description that way and make a quick reference?

@rouk1
Copy link
Contributor Author

rouk1 commented Dec 2, 2024

Can you update your description that way and make a quick reference?

Done, is it ok for you ?

@tuscland
Copy link
Member

tuscland commented Dec 2, 2024

LGTM

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

No branches or pull requests

4 participants