Exemplo n.º 1
0
 public SnapshotBatch(FilterListsDbContext dbContext, IEnumerable <string> lines,
                      Data.Entities.Snapshot snapEntity)
 {
     this.dbContext  = dbContext;
     this.lines      = lines;
     this.snapEntity = snapEntity;
 }
Exemplo n.º 2
0
 public SnapshotBatchDe(FilterListsDbContext dbContext, Data.Entities.Snapshot snapshot,
                        IEnumerable <string> rawRules)
 {
     _dbContext = dbContext;
     _snapshot  = snapshot;
     _rawRules  = rawRules;
 }
        public async void SeedOrUpdateAsync_DoesNotThrowException()
        {
            var options = new DbContextOptionsBuilder <FilterListsDbContext>()
                          .UseMySql(CiTestDatabaseConnString, m => m.MigrationsAssembly("FilterLists.Api"))
                          .Options;

            using (var context = new FilterListsDbContext(options))
            {
                await context.Database.EnsureDeletedAsync();

                using (var conn = new MySqlConnection(CiTestServerConnString))
                {
                    await conn.OpenAsync();

                    var cmd = new MySqlCommand(
                        "CREATE DATABASE filterlistsdatatest CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;",
                        conn);
                    await cmd.ExecuteNonQueryAsync();
                }

                await context.Database.MigrateAsync();

                if (Directory.Exists("../../../../../data"))
                {
                    await SeedFilterListsDbContext.SeedOrUpdateAsync(context, "../../../../../data");
                }
                else
                {
                    await SeedFilterListsDbContext.SeedOrUpdateAsync(context, "../../../../../../../../data");
                }
            }
        }
