social share up and running
This commit is contained in:
1 parent
000ebd388a
commit
b8779e5a35
22 files changed
+1935
-41
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Article } from '../entities';
|
||||
|
||||
export type SharePlatform =
|
||||
| 'facebook'
|
||||
| 'twitter'
|
||||
| 'whatsapp'
|
||||
| 'telegram'
|
||||
| 'link';
|
||||
|
||||
@Entity('share_events')
|
||||
export class ShareEvent {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
articleId: string;
|
||||
|
||||
@Column({ type: 'text' })
|
||||
platform: SharePlatform;
|
||||
|
||||
@Column({ nullable: true })
|
||||
userId: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
userAgent: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
ipAddress: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@ManyToOne(() => Article, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'articleId' })
|
||||
article: Article;
|
||||
}
|
||||
|
||||
export interface ShareStats {
|
||||
articleId: string;
|
||||
articleTitle: string;
|
||||
facebookShares: number;
|
||||
twitterShares: number;
|
||||
whatsappShares: number;
|
||||
telegramShares: number;
|
||||
linkShares: number;
|
||||
totalShares: number;
|
||||
views: number;
|
||||
shareRate: number;
|
||||
}
|
||||
Reference in new issue
Block a user