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

chore: remove archived column from features table #6431

Merged
merged 3 commits into from
Mar 5, 2024
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
12 changes: 7 additions & 5 deletions src/lib/features/feature-toggle/feature-toggle-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
.count('type')
.groupBy('type');

query.where({
project: projectId,
archived,
});
query
.where({
project: projectId,
})
.modify(FeatureToggleStore.filterByArchived, archived);
sjaanus marked this conversation as resolved.
Show resolved Hide resolved

const result = await query;
return result.map((row) => ({
Expand Down Expand Up @@ -677,7 +678,8 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
WHERE feature_types.id = features.type) *
INTERVAL '1 day'))) as current_staleness
FROM features
WHERE NOT stale = true AND archived_at IS NULL`,
WHERE NOT stale = true
AND archived_at IS NULL`,
[currentTime || this.db.fn.now()],
);

Expand Down
17 changes: 17 additions & 0 deletions src/migrations/20240305094305-features-remove-archived.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exports.up = function (db, cb) {
db.runSql(
`
ALTER TABLE features DROP COLUMN IF EXISTS archived;
`,
cb,
);
};

exports.down = function (db, cb) {
db.runSql(
`
ALTER TABLE features ADD COLUMN IF NOT EXISTS archived BOOLEAN DEFAULT FALSE;
`,
cb,
);
};
4 changes: 0 additions & 4 deletions src/test/e2e/services/project-service.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2070,19 +2070,15 @@ test('should get correct amount of features archived in current and past window'
await Promise.all([
updateFeature(toggles[0].name, {
archived_at: new Date(),
archived: true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Getting better: Lines of Code in a Single File
The lines of code decreases from 2087 to 2083, improve code health by reducing it to 1000

Why does this problem occur?

The number of Lines of Code in a single file. More Lines of Code lowers the code health. Read more.

}),
updateFeature(toggles[1].name, {
archived_at: new Date(),
archived: true,
}),
updateFeature(toggles[2].name, {
archived_at: subDays(new Date(), 31),
archived: true,
}),
updateFeature(toggles[3].name, {
archived_at: subDays(new Date(), 31),
archived: true,
}),
]);

Expand Down
Loading