Example #1
0
        public GetReposFromGH(Configuration config, TopGHReposContext context)
        {
            Config  = config;
            Context = context;

            GitHubClient = new GitHubClient(new ProductHeaderValue("Top-Repos-Crawler"));
            if (config.GitHubPAT != null)
            {
                GitHubClient.Credentials = new Credentials(config.GitHubPAT);
            }


            ConfigureSearchWaitInterval();
            Log.Info($"SearchWaitInterval is {SearchWaitInterval}ms");
        }
Example #2
0
        public async Task Run()
        {
            var optBuilder = new DbContextOptionsBuilder <TopGHReposContext>();

            optBuilder.UseSqlite($"Data Source={Config.SQLLiteOutputFile}");

            using var context = new TopGHReposContext(optBuilder.Options);

            Log.Info("Ensuring db is deleted");
            context.Database.EnsureDeleted();
            Log.Info("db is deleted");

            Log.Info($"Doing {context.Database.GetPendingMigrations().Count()} pending database migrations");
            context.Database.Migrate();
            Log.Info($"Migration successful");

            await new GetReposFromGH(Config, context).Run();

            Log.Info("Saving changes before shutting down");
            context.SaveChanges();
            Log.Info("Saved changes");
        }