mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
various updates
This commit is contained in:
parent
4d3603b683
commit
ddaadf2f06
9 changed files with 24 additions and 41 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -296,6 +296,5 @@ __pycache__/
|
|||
|
||||
# FilterLists Custom Ignores
|
||||
gs/Private.gs
|
||||
src/FilterLists.Api/appsettings.Development.json
|
||||
src/FilterLists.Api/appsettings.Production.json
|
||||
src/FilterLists.DataLoad/appsettings.json
|
||||
src/FilterLists.Api/appsettings.json
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
#TODO: use ssh keys rather than pw
|
||||
chmod a+x /home/travis/build/collinbarrett/FilterLists/src/FilterLists.Api/bin/Release/netcoreapp1.1/ubuntu.16.04-x64/publish/FilterLists.Api.dll
|
||||
chmod a+x /home/travis/build/collinbarrett/FilterLists/src/FilterLists.Api/bin/Release/netcoreapp1.1/ubuntu.16.04-x64/publish/FilterLists.DataLoad
|
||||
sshpass -p $FTP_PASSWORD scp -o StrictHostKeyChecking=no -r /home/travis/build/collinbarrett/FilterLists/src/FilterLists.Api/bin/Release/netcoreapp1.1/ubuntu.16.04-x64/publish/* $FTP_USER@$FTP_HOST:$FTP_DIR
|
||||
chmod a+x /home/travis/build/collinbarrett/FilterLists/src/FilterLists.DataLoad/bin/Release/netcoreapp1.1/ubuntu.16.04-x64/publish/FilterLists.DataLoad
|
||||
sshpass -p $FTP_PASSWORD scp -o StrictHostKeyChecking=no -r /home/travis/build/collinbarrett/FilterLists/src/FilterLists.DataLoad/bin/Release/netcoreapp1.1/ubuntu.16.04-x64/publish/* $FTP_USER@$FTP_HOST:$FTP_DIR
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using FilterLists.Api.DependencyInjection.Extensions;
|
||||
using System.IO;
|
||||
using FilterLists.Api.DependencyInjection.Extensions;
|
||||
using FilterLists.Data.DependencyInjection.Extensions;
|
||||
using FilterLists.Services.DependencyInjection.Extensions;
|
||||
using JetBrains.Annotations;
|
||||
|
|
@ -12,13 +13,11 @@ namespace FilterLists.Api
|
|||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
public Startup(ILoggerFactory loggerFactory)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(env.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", false, true)
|
||||
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
|
||||
.AddEnvironmentVariables();
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", false, true);
|
||||
Configuration = builder.Build();
|
||||
|
||||
//TODO: replace with serilog
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ namespace FilterLists.Data.Repositories.Contracts
|
|||
public interface IListRepository
|
||||
{
|
||||
IEnumerable<List> GetAll();
|
||||
IEnumerable<List> UpdateAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FilterLists.Data.Contexts;
|
||||
using FilterLists.Data.Models;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Data.Repositories.Implementations
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListRepository : IListRepository
|
||||
{
|
||||
private readonly IFilterListsDbContext _filterListsDbContext;
|
||||
|
||||
public ListRepository(FilterListsDbContext filterListsDbContext)
|
||||
public ListRepository(IFilterListsDbContext filterListsDbContext)
|
||||
{
|
||||
_filterListsDbContext = filterListsDbContext;
|
||||
}
|
||||
|
|
@ -22,10 +19,5 @@ public IEnumerable<List> GetAll()
|
|||
{
|
||||
return _filterListsDbContext.List.AsEnumerable();
|
||||
}
|
||||
|
||||
public IEnumerable<List> UpdateAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ public class Startup
|
|||
{
|
||||
public Startup()
|
||||
{
|
||||
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", false, true);
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="2.16.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data.Models;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
using FilterLists.Services.Contracts;
|
||||
|
||||
|
|
@ -31,26 +30,21 @@ public void UpdateTables()
|
|||
/// <param name="tableName">name of database table</param>
|
||||
public void UpdateTable(string tableName)
|
||||
{
|
||||
//TODO: fetch CSV URL from db table
|
||||
const string csvUrl = "https://raw.githubusercontent.com/collinbarrett/FilterLists/dataToCsv/data/List.csv";
|
||||
var file = FetchFile(csvUrl).Result;
|
||||
var csvRows = file.Split('\n');
|
||||
var headerCells = csvRows[0].Split(',');
|
||||
for (var i = 1; i < csvRows.Length; i++)
|
||||
if (!string.IsNullOrEmpty(csvRows[i]))
|
||||
{
|
||||
var cells = csvRows[i].Split(',');
|
||||
var list = new List
|
||||
{
|
||||
Name = cells[0]
|
||||
//TODO: finish mappings, try to make generic for any table type using headerCells as properties
|
||||
};
|
||||
}
|
||||
//TODO: update table via repo/EF
|
||||
switch (tableName)
|
||||
{
|
||||
case "List":
|
||||
//TODO: fetch CSV URL from db table
|
||||
const string csvUrl =
|
||||
"https://raw.githubusercontent.com/collinbarrett/FilterLists/master/data/List.csv";
|
||||
break;
|
||||
default:
|
||||
//TODO: throw invalid table exception
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fetch a file as a string from the internet
|
||||
/// fetch file as string from internet
|
||||
/// </summary>
|
||||
/// <param name="url">URL of file to fetch</param>
|
||||
/// <returns>string of file</returns>
|
||||
|
|
|
|||
Loading…
Reference in a new issue