Ejemplo n.º 1
0
        public async Task RunAsync(string endpoint = "localhost", int port = 8182)
        {
            try
            {
                var skills = new List <Skill>();

                // This uses the default Neptune and Gremlin port, 8182
                var gremlinDB = new GremlinDB(endpoint, port);

                // Drop entire DB
                //gremlinDB.Drop();

                // get job posts
                var jobPosts = JobPostRepo.Get();
                //var jobPosts = JobPostRepo.GetJobPosts();

                // load csv data for skills
                skills = LoadDataToMemory();
                // skills into DB
                Stopwatch stopWatch  = new Stopwatch();
                Stopwatch stopWatch1 = new Stopwatch();
                stopWatch.Start();
                stopWatch1.Start();
                gremlinDB.InsertNodes(skills);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND inserting NODES\n");

                // edges into DB
                IJobPostProcessor jobPostProcessor = new JobPostProcessor();
                Console.WriteLine("Start processing JOB POSTS");
                stopWatch.Restart();
                var jobPostsSkills = jobPostProcessor.ProcessJobPosts(skills, jobPosts);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND iprocessing JOB POSTS\n");

                Console.WriteLine("Start inserting EDGES");
                stopWatch.Restart();
                gremlinDB.InsertEdges(jobPostsSkills);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND inserting EDGES\n");

                // get related skills
                const string skillNameForSearch = "c#";
                const int    limit = 10;

                Console.WriteLine("Start RELATED skills");
                var relatedSkills = gremlinDB.GetRelatedSkills(skillNameForSearch, limit);
                Console.WriteLine(stopWatch1.Elapsed);

                Console.WriteLine($"Top {limit} skills related to {skillNameForSearch}:\n");
                foreach (var skill in relatedSkills)
                {
                    Console.WriteLine($"Name: {skill.Name}, Category: {skill.Category}, Weight: {skill.Weight}");
                }

                Console.WriteLine("\n\nTotal number of skills: {0}", gremlinDB.CountNodes());

                await Helpers.Metrics.CommitDataAsync();

                Console.WriteLine("Finished");
            }
            catch (Exception e)
            {
                Console.WriteLine("{0}", e);
            }
        }
Ejemplo n.º 2
0
        public void JobPostProcessorTest()
        {
            var simpleJobPost    = new JobPost("Lead .NET Developer", "Many years of experience in C#");
            var processedJobPost = new JobPost("Senior in-house Jenkins lead", "Apply here")
            {
                Keywords = new List <string>()
                {
                    "junit", "java", "maven"
                }
            };

            var jobPosts = new List <JobPost>
            {
                simpleJobPost,
                processedJobPost
            };

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = ".net"
                },
                new Skill()
                {
                    Name = "c#"
                },
                new Skill()
                {
                    Name = "java"
                },
                new Skill()
                {
                    Name = "maven"
                },
                new Skill()
                {
                    Name = "junit"
                },
                new Skill()
                {
                    Name = "jenkins"
                },
                new Skill()
                {
                    Name = "eclipse"
                }
            };

            var jobPostProcessor = new JobPostProcessor();
            var processedSkills  = (List <ICollection <Skill> >)jobPostProcessor.ProcessJobPosts(skills, jobPosts);

            var simpleJobPostSkills    = processedSkills[0];
            var processedJobPostSkills = processedSkills[1];

            Assert.True(simpleJobPostSkills.Count == 2);
            Assert.True(processedJobPostSkills.Count == 3);

            foreach (var skill in simpleJobPostSkills)
            {
                Assert.True(skill.Weight == 1);
            }

            foreach (var skill in processedJobPostSkills)
            {
                Assert.True(skill.Weight == 10);
                Assert.True(skill.Name != "jenkins");
            }
        }