villebro commented on issue #29839:
URL: https://github.com/apache/superset/issues/29839#issuecomment-2278812837
> Trying to formalize the Model (?):
>
> ```python
> class AsyncTask(Base):
> __tablename__ = 'async_tasks'
>
> id = Column(Integer, primary_key=True)
> task_id = Column(String(256), unique=True, nullable=False, index=True)
> task_name = Column(String(256), nullable=False)
> status = Column(Enum('PENDING', 'IN_PROGRESS', 'SUCCESS', 'REVOKED',
'FAILURE', name='task_status'), nullable=False)
> created_at = Column(DateTime, nullable=False)
> updated_at = Column(DateTime, nullable=False)
> ended_at = Column(DateTime, nullable=False)
> error = Column(String, nullable=True)
> extra_json = Column(Text, nullable=True)
> ```
I think this looks generally ok. Maybe we could just rename `extra_json` to
`payload` or `state` (JSON serializable ofc), as I assume all tasks will have
some state. Also, I find `Enum` works pretty badly on ORM tables, so we may
just want to use `IntEnum` in the backend and have `INT` on the ORM table (we
would call it `status_id` on the table, and then have a property on the SQLA
model that maps the `INT` value to a proper Python `Enum`). Finally, I think we
should add a `type` field (I assume `name` will be some human readable
representation, like "Email report of 'My Dashboard'"), with the following
`Enum`-type values (this list is probably non-exhaustive, but you get the idea):
- CHART_QUERY
- SQLLAB_QUERY
- THUMBNAIL
- ALERTS_REPORTS
- LOG_ROTATE
- CACHE_WARMUP
- CUSTOM (this would be for used defined tasks that could be cronned in the
`CeleryConfig` or whichever scheduler we use).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]