-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip/ improve types, add profile model, repository add TODO
- Loading branch information
Showing
9 changed files
with
134 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,65 @@ | ||
import { getModelForClass } from "@typegoose/typegoose"; | ||
import { getModelForClass, modelOptions, prop } from "@typegoose/typegoose"; | ||
|
||
class ProfileDto {} | ||
// TODO: for instagram and twitter, all post from user account are in the profile response | ||
// TODO: potentiellement créer un moniteur pour pouvoir suivre l'évolution des followers, posts, etc | ||
@modelOptions({ | ||
options: { | ||
customName: "profile", | ||
}, | ||
}) | ||
export class ProfileDto { | ||
@prop() | ||
public id!: string; | ||
|
||
@prop() | ||
public profile_url!: string; | ||
|
||
// Only for instagram | ||
@prop() | ||
public is_business_account?: boolean; | ||
|
||
// Only for instagram | ||
@prop() | ||
public is_professional_account?: boolean; | ||
|
||
@prop() | ||
public followers!: number; | ||
|
||
@prop() | ||
public is_verified!: boolean; | ||
|
||
// TODO: a voir ce que cela représente | ||
@prop() | ||
public avg_engagement?: number; | ||
|
||
// only for instagram | ||
@prop({ type: () => [String] }) | ||
public external_url?: string[]; | ||
|
||
// only for instagram | ||
@prop() | ||
public business_category_name?: string; | ||
|
||
@prop() | ||
public biography!: string; | ||
|
||
@prop() | ||
public following!: number; | ||
|
||
@prop() | ||
public full_name?: string; | ||
|
||
@prop() | ||
public is_private!: boolean; | ||
|
||
// Only for twitter | ||
// TODO: find a way to get it from instagram profile | ||
@prop() | ||
public profile_image_link?: string; | ||
|
||
// Only for twitter | ||
@prop() | ||
public date_joined?: Date; | ||
} | ||
|
||
export const ProfileModel = getModelForClass(ProfileDto); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { bind } from "@decorators/bind.decorator"; | ||
import { IInstagramProfile } from "@interfaces/instagram.interface"; | ||
import { ProfileDto, ProfileModel } from "@models/profile.model"; | ||
import { injectable } from "inversify"; | ||
|
||
@bind() | ||
@injectable() | ||
export class ProfileRepository { | ||
public async createInstagramProfile( | ||
profiles: IInstagramProfile[] | ||
): Promise<any> { | ||
const formattedProfiles: ProfileDto[] = profiles.map((profile) => ({ | ||
id: profile.id, | ||
profile_url: profile.profile_url, | ||
is_business_account: profile.is_business_account, | ||
is_professional_account: profile.is_professional_account, | ||
followers: profile.followers, | ||
is_verified: profile.is_verified, | ||
avg_engagement: profile.avg_engagement, | ||
external_url: profile.external_url, | ||
business_category_name: profile.business_category_name, | ||
biography: profile.biography, | ||
following: profile.following, | ||
full_name: profile.full_name, | ||
is_private: profile.is_private, | ||
})); | ||
|
||
return ProfileModel.insertMany(formattedProfiles); | ||
} | ||
} |