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

Cleanup doc tracker models #9747

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions front/admin/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ import {
} from "@app/lib/models/assistant/conversation";
import { ConversationClassification } from "@app/lib/models/conversation_classification";
import {
DocumentTrackerChangeSuggestion,
TrackedDocument,
TrackerConfigurationModel,
TrackerDataSourceConfigurationModel,
TrackerGenerationModel,
Expand Down Expand Up @@ -127,8 +125,6 @@ async function main() {

await RunModel.sync({ alter: true });
await RunUsageModel.sync({ alter: true });
await TrackedDocument.sync({ alter: true });
await DocumentTrackerChangeSuggestion.sync({ alter: true });

await TrackerConfigurationModel.sync({ alter: true });
await TrackerDataSourceConfigurationModel.sync({ alter: true });
Expand Down
191 changes: 0 additions & 191 deletions front/lib/document_tracker.ts

This file was deleted.

102 changes: 0 additions & 102 deletions front/lib/models/doc_tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DataSourceModel } from "@app/lib/resources/storage/models/data_source";
import { DataSourceViewModel } from "@app/lib/resources/storage/models/data_source_view";
import { SpaceModel } from "@app/lib/resources/storage/models/spaces";
import { UserModel } from "@app/lib/resources/storage/models/user";
import { BaseModel } from "@app/lib/resources/storage/wrappers";
import { SoftDeletableModel } from "@app/lib/resources/storage/wrappers";

export class TrackerConfigurationModel extends SoftDeletableModel<TrackerConfigurationModel> {
Expand Down Expand Up @@ -301,104 +300,3 @@ TrackerGenerationModel.belongsTo(DataSourceModel, {
foreignKey: { allowNull: false },
as: "dataSource",
});

// TODO(DOC_TRACKER) Delete models below this line
// They will be replaced by the new models

export class TrackedDocument extends BaseModel<TrackedDocument> {
declare createdAt: CreationOptional<Date>;
declare updatedAt: CreationOptional<Date>;

declare documentId: string;
declare trackingEnabledAt: Date | null;

declare userId: ForeignKey<UserModel["id"]>;
declare dataSourceId: ForeignKey<DataSourceModel["id"]>;
}

TrackedDocument.init(
{
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
documentId: {
type: DataTypes.STRING,
allowNull: false,
},
trackingEnabledAt: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: DataTypes.NOW,
},
},
{
modelName: "tracked_document",
sequelize: frontSequelize,
indexes: [
{ fields: ["userId", "dataSourceId", "documentId"], unique: true },
{ fields: ["dataSourceId"] },
],
}
);

DataSourceModel.hasMany(TrackedDocument, {
foreignKey: { allowNull: false },
onDelete: "CASCADE",
});
UserModel.hasMany(TrackedDocument, {
foreignKey: { allowNull: false },
onDelete: "CASCADE",
});

export class DocumentTrackerChangeSuggestion extends BaseModel<DocumentTrackerChangeSuggestion> {
declare createdAt: CreationOptional<Date>;
declare updatedAt: CreationOptional<Date>;

declare suggestion: string;
declare reason: string | null;
declare status: "pending" | "done" | "rejected";

declare trackedDocumentId: ForeignKey<TrackedDocument["id"]>;
declare sourceDataSourceId: ForeignKey<DataSourceModel["id"]>;
declare sourceDocumentId: string;
}

DocumentTrackerChangeSuggestion.init(
{
createdAt: { type: DataTypes.DATE, allowNull: false },
updatedAt: { type: DataTypes.DATE, allowNull: false },
suggestion: { type: DataTypes.TEXT, allowNull: false },
suggestionTitle: { type: DataTypes.TEXT, allowNull: true },
reason: { type: DataTypes.TEXT, allowNull: true },
status: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: "pending",
},
sourceDocumentId: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
modelName: "document_tracker_change_suggestion",
sequelize: frontSequelize,
indexes: [{ fields: ["trackedDocumentId"] }],
}
);

TrackedDocument.hasMany(DocumentTrackerChangeSuggestion, {
foreignKey: { allowNull: false },
onDelete: "CASCADE",
});
DataSourceModel.hasMany(DocumentTrackerChangeSuggestion, {
foreignKey: { allowNull: false, name: "sourceDataSourceId" },
onDelete: "RESTRICT",
});
2 changes: 2 additions & 0 deletions front/migrations/db/migration_139.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE document_tracker_change_suggestions;
DROP TABLE tracked_documents;
Loading