This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(socialStats): #56 Added social Stats model and fixed autogenerat…
…ion issue of user social connection
- Loading branch information
Venkatesh
committed
May 17, 2019
1 parent
5aa2865
commit e324e35
Showing
7 changed files
with
133 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface SocialStatsHistory { | ||
provider: string; | ||
userId: string; | ||
followers: number; | ||
following: number; | ||
repos?: number; | ||
tweets?: number; | ||
createdAt: string; | ||
} |
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,8 +1,28 @@ | ||
import { Social } from './social.model'; | ||
|
||
export interface UserSocial { | ||
github?: Social; | ||
twitter?: Social; | ||
youtube?: Social; | ||
instagram?: Social; | ||
github?: { | ||
updatedAt: string, | ||
followers: number, | ||
following: number, | ||
userId: string, | ||
}; | ||
twitter?: { | ||
updatedAt: string, | ||
followers: number, | ||
following: number, | ||
userId: string, | ||
}; | ||
youtube?: { | ||
updatedAt: string, | ||
followers: number, | ||
following: number, | ||
userId: string, | ||
}; | ||
instagram?: { | ||
updatedAt: string, | ||
followers: number, | ||
following: number, | ||
userId: string, | ||
}; | ||
} |
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,32 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
AngularFirestore, | ||
AngularFirestoreCollection, | ||
} from 'angularfire2/firestore'; | ||
import { SocialStatsHistory } from '../models/socialStatsHistory'; | ||
import { Observable, from } from 'rxjs'; | ||
import { catchError, map } from 'rxjs/operators'; | ||
import { ErrorService } from './error.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SocialStatsService { | ||
|
||
public socialStatsHistory: AngularFirestoreCollection; | ||
|
||
constructor( | ||
private db: AngularFirestore, | ||
private errorService: ErrorService, | ||
) { | ||
this.socialStatsHistory = this.db.collection('socialStatsHistory'); | ||
} | ||
|
||
createSocialStats(socialStat: SocialStatsHistory): Observable<SocialStatsHistory> { | ||
return from(this.socialStatsHistory.add(socialStat)) | ||
.pipe( | ||
map(res => res), | ||
catchError(error => this.errorService.logError(error)) | ||
); | ||
} | ||
} |
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