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

Feature: Experiment Archive State #987

Merged
merged 23 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
34b6e10
working archive feature frontend changes
ppratikcr7 Aug 14, 2023
38caaeb
ignoring storing logs for archived experiments
ppratikcr7 Aug 21, 2023
b056ac9
add few more missing readonly properties for archive state
ppratikcr7 Aug 24, 2023
e2954e1
missed readonly for archive state
ppratikcr7 Aug 24, 2023
62ea73c
Create API and database for archive
Aug 26, 2023
bd8b669
resolved failing test cases for archive state
ppratikcr7 Aug 28, 2023
5259dff
Merge branch 'dev' of https://github.com/CarnegieLearningWeb/UpGrade …
ppratikcr7 Aug 28, 2023
f72c420
import change
ppratikcr7 Aug 28, 2023
d0a7763
not allowing archived state change from enrolling state
ppratikcr7 Aug 31, 2023
fba94cf
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Aug 31, 2023
e8b9913
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Sep 1, 2023
3be74d6
merge analysis and archieve api
Sep 11, 2023
06fcd6c
added remaining file
Sep 11, 2023
8bce729
fix peer review comments for archive state
ppratikcr7 Sep 12, 2023
6ac950d
Merge branch 'dev' into feature/archive-status-backend-issue30
ppratikcr7 Sep 12, 2023
b4d1b23
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Sep 14, 2023
5aaf70b
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Sep 19, 2023
57e3198
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Sep 20, 2023
d1a2d82
Solve review comments
Sep 22, 2023
03bfe20
Merge branch 'dev' into feature/archive-status-backend-issue30
ppratikcr7 Sep 29, 2023
be8bb4f
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Oct 16, 2023
8e40d34
Merge branch 'dev' into feature/archive-status-backend-issue30
ppratikcr7 Oct 26, 2023
f13630a
Merge branch 'dev' into feature/archive-status-backend-issue30
danoswaltCL Oct 26, 2023
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
36 changes: 0 additions & 36 deletions backend/packages/Upgrade/src/api/controllers/QueryController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,4 @@ export class QueryController {
): Promise<any> {
return this.queryService.analyze(dataLogParams.queryIds, request.logger);
}

