Abdul Rehman
commited on
Commit
·
e1a5ce8
1
Parent(s):
644d830
new events
Browse files
package-lock.json
CHANGED
@@ -26,7 +26,8 @@
|
|
26 |
"passport-jwt": "^4.0.1",
|
27 |
"passport-local": "^1.0.0",
|
28 |
"reflect-metadata": "^0.2.0",
|
29 |
-
"rxjs": "^7.8.1"
|
|
|
30 |
},
|
31 |
"devDependencies": {
|
32 |
"@nestjs/cli": "^10.0.0",
|
@@ -9630,6 +9631,19 @@
|
|
9630 |
"node": ">= 0.4.0"
|
9631 |
}
|
9632 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9633 |
"node_modules/v8-compile-cache-lib": {
|
9634 |
"version": "3.0.1",
|
9635 |
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
|
|
26 |
"passport-jwt": "^4.0.1",
|
27 |
"passport-local": "^1.0.0",
|
28 |
"reflect-metadata": "^0.2.0",
|
29 |
+
"rxjs": "^7.8.1",
|
30 |
+
"uuid": "^10.0.0"
|
31 |
},
|
32 |
"devDependencies": {
|
33 |
"@nestjs/cli": "^10.0.0",
|
|
|
9631 |
"node": ">= 0.4.0"
|
9632 |
}
|
9633 |
},
|
9634 |
+
"node_modules/uuid": {
|
9635 |
+
"version": "10.0.0",
|
9636 |
+
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
|
9637 |
+
"integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
|
9638 |
+
"funding": [
|
9639 |
+
"https://github.com/sponsors/broofa",
|
9640 |
+
"https://github.com/sponsors/ctavan"
|
9641 |
+
],
|
9642 |
+
"license": "MIT",
|
9643 |
+
"bin": {
|
9644 |
+
"uuid": "dist/bin/uuid"
|
9645 |
+
}
|
9646 |
+
},
|
9647 |
"node_modules/v8-compile-cache-lib": {
|
9648 |
"version": "3.0.1",
|
9649 |
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
package.json
CHANGED
@@ -37,7 +37,8 @@
|
|
37 |
"passport-jwt": "^4.0.1",
|
38 |
"passport-local": "^1.0.0",
|
39 |
"reflect-metadata": "^0.2.0",
|
40 |
-
"rxjs": "^7.8.1"
|
|
|
41 |
},
|
42 |
"devDependencies": {
|
43 |
"@nestjs/cli": "^10.0.0",
|
|
|
37 |
"passport-jwt": "^4.0.1",
|
38 |
"passport-local": "^1.0.0",
|
39 |
"reflect-metadata": "^0.2.0",
|
40 |
+
"rxjs": "^7.8.1",
|
41 |
+
"uuid": "^10.0.0"
|
42 |
},
|
43 |
"devDependencies": {
|
44 |
"@nestjs/cli": "^10.0.0",
|
src/modules/activity/activity.controller.ts
CHANGED
@@ -26,14 +26,14 @@ export class ActivityController extends CommonServices {
|
|
26 |
}
|
27 |
|
28 |
@Post('create')
|
29 |
-
@UseGuards(JwtAuthGuard)
|
30 |
async createActivity(@Body() body: any, @Res() res: Response, @Req() req) {
|
31 |
try {
|
32 |
-
const payload = {
|
33 |
-
|
34 |
-
|
35 |
-
};
|
36 |
-
const activity = await this.activityService.sharedCreate(
|
37 |
|
38 |
// update views
|
39 |
if (body.action == 'view')
|
|
|
26 |
}
|
27 |
|
28 |
@Post('create')
|
29 |
+
// @UseGuards(JwtAuthGuard)
|
30 |
async createActivity(@Body() body: any, @Res() res: Response, @Req() req) {
|
31 |
try {
|
32 |
+
// const payload = {
|
33 |
+
// ...body,
|
34 |
+
// userId: req.user.userId,
|
35 |
+
// };
|
36 |
+
const activity = await this.activityService.sharedCreate(body);
|
37 |
|
38 |
// update views
|
39 |
if (body.action == 'view')
|
src/modules/activity/activity.schema.ts
CHANGED
@@ -4,26 +4,30 @@ import { IUserDocument } from '../user/user.schema';
|
|
4 |
import { IPropertyDocument } from '../property/property.schema';
|
5 |
|
6 |
export interface IUserActivityDocument extends Document {
|
7 |
-
userId: IUserDocument;
|
8 |
propertyId: IPropertyDocument;
|
9 |
action: string; // E.g., 'click', 'view', 'time_spent'
|
|
|
10 |
timestamp: Date;
|
11 |
duration?: number; // Store time spent in seconds for 'time_spent' action
|
|
|
12 |
}
|
13 |
|
14 |
const UserActivitySchema = new mongoose.Schema<IUserActivityDocument>(
|
15 |
{
|
16 |
-
userId: {
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
},
|
21 |
propertyId: {
|
22 |
type: mongoose.Schema.Types.ObjectId,
|
23 |
ref: 'propertie',
|
24 |
-
required: true,
|
25 |
},
|
26 |
action: { type: String, required: true }, // 'click', 'view', 'time_spent'
|
|
|
|
|
27 |
timestamp: { type: Date, default: Date.now },
|
28 |
duration: { type: Number }, // Only applicable for 'time_spent'
|
29 |
},
|
|
|
4 |
import { IPropertyDocument } from '../property/property.schema';
|
5 |
|
6 |
export interface IUserActivityDocument extends Document {
|
7 |
+
// userId: IUserDocument;
|
8 |
propertyId: IPropertyDocument;
|
9 |
action: string; // E.g., 'click', 'view', 'time_spent'
|
10 |
+
sessionId: string; // E.g., 'click', 'view', 'time_spent'
|
11 |
timestamp: Date;
|
12 |
duration?: number; // Store time spent in seconds for 'time_spent' action
|
13 |
+
searchQuery?: string;
|
14 |
}
|
15 |
|
16 |
const UserActivitySchema = new mongoose.Schema<IUserActivityDocument>(
|
17 |
{
|
18 |
+
// userId: {
|
19 |
+
// type: mongoose.Schema.Types.ObjectId,
|
20 |
+
// ref: 'User',
|
21 |
+
// required: true,
|
22 |
+
// },
|
23 |
propertyId: {
|
24 |
type: mongoose.Schema.Types.ObjectId,
|
25 |
ref: 'propertie',
|
26 |
+
// required: true,
|
27 |
},
|
28 |
action: { type: String, required: true }, // 'click', 'view', 'time_spent'
|
29 |
+
sessionId: { type: String, required: true },
|
30 |
+
searchQuery: { type: String },
|
31 |
timestamp: { type: Date, default: Date.now },
|
32 |
duration: { type: Number }, // Only applicable for 'time_spent'
|
33 |
},
|
src/modules/database/database.provider.ts
CHANGED
@@ -9,4 +9,4 @@ export const databaseProviders = [
|
|
9 |
'mongodb+srv://rehmanwahlah248:[email protected]/property-listing?retryWrites=true&w=majority',
|
10 |
),
|
11 |
},
|
12 |
-
];
|
|
|
9 |
'mongodb+srv://rehmanwahlah248:[email protected]/property-listing?retryWrites=true&w=majority',
|
10 |
),
|
11 |
},
|
12 |
+
];
|
src/modules/property/property.controller.ts
CHANGED
@@ -12,6 +12,7 @@ import {
|
|
12 |
import { Response } from 'express';
|
13 |
import { CommonServices } from '../shared/common.service';
|
14 |
import { PropertyService } from './property.service';
|
|
|
15 |
|
16 |
@Controller('property')
|
17 |
export class PropertyController extends CommonServices {
|
@@ -77,8 +78,9 @@ export class PropertyController extends CommonServices {
|
|
77 |
const page = Number(query.page);
|
78 |
const resPerPage = query.resPerPage ? Number(query.resPerPage) : 20;
|
79 |
const search = query.search || ''; // Default to empty search if not provided
|
|
|
80 |
|
81 |
-
|
82 |
|
83 |
const listings = await this.propertyService.propertyLisitng(
|
84 |
page,
|
@@ -86,7 +88,12 @@ export class PropertyController extends CommonServices {
|
|
86 |
search,
|
87 |
);
|
88 |
|
89 |
-
this.sendResponse(
|
|
|
|
|
|
|
|
|
|
|
90 |
} catch (error) {
|
91 |
console.error('error', error);
|
92 |
this.sendResponse(
|
|
|
12 |
import { Response } from 'express';
|
13 |
import { CommonServices } from '../shared/common.service';
|
14 |
import { PropertyService } from './property.service';
|
15 |
+
import { v4 as uuidv4 } from 'uuid';
|
16 |
|
17 |
@Controller('property')
|
18 |
export class PropertyController extends CommonServices {
|
|
|
78 |
const page = Number(query.page);
|
79 |
const resPerPage = query.resPerPage ? Number(query.resPerPage) : 20;
|
80 |
const search = query.search || ''; // Default to empty search if not provided
|
81 |
+
let sessionId = null;
|
82 |
|
83 |
+
if (!query.sessionId) sessionId = uuidv4();
|
84 |
|
85 |
const listings = await this.propertyService.propertyLisitng(
|
86 |
page,
|
|
|
88 |
search,
|
89 |
);
|
90 |
|
91 |
+
this.sendResponse(
|
92 |
+
this.messages.Success,
|
93 |
+
{ listings, sessionId: sessionId },
|
94 |
+
HttpStatus.OK,
|
95 |
+
res,
|
96 |
+
);
|
97 |
} catch (error) {
|
98 |
console.error('error', error);
|
99 |
this.sendResponse(
|