-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
feat: expose lifecycle stage in project overview search #7017
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import type { | |
IFeatureOverview, | ||
IFeatureSearchOverview, | ||
IFeatureSearchStore, | ||
IFlagResolver, | ||
ITag, | ||
} from '../../types'; | ||
import FeatureToggleStore from '../feature-toggle/feature-toggle-store'; | ||
|
@@ -40,9 +41,17 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
|
||
private readonly timer: Function; | ||
|
||
constructor(db: Db, eventBus: EventEmitter, getLogger: LogProvider) { | ||
private flagResolver: IFlagResolver; | ||
|
||
constructor( | ||
db: Db, | ||
eventBus: EventEmitter, | ||
getLogger: LogProvider, | ||
flagResolver: IFlagResolver, | ||
) { | ||
this.db = db; | ||
this.logger = getLogger('feature-search-store.ts'); | ||
this.flagResolver = flagResolver; | ||
this.timer = (action) => | ||
metricsHelper.wrapTimer(eventBus, DB_TIME, { | ||
store: 'feature-search', | ||
|
@@ -86,6 +95,19 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
const validatedSortOrder = | ||
sortOrder === 'asc' || sortOrder === 'desc' ? sortOrder : 'asc'; | ||
|
||
const featureLifecycleEnabled = | ||
this.flagResolver.isEnabled('featureLifecycle'); | ||
const latestLifecycleStageQuery = this.db | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also can we look into opportunities to pull it out as a method, and put all selects, joins and query there |
||
.select([ | ||
'feature_lifecycles.feature', | ||
'feature_lifecycles.stage as latest_stage', | ||
this.db.raw( | ||
'MAX(feature_lifecycles.created_at) OVER (PARTITION BY feature_lifecycles.feature) as entered_stage_at', | ||
), | ||
]) | ||
.from('feature_lifecycles') | ||
.as('lifecycle'); | ||
|
||
const finalQuery = this.db | ||
.with('ranked_features', (query) => { | ||
query.from('features'); | ||
|
@@ -112,6 +134,13 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
const lastSeenQuery = 'last_seen_at_metrics.last_seen_at'; | ||
selectColumns.push(`${lastSeenQuery} as env_last_seen_at`); | ||
|
||
if (featureLifecycleEnabled) { | ||
selectColumns.push( | ||
'lifecycle.latest_stage', | ||
'lifecycle.entered_stage_at', | ||
); | ||
} | ||
|
||
if (userId) { | ||
query.leftJoin(`favorite_features`, function () { | ||
this.on( | ||
|
@@ -224,6 +253,14 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
); | ||
}); | ||
|
||
if (featureLifecycleEnabled) { | ||
query.leftJoin( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not join it into original query, but rather into final query, where the paging has been done already. |
||
latestLifecycleStageQuery, | ||
'lifecycle.feature', | ||
'features.name', | ||
); | ||
} | ||
|
||
const rankingSql = this.buildRankingSql( | ||
favoritesFirst, | ||
sortBy, | ||
|
@@ -371,6 +408,12 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
dependencyType: row.dependency, | ||
environments: [], | ||
segments: row.segment_name ? [row.segment_name] : [], | ||
lifecycle: row.latest_stage | ||
? { | ||
stage: row.latest_stage, | ||
enteredStageAt: row.entered_stage_at, | ||
} | ||
: undefined, | ||
}; | ||
entriesMap.set(row.feature_name, entry); | ||
orderedEntries.push(entry); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Getting worse: Large Method
createStores increases from 106 to 112 lines of code, threshold = 70
Suppress