Skip to content

Commit

Permalink
remove firebase getCourse
Browse files Browse the repository at this point in the history
  • Loading branch information
rwieruch committed Apr 8, 2020
1 parent 04782f8 commit 5ee0df7
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 59 deletions.
17 changes: 1 addition & 16 deletions src/api/resolvers/course/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { QueryResolvers, MutationResolvers } from '@generated/server';
import {
createCourse,
// getCoursesById,
} from '@services/firebase/course';
import { createCourse } from '@services/firebase/course';
import { mergeCourses } from '@services/course';

interface Resolvers {
Expand All @@ -17,12 +14,6 @@ export const resolvers: Resolvers = {
return [];
}

// LEGACY
// const courses = await getCoursesById(me?.uid);
// if (!courses) {
// return [];
// }

const courses = await courseConnector.getCoursesByUserId(
me.uid
);
Expand All @@ -46,12 +37,6 @@ export const resolvers: Resolvers = {
return null;
}

// LEGACY
// const courses = await getCoursesById(me?.uid);
// if (!courses) {
// return null;
// }

const courses = await courseConnector.getCoursesByUserIdAndCourseId(
me.uid,
courseId
Expand Down
7 changes: 0 additions & 7 deletions src/api/resolvers/upgrade/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { QueryResolvers } from '@generated/server';
// import { getCoursesById } from '@services/firebase/course';
import { getUpgradeableCourses } from '@services/course';

interface Resolvers {
Expand All @@ -22,12 +21,6 @@ export const resolvers: Resolvers = {
courseId
);

// LEGACY
// const courses = await getCoursesById(me?.uid);
// if (!courses) {
// return [];
// }

return getUpgradeableCourses(courseId, courses);
},
},
Expand Down
5 changes: 0 additions & 5 deletions src/services/course/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import omit from 'lodash.omit';

// import {
// FirebaseCourseContent,
// FirebaseCourse,
// } from '@services/firebase/course';

import { Course } from '@models/course';
import { COURSE } from '@data/course-keys';
import BUNDLE_LEGACY from '@data/bundle-legacy';
Expand Down
5 changes: 0 additions & 5 deletions src/services/discount/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import axios from 'axios';

import { COURSE } from '@data/course-keys';
import { BUNDLE } from '@data/bundle-keys';
// LEGACY
// import { getCoursesById } from '@services/firebase/course';
import { getUpgradeableCourses } from '@services/course';
import { Course } from '@models/course';

Expand Down Expand Up @@ -39,9 +37,6 @@ const tryUpgradeDiscount = async (
coupon: string,
uid: string
) => {
// LEGACY
//const courses = await getCoursesById(uid);

if (!courses) {
return price;
}
Expand Down
26 changes: 0 additions & 26 deletions src/services/firebase/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,3 @@ export const createCourse = async ({
coupon,
},
});

export type FirebaseCourseContent = {
courseId: COURSE;
packageId: BUNDLE;
invoice: {
amount: number;
createdAt: number;
currency: string;
licencesCount: number;
paymentType: string;
coupon: string;
};
};

export type FirebaseCourse = {
[key: string]: FirebaseCourseContent;
};

export const getCoursesById = async (
uid?: string
): Promise<FirebaseCourse> =>
await firebaseAdmin
.database()
.ref(`users/${uid}/courses`)
.once('value')
.then(snapshot => snapshot.val());

0 comments on commit 5ee0df7

Please sign in to comment.