yeg-relief / youcanbenefit

YouCanBenefit is a web application that increases social benefit program discoverability for people of lesser means and their allies.
https://youcanbenefit.edmonton.ca
MIT License
13 stars 9 forks source link

Program content and program queries are created/updated independently #117

Open CodyGramlich opened 5 years ago

CodyGramlich commented 5 years ago

In protected.controller.ts, these endpoints are not used (which were meant to create or update the program content and program queries together):

    @Post('/program/')
    createProgramWithQueries(
        @Body("user") user,
        @Body("application") application,
    ): any {
        return Observable.zip(
            this.programService.create(user),
            Observable.from(application)
                .mergeMap( (query: ApplicationQueryDto) => this.queryService.create(query))
                .catch(() => Observable.throw(false))
        )
            .map( ([{created}, queriesCreated]) => {
                return created === true && queriesCreated === true ? { created: true} : { created: false }
            })
    }
    @Put('/program/')
    updateProgramWithQueries(@Body() data: any): any {
        return Observable.zip(
            this.programService.index(data.user),
            Observable.from(data.application).mergeMap((query: ApplicationQueryDto) => this.queryService.index(query))
        )
            .map( ([userUpdated, queriesUpdated]) => {
                return userUpdated.created === true && queriesUpdated.created === true ? { updated: true} : { updated: false }
            })
    }

Only PUT protected/program-description/ is used for both creating a program and updating its content (excluding queries):

@Put('/program-description/')
    updateUserFacingProgram(@Body() data): Promise<any> {
        return this.programService.index(data)
    }

I was considering removing the POST protected/program/ and PUT protected/program/ endpoints, but I realized that issue #61 is caused by the program content and program queries being created or updated independently, and we still don't have a solution to this issue.