Exemplo n.º 4
0
        public static async Task SeedOrUpdateAsync(FilterListsDbContext dbContext, string dataPath)
        {
            if (dbContext is null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            await SeedOrUpdate <Language>(dbContext, dataPath);
            await SeedOrUpdate <License>(dbContext, dataPath);
            await SeedOrUpdate <Maintainer>(dbContext, dataPath);
            await SeedOrUpdate <Software>(dbContext, dataPath);
            await SeedOrUpdate <Syntax>(dbContext, dataPath);
            await SeedOrUpdate <Tag>(dbContext, dataPath);

            await SeedOrUpdate <FilterList>(dbContext, dataPath);
            await SetDefaultLicenseIdAsync(dbContext);
            await SeedFilterListDates(dbContext, dataPath);

            await SeedOrUpdate <FilterListLanguage>(dbContext, dataPath);
            await SeedOrUpdate <FilterListMaintainer>(dbContext, dataPath);
            await SeedOrUpdate <FilterListTag>(dbContext, dataPath);
            await SeedOrUpdate <Dependent>(dbContext, dataPath);
            await SeedOrUpdate <Fork>(dbContext, dataPath);
            await SeedOrUpdate <Merge>(dbContext, dataPath);
            await SeedOrUpdate <SoftwareSyntax>(dbContext, dataPath);
        }
Exemplo n.º 5
0
 public Snapshot(FilterListsDbContext dbContext, FilterListViewUrlDto list)
 {
     this.dbContext = dbContext;
     this.list      = list;
     snapEntity     = new Data.Entities.Snapshot
     {
         FilterListId       = list.Id,
         AddedSnapshotRules = new List <SnapshotRule>()
     };
 }
Exemplo n.º 6
0
 public Snapshot(FilterListsDbContext dbContext, FilterListViewUrlDto list, Logger logger, string uaString)
 {
     this.dbContext = dbContext;
     List           = list;
     ListUrl        = list.ViewUrl;
     this.logger    = logger;
     SnapEntity     = new Data.Entities.Snapshot {
         FilterListId = list.Id, SnapshotRules = new List <SnapshotRule>()
     };
     this.uaString = uaString;
 }
Exemplo n.º 7
0
 public Snapshot(FilterListsDbContext dbContext, Data.Entities.FilterList list, GitHubService gitHubService,
                 Logger logger, string uaString)
 {
     this.dbContext     = dbContext;
     List               = list;
     ListUrl            = list.ViewUrl;
     this.gitHubService = gitHubService;
     this.logger        = logger;
     SnapEntity         = new Data.Entities.Snapshot {
         FilterListId = list.Id, SnapshotRules = new List <SnapshotRule>()
     };
     this.uaString = uaString;
 }
        public void Migrate_DoesNotThrowException()
        {
            // TODO: replace with Polly or similar to optimize time waste
            // allow time for db to init
            Thread.Sleep(20000);

            const string connString = "Server=mariadb;Database=filterlists;Uid=filterlists;Pwd=filterlists;";
            var          options    = new DbContextOptionsBuilder <FilterListsDbContext>().UseMySql(connString,
                                                                                                    m => m.MigrationsAssembly("FilterLists.Data.Migrations").ServerVersion(Constants.ServerVersion))
                                      .Options;

            using var context = new FilterListsDbContext(options);
            context.Database.Migrate();
        }
        public async void SeedOrUpdateAsync_DoesNotThrowException()
        {
            const string connString = "Server=mariadb;Database=filterlists;Uid=filterlists;Pwd=filterlists;";
            var          options    = new DbContextOptionsBuilder <FilterListsDbContext>()
                                      .UseMySql(connString, m => m.MigrationsAssembly("FilterLists.Api"))
                                      .Options;

            using (var context = new FilterListsDbContext(options))
            {
                await context.Database.EnsureCreatedAsync();

                await SeedFilterListsDbContext.SeedOrUpdateAsync(context, "../../../data");
            }
        }
Exemplo n.º 10
0
 public static void SeedOrUpdate(this FilterListsDbContext dbContext, string dataPath)
 {
     dbContext.InsertOnDuplicateKeyUpdate <Language>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <License>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <Maintainer>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <Software>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <Syntax>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <FilterList>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <FilterListLanguage>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <FilterListMaintainer>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <Fork>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <Merge>(dataPath);
     dbContext.InsertOnDuplicateKeyUpdate <SoftwareSyntax>(dataPath);
 }
 public static void SeedOrUpdate(this FilterListsDbContext dbContext, string dataPath)
 {
     dbContext.SeedOrUpdate <Language>(dataPath);
     dbContext.SeedOrUpdate <License>(dataPath);
     dbContext.SeedOrUpdate <Maintainer>(dataPath);
     dbContext.SeedOrUpdate <Software>(dataPath);
     dbContext.SeedOrUpdate <Syntax>(dataPath);
     dbContext.SeedOrUpdate <Tag>(dataPath);
     dbContext.SeedOrUpdate <FilterList>(dataPath);
     dbContext.SeedOrUpdate <FilterListLanguage>(dataPath);
     dbContext.SeedOrUpdate <FilterListMaintainer>(dataPath);
     dbContext.SeedOrUpdate <FilterListTag>(dataPath);
     dbContext.SeedOrUpdate <Dependent>(dataPath);
     dbContext.SeedOrUpdate <Fork>(dataPath);
     dbContext.SeedOrUpdate <Merge>(dataPath);
     dbContext.SeedOrUpdate <SoftwareSyntax>(dataPath);
 }
Exemplo n.º 12
0
        public async void SeedOrUpdateAsync_DoesNotThrowException()
        {
            //TODO: replace with Polly or similar to optimize time waste
            // allow time for db to init
            Thread.Sleep(20000);

            const string connString = "Server=mariadb;Database=filterlists;Uid=filterlists;Pwd=filterlists;";
            var          options    = new DbContextOptionsBuilder <FilterListsDbContext>()
                                      .UseMySql(connString, m => m.MigrationsAssembly("FilterLists.Api"))
                                      .Options;

            using (var context = new FilterListsDbContext(options))
            {
                await context.Database.EnsureCreatedAsync();

                await SeedFilterListsDbContext.SeedOrUpdateAsync(context, "../../../data");
            }
        }
        public static async Task SeedOrUpdateAsync(FilterListsDbContext dbContext, string dataPath)
        {
            await SeedOrUpdate <Language>(dbContext, dataPath);
            await SeedOrUpdate <License>(dbContext, dataPath);
            await SeedOrUpdate <Maintainer>(dbContext, dataPath);
            await SeedOrUpdate <Software>(dbContext, dataPath);
            await SeedOrUpdate <Syntax>(dbContext, dataPath);
            await SeedOrUpdate <Tag>(dbContext, dataPath);

            await SeedOrUpdate <FilterList>(dbContext, dataPath);
            await SetDefaultLicenseIdAsync(dbContext);
            await SeedFilterListDates(dbContext, dataPath);

            await SeedOrUpdate <FilterListLanguage>(dbContext, dataPath);
            await SeedOrUpdate <FilterListMaintainer>(dbContext, dataPath);
            await SeedOrUpdate <FilterListTag>(dbContext, dataPath);
            await SeedOrUpdate <Dependent>(dbContext, dataPath);
            await SeedOrUpdate <Fork>(dbContext, dataPath);
            await SeedOrUpdate <Merge>(dbContext, dataPath);
            await SeedOrUpdate <SoftwareSyntax>(dbContext, dataPath);
        }
Exemplo n.º 14
0
 public FilterListService(FilterListsDbContext filterListsDbContext)
 {
     this.filterListsDbContext = filterListsDbContext;
 }
Exemplo n.º 15
0
 public SnapshotService(FilterListsDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
Exemplo n.º 16
0
 public FilterListService(FilterListsDbContext dbContext) : base(dbContext)
 {
     DbContext = dbContext;
 }
Exemplo n.º 17
0
 public FilterListRepository(FilterListsDbContext filterListsDbContext)
 {
     this.filterListsDbContext = filterListsDbContext;
 }
Exemplo n.º 18
0
 public SnapshotDe(FilterListsDbContext dbContext, FilterListViewUrlDto list)
 {
     _dbContext = dbContext;
     _list      = list;
 }
Exemplo n.º 19
0
 public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig,
                        GitHubService gitHubService, Logger logger) : base(dbContext, mapConfig)
 {
     this.gitHubService = gitHubService;
     this.logger        = logger;
 }
Exemplo n.º 20
0
 public FilterListService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig)
     : base(dbContext, mapConfig)
 {
 }
