bito-code-review[bot] commented on code in PR #37680:
URL: https://github.com/apache/superset/pull/37680#discussion_r2766135922


##########
superset/models/user_onboarding_workflow.py:
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from flask_appbuilder import Model
+from sqlalchemy import Column, ForeignKey, Integer, Boolean
+from sqlalchemy.orm import relationship
+
+from superset import security_manager
+from superset.models.helpers import AuditMixinNullable
+
+
+class UserOnboardingWorkflow(Model, AuditMixinNullable):
+    """
+    Stores per-user state for onboarding workflows.
+
+    This model tracks a user's interaction with a specific onboarding workflow,
+    including whether the workflow has been visited and how many times it has
+    been completed or re-run. It enables Superset to determine when onboarding
+    experiences should be shown automatically and allows users to re-trigger
+    workflows as needed.
+
+    This table represents user-specific state only and should not contain any
+    workflow definition or UI configuration details.
+    """
+    __tablename__ = "user_onboarding_workflow"
+    user_id = Column(Integer, ForeignKey("ab_user.id"))
+    workflow_id = Column(Integer, ForeignKey("onboarding_workflow.id"))

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing Primary Key</b></div>
   <div id="fix">
   
   This SQLAlchemy model lacks a primary key, which is essential for database 
operations and ORM functionality. Without it, the model cannot be properly 
queried or updated. Based on the model's purpose tracking per-user per-workflow 
state, a composite primary key on user_id and workflow_id is appropriate.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       user_id = Column(Integer, ForeignKey("ab_user.id"), primary_key=True)
       workflow_id = Column(Integer, ForeignKey("onboarding_workflow.id"), 
primary_key=True)
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #03eb23</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset/migrations/versions/2026-02-04_17-02_a55bbb4da9a6_add_create_dashboard_with_none_existing_.py:
##########
@@ -0,0 +1,85 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Add oboarding workflow for creating a dashboard with none existing chart
+
+Revision ID: a55bbb4da9a6
+Revises: 91b151e8dac1
+Create Date: 2026-02-04 17:02:54.527420
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'a55bbb4da9a6'
+down_revision = '91b151e8dac1'
+
+from alembic import op

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Module imports not at top of file</b></div>
   <div id="fix">
   
   Imports on lines 29-30 must be moved to the top of the file, before the 
module docstring. Additionally, imports should be sorted (I001). Move `from 
alembic import op` and `import sqlalchemy as sa` to lines 1-2 after the license 
header.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
     # under the License.
    +import sqlalchemy as sa
    +
    +from alembic import op
    +
     """Add oboarding workflow for creating a dashboard with none existing chart
    
     Revision ID: a55bbb4da9a6
     Revises: 91b151e8dac1
     Create Date: 2026-02-04 17:02:54.527420
    
    
     """
    
     # revision identifiers, used by Alembic.
     revision = 'a55bbb4da9a6'
     down_revision = '91b151e8dac1'
    -
    -from alembic import op
    -import sqlalchemy as sa
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #03eb23</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset/migrations/versions/2026-02-04_16-32_91b151e8dac1_add_onboarding_workflows.py:
##########
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Add onboarding workflows tables
+
+Revision ID: 91b151e8dac1
+Revises: 9787190b3d89
+Create Date: 2026-02-04 16:32:25.570254
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '91b151e8dac1'
+down_revision = '9787190b3d89'
+
+from alembic import op
+import sqlalchemy as sa
+
+def upgrade():
+    op.create_table(
+        "onboarding_workflow",
+        sa.Column("created_on", sa.DateTime(), nullable=True),
+        sa.Column("changed_on", sa.DateTime(), nullable=True),
+        sa.Column("id", sa.Integer, primary_key=True),
+        sa.Column("name", sa.String(100), unique=True),
+        sa.Column("description", sa.String(255)),
+    )
+
+    op.create_table(
+        "user_onboarding_workflow",
+        sa.Column("created_on", sa.DateTime(), nullable=True),
+        sa.Column("changed_on", sa.DateTime(), nullable=True),
+        sa.Column("user_id", sa.Integer()),
+        sa.Column("workflow_id", sa.Integer()),
+        sa.Column("visited", sa.Boolean, default=False),
+        sa.Column("visited_times", sa.Integer, default=0),

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing Primary Key</b></div>
   <div id="fix">
   
   The user_onboarding_workflow table is a junction table linking users to 
workflows, but it lacks a primary key. Without one, duplicate associations 
could be inserted, leading to incorrect onboarding behavior. Add a composite 
primary key on user_id and workflow_id, as seen in similar tables like 
sl_dataset_users.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
            sa.Column("visited_times", sa.Integer, default=0),
            sa.PrimaryKeyConstraint(["user_id", "workflow_id"]),
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #03eb23</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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]

Reply via email to