-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.js
More file actions
933 lines (656 loc) · 26.9 KB
/
functions.js
File metadata and controls
933 lines (656 loc) · 26.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
// async function insertData() {
// try {
// // Insert each user data into MongoDB
// for (const user of userData) {
// await IndianEmployer.create(user);
// console.log(`User "${user.companyname}" inserted into MongoDB.`);
// }
// console.log("Data insertion completed.");
// } catch (error) {
// console.error("Error inserting data:", error);
// } finally {
// // Disconnect from MongoDB
// }
// }
// // Run the function to insert data
// insertData();
import http from 'http';
import express from 'express';
import cors from 'cors';
import { Server } from 'socket.io';
import IndianEmployer from './models/IndianEmployer.js'
import mongoose from 'mongoose';
import userData from "./userData.js"; // Replace with the correct path to your userData file
import JobsModel from './models/jobs.js'
import SeekerModel from "./models/User.js";
import userRoutes from './router/user.js'
import { saveIndianEmployerData } from './contontrollers/dailyupdate.js';
mongoose.connect("mongodb+srv://sih202227:[email protected]/?retryWrites=true&w=majority",{useNewUrlParser: true, useUnifiedTopology: true})
// import SeekerModel from "./models/User.js";
// // // // // Function to generate a random number between min and max (inclusive)
// const getRandomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
// mongoose.connection.on('error',err=>{
// console.log('connection failed');
// });
// mongoose.connection.on('connected',()=>{
// console.log('connected successfully with database');
// })
// // Function to generate random Seeker data
// const generateRandomSeeker = (i) => {
// return {
// name: `User${i + 1}`,
// age: getRandomNumber(20, 35).toString(),
// email: `user${i + 1}@example.com`,
// state: "Punjab",
// location: cities[getRandomNumber(0, cities.length - 1)],
// sex: i % 2 === 0 ? "Male" : "Female",
// education: educationLevels[getRandomNumber(0, educationLevels.length - 1)].value,
// course: coursesArray[getRandomNumber(0, coursesArray.length - 1)],
// maritialstatus: i % 2 === 0 ? "Single" : "Married",
// skills: [
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// ],
// intrest: [
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// ],
// componenttime: [],
// phoneno: "1234567890",
// password: "password123",
// };
// };
// // // Create 300 users
// // (async () => {
// // for (let i = 0; i < 300; i++) {
// // const seekerData = generateRandomSeeker(i);
// // try {
// // const user = await SeekerModel.create(seekerData);
// // console.log(`User "${user.name}" created successfully.`);
// // } catch (err) {
// // console.error(`Error creating user: ${err}`);
// // }
// // }
// // })();
const collectionName = 'users';
const db = mongoose.connection;
db.on('error', (error) => {
console.error('MongoDB connection error:', error);
});
db.once('open', async () => {
console.log('Connected to the database');
try {
// Clear the collection
const result = await mongoose.connection.db.collection(collectionName).deleteMany({});
console.log(`Deleted ${result.deletedCount} documents from the ${collectionName} collection`);
} catch (error) {
console.error('Error clearing collection:', error);
} finally {
mongoose.connection.close();
console.log('Connection closed');
}
});
// const educationLevels = [
// { value: '10', label: 'No Schooling' },
// { value: '1', label: '5th' },
// { value: '2', label: '8th' },
// { value: '3', label: '10th' },
// { value: '4', label: '12th' },
// { value: '5', label: 'Diploma After 10th' },
// { value: '6', label: 'Diploma After 12th' },
// { value: '11', label: 'ITI' },
// { value: '7', label: 'Graduate' },
// { value: '12', label: 'PG Diploma' },
// { value: '8', label: 'Post Graduate' },
// { value: '13', label: 'M Phill' },
// { value: '9', label: 'Phd' },
// ];
// const skillsArray = [
// "JavaScript",
// "React",
// "Node.js",
// "Python",
// "Java",
// "C++",
// "HTML",
// "CSS",
// "SQL",
// "Angular",
// "Vue.js",
// "Express",
// "MongoDB",
// ];
// const interestsArray = [
// "Coding",
// "Reading",
// "Traveling",
// "Gaming",
// "Music",
// "Cooking",
// "Fitness",
// "Photography",
// "Art",
// ];
// const coursesArray = [
// "Computer Science",
// "Electrical Engineering",
// "Mechanical Engineering",
// "Physics",
// "Mathematics",
// "Biology",
// "Chemistry",
// "Psychology",
// "Business Administration",
// "Economics",
// // Add more courses as needed
// ];
// const cities = [
// "Amritsar",
// "Ludhiana",
// "Jalandhar",
// "Patiala",
// "Bathinda",
// "Hoshiarpur",
// "Pathankot",
// "Mohali",
// "Batala",
// "Moga",
// "Sangrur",
// "Firozpur",
// "Kapurthala",
// "Fazilka",
// "Mansa",
// "Gurdaspur",
// "Rupnagar",
// "Faridkot",
// "Fatehgarh Sahib",
// "Tarn Taran",
// ];
// function getRandomIndianState() {
// const indianStatesArray = [
// "Andhra Pradesh", "Arunachal Pradesh", "Assam", "Bihar", "Chhattisgarh",
// "Goa", "Gujarat", "Haryana", "Himachal Pradesh", "Jharkhand",
// "Karnataka", "Kerala", "Madhya Pradesh", "Maharashtra", "Manipur",
// "Meghalaya", "Mizoram", "Nagaland", "Odisha", "Punjab",
// "Rajasthan", "Sikkim", "Tamil Nadu", "Telangana", "Tripura",
// "Uttar Pradesh", "Uttarakhand", "West Bengal", "Andaman and Nicobar Islands", "Chandigarh",
// "Dadra and Nagar Haveli and Daman and Diu", "Lakshadweep", "Delhi", "Puducherry"
// ];
// // Generate a random index
// const randomIndex = Math.floor(Math.random() * indianStatesArray.length);
// // Return the random state
// return indianStatesArray[randomIndex];
// }
// const jobTitles = [
// "Software Engineer",
// "Data Analyst",
// "Marketing Specialist",
// "Graphic Designer",
// "Financial Analyst",
// "Human Resources Manager",
// "Customer Service Representative",
// "Sales Executive",
// "Web Developer",
// "Project Manager",
// "UX/UI Designer",
// "Quality Assurance Engineer",
// "Content Writer",
// "Business Development Manager",
// "IT Support Specialist",
// "Digital Marketing Manager",
// "Network Administrator",
// "Mobile App Developer",
// "Product Manager",
// "Data Scientist",
// "Front-end Developer",
// "Back-end Developer",
// "DevOps Engineer",
// "Technical Support Specialist",
// "Social Media Manager",
// "E-commerce Specialist",
// "Cybersecurity Analyst",
// "UI/UX Developer",
// "Cloud Solutions Architect",
// ];
// const citiesByState = {
// "Andhra Pradesh": ["Vijayawada", "Visakhapatnam", "Tirupati", "Guntur", "Nellore"],
// "Arunachal Pradesh": ["Itanagar", "Naharlagun", "Pasighat", "Namsai", "Roing"],
// "Assam": ["Guwahati", "Silchar", "Dibrugarh", "Jorhat", "Tezpur"],
// "Bihar": ["Patna", "Gaya", "Bhagalpur", "Muzaffarpur", "Darbhanga"],
// "Chhattisgarh": ["Raipur", "Bilaspur", "Bhilai", "Korba", "Durg"],
// "Goa": ["Panaji", "Margao", "Vasco da Gama", "Mapusa", "Ponda"],
// "Gujarat": ["Ahmedabad", "Surat", "Vadodara", "Rajkot", "Gandhinagar"],
// "Haryana": ["Chandigarh", "Faridabad", "Gurgaon", "Hisar", "Panipat"],
// "Himachal Pradesh": ["Shimla", "Mandi", "Dharamshala", "Solan", "Kullu"],
// "Jharkhand": ["Ranchi", "Jamshedpur", "Dhanbad", "Bokaro", "Hazaribagh"],
// "Karnataka": ["Bangalore", "Mysore", "Hubli", "Mangalore", "Belgaum"],
// "Kerala": ["Thiruvananthapuram", "Kochi", "Kozhikode", "Thrissur", "Kollam"],
// "Madhya Pradesh": ["Bhopal", "Indore", "Jabalpur", "Gwalior", "Ujjain"],
// "Maharashtra": ["Mumbai", "Pune", "Nagpur", "Thane", "Nashik"],
// "Manipur": ["Imphal", "Thoubal", "Churachandpur", "Bishnupur", "Kakching"],
// "Meghalaya": ["Shillong", "Tura", "Jowai", "Nongpoh", "Baghmara"],
// "Mizoram": ["Aizawl", "Lunglei", "Saiha", "Champhai", "Kolasib"],
// "Nagaland": ["Kohima", "Dimapur", "Mokokchung", "Tuensang", "Wokha"],
// "Odisha": ["Bhubaneswar", "Cuttack", "Rourkela", "Berhampur", "Sambalpur"],
// "Punjab": ["Chandigarh", "Ludhiana", "Amritsar", "Jalandhar", "Patiala"],
// "Rajasthan": ["Jaipur", "Udaipur", "Jodhpur", "Ajmer", "Kota"],
// "Sikkim": ["Gangtok", "Namchi", "Mangan", "Rangpo", "Singtam"],
// "Tamil Nadu": ["Chennai", "Coimbatore", "Madurai", "Tiruchirappalli", "Salem"],
// "Telangana": ["Hyderabad", "Warangal", "Nizamabad", "Karimnagar", "Khammam"],
// "Tripura": ["Agartala", "Udaipur", "Dharmanagar", "Kailasahar", "Belonia"],
// "Uttar Pradesh": ["Lucknow", "Kanpur", "Agra", "Varanasi", "Meerut"],
// "Uttarakhand": ["Dehradun", "Haridwar", "Rishikesh", "Nainital", "Almora"],
// "West Bengal": ["Kolkata", "Howrah", "Durgapur", "Asansol", "Siliguri"],
// "Andaman and Nicobar Islands": ["Port Blair", "Diglipur", "Mayabunder", "Rangat", "Little Andaman"],
// "Chandigarh": ["Chandigarh"],
// "Dadra and Nagar Haveli and Daman and Diu": ["Daman", "Diu", "Dadra", "Nagar Haveli"],
// "Lakshadweep": ["Kavaratti", "Agatti", "Amini", "Andrott", "Minicoy"],
// "Delhi": ["New Delhi", "North Delhi", "South Delhi", "East Delhi", "West Delhi"],
// "Puducherry": ["Puducherry", "Karaikal", "Mahe", "Yanam"],
// };
// function getRandomType() {
// const types = ["govt", "pvt"];
// const randomIndex = Math.floor(Math.random() * types.length);
// return types[randomIndex];
// }
// function getRandomCitiesForState(state, minCities = 1, maxCities = 1) {
// const cities = citiesByState[state] || [];
// const numberOfCities = getRandomNumber(minCities, Math.min(maxCities, cities.length));
// // Shuffle the array to get random cities
// const shuffledCities = cities.sort(() => Math.random() - 0.5);
// return shuffledCities[0];
// }
// const jobDescriptions = [
// "We are seeking a talented Software Engineer to join our dynamic team. Contribute to the development of cutting-edge software solutions.",
// "Join our team as a Data Analyst and contribute to data-driven decision-making. Analyze and interpret complex data sets.",
// "Exciting opportunity for a Marketing Specialist to drive brand awareness. Develop and implement effective marketing strategies.",
// "Creative Graphic Designer needed to produce stunning visual content. Bring artistic and innovative ideas to the table.",
// "Financial Analyst position available for a detail-oriented professional. Analyze financial data and provide valuable insights.",
// "Manage human resources functions as a Human Resources Manager. Ensure a positive and productive workplace environment.",
// "Customer Service Representative wanted to provide exceptional support. Assist customers with inquiries and problem resolution.",
// "Sales Executive role available for a motivated and results-driven individual. Identify and pursue new business opportunities.",
// "Web Developer position for someone passionate about web technologies. Design and implement web applications with the latest tools.",
// "Project Manager needed to lead and execute key projects. Ensure successful project delivery on time and within budget.",
// "UX/UI Designer role for creating intuitive and visually appealing user experiences. Work on enhancing user interface designs.",
// "Quality Assurance Engineer responsible for ensuring software quality through testing and debugging.",
// "Content Writer position available to create engaging and informative content across various platforms.",
// "Business Development Manager to identify new business opportunities and build strategic partnerships.",
// "IT Support Specialist to provide technical support and troubleshooting for IT-related issues.",
// "Digital Marketing Manager to lead digital marketing campaigns and optimize online presence.",
// "Network Administrator responsible for managing and maintaining computer networks.",
// "Mobile App Developer to design and develop mobile applications for iOS and Android platforms.",
// "Product Manager to oversee the entire product development lifecycle and drive product strategy.",
// "Data Scientist to analyze and interpret complex data sets to inform business decisions.",
// "Front-end Developer to create visually appealing and responsive user interfaces.",
// "Back-end Developer to develop server-side logic and integrate user-facing elements.",
// "DevOps Engineer to improve and streamline the development and deployment processes.",
// "Technical Support Specialist to provide technical assistance and support to end-users.",
// "Social Media Manager to develop and implement social media strategies to increase brand awareness.",
// "E-commerce Specialist to manage and optimize e-commerce platforms and online sales.",
// "Cybersecurity Analyst to protect computer systems and networks from cybersecurity threats.",
// "UI/UX Developer to combine design principles with programming skills for a seamless user experience.",
// "Cloud Solutions Architect to design and implement scalable and secure cloud solutions.",
// ];
// const getRandomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
// const getRandomTitleAndDescription = (jobTitles, jobDescriptions) => {
// const randomIndex = getRandomNumber(0, jobTitles.length - 1);
// return {
// title: jobTitles[randomIndex],
// description: jobDescriptions[randomIndex],
// };
// };
// const generateRandomSeeker = (i) => {
// const state=getRandomIndianState();
// console.log(state)
// return {
// name: `User${i + 1}`,
// age: getRandomNumber(20, 35).toString(),
// email: `user${i + 1}@example.com`,
// state: state,
// location:getRandomCitiesForState(state),
// sex: i % 2 === 0 ? "Male" : "Female",
// education: educationLevels[getRandomNumber(0, educationLevels.length - 1)].label,
// course: coursesArray[getRandomNumber(0, coursesArray.length - 1)],
// maritialstatus: i % 2 === 0 ? "Single" : "Married",
// skills: [
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// ],
// intrest: [
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// interestsArray[getRandomNumber(0, interestsArray.length - 1)],
// ],
// componenttime: [],
// phoneno: "1234567890",
// password: "password123",
// };
// };
// for (let i = 0; i < 300; i++) {
// const seekerData = generateRandomSeeker(i);
// try {
// const user = await SeekerModel.create(seekerData);
// console.log(`User "${user.name}" created successfully.`);
// } catch (err) {
// console.error(`Error creating user: ${err}`);
// }
// }
const getRandomNumber = (min, max) =>
Math.floor(Math.random() * (max - min + 1)) + min;
// export const createRandomJobs = async () => {
// try {
// const getRandomNumber = (min, max) =>
// Math.floor(Math.random() * (max - min + 1)) + min;
// const indianEmployers = await IndianEmployer.find().limit(40);
// console.log(indianEmployers);
// console.log(indianEmployers)
// for (const employer of indianEmployers) {
// const employerId = employer._id;
// for (let i = 0; i < 5; i++) {
// const { title, description } = await getRandomTitleAndDescription(jobTitles, jobDescriptions);
// const state=getRandomIndianState();
// const jobData = {
// provider: employerId,
// title,
// description,
// state: state,
// type:getRandomType(),
// salarytype: "Monthly",
// salary: `${getRandomNumber(30000, 80000)}`,
// education: educationLevels[getRandomNumber(0, educationLevels.length - 1)].label,
// gender: i % 2 === 0 ? "Male" : "Female",
// vaccancy: `${getRandomNumber(1, 10)}`,
// maxage: `${getRandomNumber(25, 40)}`,
// ispwd: i % 2 === 0 ? "Yes" : "No",
// disabilitytype: "Some Disability",
// interview: "Some Interview Process",
// skills: [
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// skillsArray[getRandomNumber(0, skillsArray.length - 1)],
// ],
// expirience: ["1 year", "2 years","Fresher"],
// location:getRandomCitiesForState(state),
// };
// await JobsModel.create(jobData);
// }
// }
// console.log("Jobs created successfully.");
// } catch (error) {
// console.error("Error creating jobs:", error);
// } finally {
// mongoose.disconnect();
// }
// };
// // Run the function to create random jobs
// // createRandomJobs(educationLevels, skillsArray, interestsArray, coursesArray, cities);
const educationLevels = [
{ value: '10', label: 'No Schooling' },
{ value: '1', label: '5th' },
{ value: '2', label: '8th' },
{ value: '3', label: '10th' },
{ value: '4', label: '12th' },
{ value: '5', label: 'Diploma After 10th' },
{ value: '6', label: 'Diploma After 12th' },
{ value: '11', label: 'ITI' },
{ value: '7', label: 'Graduate' },
{ value: '12', label: 'PG Diploma' },
{ value: '8', label: 'Post Graduate' },
{ value: '13', label: 'M Phill' },
{ value: '9', label: 'Phd' },
];
const skillsArray = [
"JavaScript",
"React",
"Node.js",
"Python",
"Java",
"C++",
"HTML",
"CSS",
"SQL",
"Angular",
"Vue.js",
"Express",
"MongoDB",
];
const interestsArray = [
"Coding",
"Reading",
"Traveling",
"Gaming",
"Music",
"Cooking",
"Fitness",
"Photography",
"Art",
];
const coursesArray = [
"Computer Science",
"Electrical Engineering",
"Mechanical Engineering",
"Physics",
"Mathematics",
"Biology",
"Chemistry",
"Psychology",
"Business Administration",
"Economics",
// Add more courses as needed
];
const cities = [
"Amritsar",
"Ludhiana",
"Jalandhar",
"Patiala",
"Bathinda",
"Hoshiarpur",
"Pathankot",
"Mohali",
"Batala",
"Moga",
"Sangrur",
"Firozpur",
"Kapurthala",
"Mansa",
"Gurdaspur",
"Rupnagar",
"Faridkot",
"Fatehgarh Sahib",
"Tarn Taran",
];
function getRandomIndianState() {
const indianStatesArray = [
"Amritsar",
"Ludhiana",
"Jalandhar",
"Patiala",
"Bathinda",
"Hoshiarpur",
"Pathankot",
"Mohali",
"Batala",
"Moga",
"Sangrur",
"Firozpur",
"Kapurthala",
"Mansa",
"Gurdaspur",
"Rupnagar",
"Faridkot",
"Fatehgarh Sahib",
"Tarn Taran",
];
// Generate a random index
const randomIndex = Math.floor(Math.random() * indianStatesArray.length);
// Return the random state
return indianStatesArray[randomIndex];
}
const jobTitles = [
"Software Engineer",
"Data Analyst",
"Marketing Specialist",
"Graphic Designer",
"Financial Analyst",
"Human Resources Manager",
"Customer Service Representative",
"Sales Executive",
"Web Developer",
"Project Manager",
"UX/UI Designer",
"Quality Assurance Engineer",
"Content Writer",
"Business Development Manager",
"IT Support Specialist",
"Digital Marketing Manager",
"Network Administrator",
"Mobile App Developer",
"Product Manager",
"Data Scientist",
"Front-end Developer",
"Back-end Developer",
"DevOps Engineer",
"Technical Support Specialist",
"Social Media Manager",
"E-commerce Specialist",
"Cybersecurity Analyst",
"UI/UX Developer",
"Cloud Solutions Architect",
];
const citiesByState = {
"Amritsar": ["Amritsar", "Ajnala", "Baba Bakala", "Majitha", "Tarn Taran"],
"Ludhiana": ["Ludhiana", "Jagraon", "Khanna", "Samrala"],
"Jalandhar": ["Jalandhar", "Nakodar", "Phillaur"],
"Patiala": ["Patiala", "Nabha", "Samana"],
"Bathinda": ["Bathinda", "Rampura Phul", "Talwandi Sabo"],
"Hoshiarpur": ["Hoshiarpur", "Dasua", "Mukerian"],
"Mohali": ["Mohali"],
"Pathankot": ["Pathankot", "Sujanpur"],
"Moga": ["Moga", "Nihal Singh Wala"],
"Sangrur": ["Sangrur", "Sunam", "Dhuri"],
"Batala": ["Batala"],
"Firozpur": ["Firozpur", "Fazilka", "Zira"],
"Kapurthala": ["Kapurthala", "Phagwara", "Sultanpur Lodhi"],
"Gurdaspur": ["Gurdaspur", "Dera Baba Nanak", "Batala"],
"Rupnagar": ["Rupnagar", "Anandpur Sahib", "Nangal"],
"Faridkot": ["Faridkot", "Kotkapura", "Jaitu"],
"Fatehgarh Sahib": ["Fatehgarh Sahib", "Amloh", "Bassi Pathana"],
"Tarn Taran": ["Tarn Taran"],
"Mansa": ["Mansa", "Budhlada"],
"Gurdaspur": ["Gurdaspur", "Dera Baba Nanak", "Batala"],
};
function getRandomType() {
const types = ["govt", "pvt"];
const randomIndex = Math.floor(Math.random() * types.length);
return types[randomIndex];
}
function getRandomCitiesForState(state) {
const cities = citiesByState[state];
// Check if cities are available for the given state
if (cities && cities.length > 0) {
// Shuffle the array to get random cities
const shuffledCities = cities.sort(() => Math.random() - 0.5);
// Return a single random city as a string
return shuffledCities[0];
} else {
return null; // Return null if no cities are available for the given state
}
}
const jobDescriptions = [
"We are seeking a talented Software Engineer to join our dynamic team. Contribute to the development of cutting-edge software solutions.",
"Join our team as a Data Analyst and contribute to data-driven decision-making. Analyze and interpret complex data sets.",
"Exciting opportunity for a Marketing Specialist to drive brand awareness. Develop and implement effective marketing strategies.",
"Creative Graphic Designer needed to produce stunning visual content. Bring artistic and innovative ideas to the table.",
"Financial Analyst position available for a detail-oriented professional. Analyze financial data and provide valuable insights.",
"Manage human resources functions as a Human Resources Manager. Ensure a positive and productive workplace environment.",
"Customer Service Representative wanted to provide exceptional support. Assist customers with inquiries and problem resolution.",
"Sales Executive role available for a motivated and results-driven individual. Identify and pursue new business opportunities.",
"Web Developer position for someone passionate about web technologies. Design and implement web applications with the latest tools.",
"Project Manager needed to lead and execute key projects. Ensure successful project delivery on time and within budget.",
"UX/UI Designer role for creating intuitive and visually appealing user experiences. Work on enhancing user interface designs.",
"Quality Assurance Engineer responsible for ensuring software quality through testing and debugging.",
"Content Writer position available to create engaging and informative content across various platforms.",
"Business Development Manager to identify new business opportunities and build strategic partnerships.",
"IT Support Specialist to provide technical support and troubleshooting for IT-related issues.",
"Digital Marketing Manager to lead digital marketing campaigns and optimize online presence.",
"Network Administrator responsible for managing and maintaining computer networks.",
"Mobile App Developer to design and develop mobile applications for iOS and Android platforms.",
"Product Manager to oversee the entire product development lifecycle and drive product strategy.",
"Data Scientist to analyze and interpret complex data sets to inform business decisions.",
"Front-end Developer to create visually appealing and responsive user interfaces.",
"Back-end Developer to develop server-side logic and integrate user-facing elements.",
"DevOps Engineer to improve and streamline the development and deployment processes.",
"Technical Support Specialist to provide technical assistance and support to end-users.",
"Social Media Manager to develop and implement social media strategies to increase brand awareness.",
"E-commerce Specialist to manage and optimize e-commerce platforms and online sales.",
"Cybersecurity Analyst to protect computer systems and networks from cybersecurity threats.",
"UI/UX Developer to combine design principles with programming skills for a seamless user experience.",
"Cloud Solutions Architect to design and implement scalable and secure cloud solutions.",
];
const getRandomTitleAndDescription = (jobTitles, jobDescriptions) => {
const randomIndex = getRandomNumber(0, jobTitles.length - 1);
return {
title: jobTitles[randomIndex],
description: jobDescriptions[randomIndex],
};
};
const generateRandomSeeker = (i) => {
const state=getRandomIndianState();
console.log(state)
return {
name: `User${i + 1}`,
age: getRandomNumber(20, 35).toString(),
email: `user${i + 1}@example.com`,
state: state,
city:getRandomCitiesForState(state),
tehsil:getRandomCitiesForState(state),
sex: i % 2 === 0 ? "Male" : "Female",
education: educationLevels[getRandomNumber(0, educationLevels.length - 1)].label,
course: coursesArray[getRandomNumber(0, coursesArray.length - 1)],
maritialstatus: i % 2 === 0 ? "Single" : "Married",
skills: [
skillsArray[getRandomNumber(0, skillsArray.length - 1)],
skillsArray[getRandomNumber(0, skillsArray.length - 1)],
skillsArray[getRandomNumber(0, skillsArray.length - 1)],
skillsArray[getRandomNumber(0, skillsArray.length - 1)],
skillsArray[getRandomNumber(0, skillsArray.length - 1)],
],
intrest: [
interestsArray[getRandomNumber(0, interestsArray.length - 1)],
interestsArray[getRandomNumber(0, interestsArray.length - 1)],
interestsArray[getRandomNumber(0, interestsArray.length - 1)],
interestsArray[getRandomNumber(0, interestsArray.length - 1)],
interestsArray[getRandomNumber(0, interestsArray.length - 1)],
],
componenttime: [],
phoneno: "1234567890",
password: "password123",
};
};
export const createRandom =async()=> {
try {
console.log('called')
for (let i = 0; i < 300; i++) {
const seekerData = generateRandomSeeker(i);
try {
const user = await SeekerModel.create(seekerData);
console.log(`User "${user.name}" created successfully.`);
} catch (err) {
console.error(`Error creating user: ${err}`);
}
}
console.log("users created successfully.");
} catch (error) {
console.error("Error creating jobs:", error);
} finally {
}
};