mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 08:35:17 +00:00
Export all responses of user to surveys
This commit is contained in:
@ -9,6 +9,7 @@ import { UserController } from "./UserController";
|
||||
import { PostsController } from "./PostsController";
|
||||
import { CommentsController } from "./CommentsController";
|
||||
import { LikesController } from "./LikesController";
|
||||
import { SurveyController } from "./SurveyController";
|
||||
|
||||
/**
|
||||
* Account controller
|
||||
@ -240,7 +241,10 @@ export class AccountController {
|
||||
comments: await CommentsController.CommentsToAPI(h, data.comments),
|
||||
|
||||
// User likes
|
||||
likes: data.likes.map(LikesController.UserLikeToAPI)
|
||||
likes: data.likes.map(LikesController.UserLikeToAPI),
|
||||
|
||||
// Responses to surveys
|
||||
survey_responses: data.surveyResponses.map(SurveyController.SurveyResponseToAPI)
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Survey, SurveyChoice } from "../entities/Survey";
|
||||
import { RequestHandler } from "../entities/RequestHandler";
|
||||
import { SurveyHelper } from "../helpers/SurveyHelper";
|
||||
import { SurveyResponse } from "../entities/SurveyResponse";
|
||||
|
||||
/**
|
||||
* Survey controller
|
||||
@ -92,4 +93,19 @@ export class SurveyController {
|
||||
responses: c.count
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a {SurveyResponse} object into an API entry
|
||||
*
|
||||
* @param r The survey response
|
||||
*/
|
||||
public static SurveyResponseToAPI(r: SurveyResponse) : any {
|
||||
return {
|
||||
id: r.id,
|
||||
time_sent: r.timeSent,
|
||||
userID: r.userID,
|
||||
surveyID: r.surveyID,
|
||||
choiceID: r.choiceID
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user