Skip to content

Commit

Permalink
adjust sync service
Browse files Browse the repository at this point in the history
  • Loading branch information
Janderson Souza Matias authored and Janderson Souza Matias committed Nov 22, 2023
1 parent 3b99400 commit fc5d443
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/modules/sync/controller/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type DataToSync = {

export type SyncData = {
coaches: Coach[];
competencies: Competence[];
coachSchools: CoachSchool[];
sessions: Session[];
questions: Question[];
Expand Down
6 changes: 5 additions & 1 deletion src/modules/sync/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Sync } from "../entity";
import { School } from "../../school/entity/school.entity";
import { Question } from "../../question/entity/question.entity";
import { CoachSchool } from "../../coach/entity/coach-school.entity";
import { CompetenceService } from "../../competencies/service";
import { QuestionService } from "../../question/service";

export class SyncService {
static findAll = async (): Promise<Teacher[]> => {
Expand Down Expand Up @@ -40,15 +42,17 @@ export class SyncService {
await this.saveSyncByEntity(Answer, changes.answers || []);
await this.saveSyncByEntity(Feedback, changes.feedbacks || []);

const questions = await this.getDataToSync(Question, lastSync);
const { coaches, coachSchools } = await this.getCoachDataToSync(school);
const teachers = await this.getDataToSync(Teacher, undefined, school);
const sessions = await this.getDataToSync(Session, lastSync, school);
const answers = await this.getAnswerToSync(sessions);
const feedbacks = await this.getFeedbackToSync(school, lastSync);
const competencies = await CompetenceService.findAll();
const questions = await QuestionService.findAll();

return {
coaches,
competencies,
coachSchools,
feedbacks,
questions,
Expand Down

0 comments on commit fc5d443

Please sign in to comment.