Exemplo n.º 21
0
 public SnapshotWayback(FilterListsDbContext dbContext, FilterListViewUrlDto list, Logger logger, string uaString)
     : base(dbContext, list, logger, uaString)
 {
 }
Exemplo n.º 22
0
 public RuleService(FilterListsDbContext dbContext) : base(dbContext)
 {
 }
Exemplo n.º 23
0
 public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig, Logger logger)
     : base(dbContext, mapConfig) => this.logger = logger;
Exemplo n.º 24
0
 public ListRepository(FilterListsDbContext filterListsDbContext)
 {
     _filterListsDbContext = filterListsDbContext;
 }
Exemplo n.º 25
0
 public SnapshotBatchDe(FilterListsDbContext dbContext, Snapshot snapshot, IEnumerable <string> rawRules)
 {
     this.dbContext = dbContext;
     this.snapshot  = snapshot;
     this.rawRules  = rawRules;
 }
Exemplo n.º 26
0
 public Service(FilterListsDbContext dbContext)
 {
     DbContext = dbContext;
 }
Exemplo n.º 27
0
 protected Service(FilterListsDbContext dbContext) => DbContext = dbContext;
Exemplo n.º 28
0
 public TableCsvRepository(FilterListsDbContext filterListsDbContext)
 {
     _filterListsDbContext = filterListsDbContext;
 }
Exemplo n.º 29
0
 public SnapshotDe(FilterListsDbContext dbContext, FilterListViewUrlDto list)
 {
     this.dbContext = dbContext;
     this.list      = list;
 }
Exemplo n.º 30
0
 public SnapshotWayback(FilterListsDbContext dbContext, Data.Entities.FilterList list,
                        GitHubService gitHubService, Logger logger, string uaString) :
     base(dbContext, list, gitHubService, logger, uaString)
 {
 }