/**
* @swagger
* /query/archive:
* post:
* description: Data log analysis
* consumes:
* - application/json
* parameters:
* - in: body
* name: params
* required: true
* schema:
* type: object
* properties:
* queryIds:
* type: array
* items:
* type: string
* description: Data analysis
* tags:
* - Query
* produces:
* - application/json
* responses:
* '200':
* description: Get data analysis
*/
@Post('/archive')
public archive(
@Body()
dataLogParams: DataLogAnalysisValidator,
@Req() request: AppRequest
): Promise<any> {
return this.queryService.getArchivedStats(dataLogParams.queryIds, request.logger);
}
}
2 changes: 1 addition & 1 deletion backend/packages/Upgrade/src/api/models/ArchivedStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ArchivedStats extends BaseModel {

@IsNotEmpty()
@Column('jsonb')
public result: any;
public result: object;

@OneToOne(() => Query, (query) => query.archivedStats, { onDelete: 'CASCADE' })
@JoinColumn()
Expand Down
8 changes: 7 additions & 1 deletion backend/packages/Upgrade/src/api/services/QueryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { OrmRepository } from 'typeorm-typedi-extensions';
import { QueryRepository } from '../repositories/QueryRepository';
import { Query } from '../models/Query';
import { LogRepository } from '../repositories/LogRepository';
import { EXPERIMENT_TYPE, SERVER_ERROR } from 'upgrade_types';
import { EXPERIMENT_STATE, EXPERIMENT_TYPE, SERVER_ERROR } from 'upgrade_types';
import { ErrorService } from './ErrorService';
import { ExperimentError } from '../models/ExperimentError';
import { UpgradeLogger } from '../../lib/logger/UpgradeLogger';
Expand Down Expand Up @@ -66,6 +66,12 @@ export class QueryService {

const promiseResult = await Promise.all(promiseArray);
const experiments: Experiment[] = [];

// checks for archieve state experiment
if (promiseResult[0].experiment?.state === EXPERIMENT_STATE.ARCHIVED) {
return await this.getArchivedStats(queryIds, logger);
ppratikcr7 marked this conversation as resolved.
Show resolved Hide resolved
}

const analyzePromise = promiseResult.map((query) => {
experiments.push(query.experiment);
if (query.experiment?.type === EXPERIMENT_TYPE.FACTORIAL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,4 @@ export class AnalysisDataService {
const url = this.environment.api.queryResult;
return this.http.post(url, { queryIds });
}

archiveQuery(queryIds: string[]) {
const url = this.environment.api.archiveResult;
return this.http.post(url, { queryIds });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class AnalysisService {
this.store$.dispatch(AnalysisActions.actionDeleteMetric({ key }));
}

executeQuery(queryIds: string[], state?: EXPERIMENT_STATE) {
this.store$.dispatch(AnalysisActions.actionExecuteQuery({ queryIds, state }));
executeQuery(queryIds: string[]) {
this.store$.dispatch(AnalysisActions.actionExecuteQuery({ queryIds }));
}

setQueryResult(queryResult: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export const actionUpsertMetricsSuccess = createAction(

export const actionUpsertMetricsFailure = createAction('[Analysis] Upsert Metrics Failure');

export const actionExecuteQuery = createAction(
'[Analysis] Execute Query',
props<{ queryIds: string[]; state?: EXPERIMENT_STATE }>()
);
export const actionExecuteQuery = createAction('[Analysis] Execute Query', props<{ queryIds: string[] }>());

export const actionExecuteQuerySuccess = createAction(
'[Analysis] Execute Query Success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AnalysisDataService } from '../analysis.data.service';
import { Store, select } from '@ngrx/store';
import { AppState } from '../../core.state';
import { selectQueryResult } from './analysis.selectors';
import { EXPERIMENT_STATE } from '../../experiments/store/experiments.model';

@Injectable()
export class AnalysisEffects {
Expand Down Expand Up @@ -67,15 +66,11 @@ export class AnalysisEffects {
executeQuery$ = createEffect(() =>
this.actions$.pipe(
ofType(AnalysisActions.actionExecuteQuery),
map((action) => ({ queryIds: action.queryIds, state: action.state })),
filter(({ queryIds }) => !!queryIds.length),
map((action) => action.queryIds),
filter((queryIds) => !!queryIds.length),
withLatestFrom(this.store$.pipe(select(selectQueryResult))),
switchMap(([{ queryIds, state }, queryResult]) => {
const analysisData =
(state && state === EXPERIMENT_STATE.ARCHIVED)
? this.analysisDataService.archiveQuery(queryIds)
: this.analysisDataService.executeQuery(queryIds);
return analysisData.pipe(
switchMap(([queryIds, queryResult]) =>
this.analysisDataService.executeQuery(queryIds).pipe(
map((data: any) => {
let newResults = queryResult && queryResult.length ? queryResult : [];
if (data.length) {
Expand All @@ -91,8 +86,8 @@ export class AnalysisEffects {
return AnalysisActions.actionExecuteQuerySuccess({ queryResult: newResults });
}),
catchError(() => [AnalysisActions.actionExecuteQueryFailure()])
);
})
)
)
)
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector, createFeatureSelector } from '@ngrx/store';
import { AnalysisState, State } from './analysis.models';
import { AnalysisState } from './analysis.models';

export const selectAnalysisState = createFeatureSelector<AnalysisState>('analysis');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ export class ExperimentEffects {
experimentAction.actionFetchExperimentStatsSuccess({ stats }),
experimentAction.actionUpsertExperimentSuccess({ experiment: data }),
experimentAction.actionFetchAllDecisionPoints(),
analysisAction.actionExecuteQuery({
queryIds,
state: data.state,
}),
analysisAction.actionExecuteQuery({ queryIds }),
];
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class ExperimentListComponent implements OnInit, OnDestroy, AfterViewInit
searchControl = new FormControl();

get filteredStatusOptions(): string[] {
if (this.searchValue !== undefined) {
if (typeof this.searchValue === 'string') {
const filterValue = this.searchValue.toLowerCase();
return this.statusFilterOptions.filter((option) => option.toLowerCase().includes(filterValue));
} else {
Expand Down Expand Up @@ -144,7 +144,7 @@ export class ExperimentListComponent implements OnInit, OnDestroy, AfterViewInit

applyFilter(filterValue: string) {
this.filterExperimentPredicate(this.selectedExperimentFilterOption);
if (filterValue !== undefined) {
if (typeof filterValue === 'string') {
if (this.selectedExperimentFilterOption === EXPERIMENT_SEARCH_KEY.STATUS) {
this.allExperiments.filter = filterValue.trim().toLowerCase();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class ExperimentQueryResultComponent implements OnInit, OnDestroy {
ngOnInit() {
const queryIds = [];
this.experimentType = this.experiment.type;
this.experimentState = this.experiment.state

if (this.experimentType === EXPERIMENT_TYPE.FACTORIAL) {
this.setMaxLevelsCount();
Expand All @@ -101,7 +100,7 @@ export class ExperimentQueryResultComponent implements OnInit, OnDestroy {
[query.id]: [],
};
});
this.analysisService.executeQuery(queryIds, this.experimentState);
this.analysisService.executeQuery(queryIds);
this.queryResultsSub = this.analysisService.queryResult$.pipe(filter((result) => !!result)).subscribe((result) => {
// main effect graph data
this.populateMainEffectGraphData(result);
Expand Down
2 changes: 1 addition & 1 deletion frontend/projects/upgrade/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"home.change-experiment-status.enrolling-info.text": "*Once the experiment is started you won’t be allowed to update Experiment’s Condition and Sites",
"home.change-experiment-status.enrolling-error.text": "*Experiment start date should not be greater than experiment end date {{ endDate }}",
"home.change-experiment-status.condition-count-error.text": "*Please have at least 2 conditions to move forward",
"home.change-experiment-status.archiving-confirmation.text": "Please acknowledge that you agree to permanently transition this experiment to archive status",
"home.change-experiment-status.archiving-confirmation.text": "Please acknowledge that you agree to permanently transition this experiment to archive status.",
"home.change-experiment-status.archiving-info.text": "*Archiving the experiment will cancel the post rule. The archived experiments are hidden from the experiment list and can be found by explicitly searching for 'Archived' experiments.",
"home.change-post-experiment-rule.title.text": "Change Post Experiment Condition",
"logs-global.log-zero-state.text": "No Logs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface APIEndpoints {
metrics: string;
metricsSave: string;
queryResult: string;
archiveResult: string;
getVersion: string;
contextMetaData: string;
segments: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const environment = {
metrics: '/metric',
metricsSave: '/metric/save',
queryResult: '/query/analyse',
archiveResult: '/query/archive',
getVersion: '/version',
contextMetaData: '/experiments/contextMetaData',
segments: '/segments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const environment = {
metrics: '/metric',
metricsSave: '/metric/save',
queryResult: '/query/analyse',
archiveResult: '/query/archive',
getVersion: '/version',
contextMetaData: '/experiments/contextMetaData',
segments: '/segments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const environment = {
metrics: '/metric',
metricsSave: '/metric/save',
queryResult: '/query/analyse',
archiveResult: '/query/archive',
getVersion: '/version',
contextMetaData: '/experiments/contextMetaData',
segments: '/segments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const environment = {
metrics: '/metric',
metricsSave: '/metric/save',
queryResult: '/query/analyse',
archiveResult: '/query/archive',
getVersion: '/version',
contextMetaData: '/experiments/contextMetaData',
segments: '/segments',
Expand Down
1 change: 0 additions & 1 deletion frontend/projects/upgrade/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const environment = {
metrics: '/metric',
metricsSave: '/metric/save',
queryResult: '/query/analyse',
archiveResult: '/query/archive',
getVersion: '/version',
contextMetaData: '/experiments/contextMetaData',
segments: '/segments',
Expand Down