Skip to content

Commit cdb37cc

Browse files
Merge pull request #1885 from OneCommunityGlobal/adithya_impl_enhanced_role_analytics_backend
Adithya Enhanced popularity timeline Backend
2 parents a76f5eb + a8d6de6 commit cdb37cc

5 files changed

Lines changed: 498 additions & 10 deletions

File tree

package-lock.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/models/popularityEnhanced.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// src/models/popularityEnhanced.js
2+
const mongoose = require('mongoose');
3+
4+
/**
5+
* Enhanced Popularity Timeline Model
6+
* Description: Enhanced schema for role-based popularity analytics with improved indexing
7+
*/
8+
const PopularityEnhancedSchema = new mongoose.Schema(
9+
{
10+
month: {
11+
type: String,
12+
required: true,
13+
index: true,
14+
},
15+
hitsCount: {
16+
type: Number,
17+
required: true,
18+
default: 0,
19+
},
20+
applicationsCount: {
21+
type: Number,
22+
required: true,
23+
default: 0,
24+
},
25+
role: {
26+
type: String,
27+
required: true,
28+
index: true,
29+
},
30+
timestamp: {
31+
type: Date,
32+
default: Date.now,
33+
index: true,
34+
},
35+
// Enhanced fields for better analytics
36+
roleCategory: {
37+
type: String,
38+
default() {
39+
return this.role;
40+
},
41+
index: true,
42+
},
43+
dataSource: {
44+
type: String,
45+
default: 'job_posting',
46+
enum: ['job_posting', 'profile_view', 'other'],
47+
},
48+
isActive: {
49+
type: Boolean,
50+
default: true,
51+
},
52+
},
53+
{
54+
collection: 'popularityTimelineEnhanced',
55+
timestamps: true,
56+
},
57+
);
58+
59+
// Compound indexes for optimized queries
60+
PopularityEnhancedSchema.index({ timestamp: 1, role: 1 });
61+
PopularityEnhancedSchema.index({ role: 1, month: 1 });
62+
PopularityEnhancedSchema.index({ roleCategory: 1, timestamp: 1 });
63+
PopularityEnhancedSchema.index({ month: 1, role: 1, isActive: 1 });
64+
65+
module.exports = mongoose.model('PopularityEnhanced', PopularityEnhancedSchema);

0 commit comments

Comments
 (0)