betodealmeida commented on a change in pull request #5524: A tagging system for
dashboards, charts and queries
URL:
https://github.com/apache/incubator-superset/pull/5524#discussion_r207343791
##########
File path: superset/models/tags.py
##########
@@ -0,0 +1,233 @@
+# -*- coding: utf-8 -*-
+# pylint: disable=no-init
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+import enum
+
+from flask_appbuilder import Model
+from sqlalchemy import Column, Enum, ForeignKey, Integer, String
+from sqlalchemy.orm import relationship, sessionmaker
+from sqlalchemy.orm.exc import NoResultFound
+
+from superset.models.helpers import AuditMixinNullable
+
+
+Session = sessionmaker(autoflush=False)
+
+
+class TagTypes(enum.Enum):
+
+ """
+ Types for tags.
+
+ Objects (queries, charts and dashboards) will have with implicit tags based
+ on metadata: types, owners and who favorited them. This way, user "alice"
+ can find all their objects by querying for the tag `owner:alice`.
+ """
+
+ # explicit tags, added manually by the owner
+ custom = 1
Review comment:
SQLAlchemy is storing them as strings in the DB, though (at least in sqlite):
```sql
sqlite> SELECT DISTINCT object_type FROM tagged_object;
chart
dashboard
query
sqlite> .schema tagged_object
CREATE TABLE tagged_object (
created_on DATETIME,
changed_on DATETIME,
id INTEGER NOT NULL,
tag_id INTEGER,
object_id INTEGER,
object_type VARCHAR(9),
created_by_fk INTEGER,
changed_by_fk INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(tag_id) REFERENCES tag (id),
CONSTRAINT objecttypes CHECK (object_type IN ('query', 'chart',
'dashboard')),
FOREIGN KEY(created_by_fk) REFERENCES ab_user (id),
FOREIGN KEY(changed_by_fk) REFERENCES ab_user (id)
);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]