Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

POSTGRES_DB=linktracker
POSTGRES_USER=linktracker
POSTGRES_PASSWORD=linktracker
POSTGRES_PASSWORD=linktracker
GITHUB_TOKEN=your-github-token
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
- Database__AccessType=SQL
- Database__ConnectionString=Host=postgres;Port=5432;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD}
- Database__RunMigrations=true
- Scrapper__GitHubToken=${GITHUB_TOKEN}
depends_on:
postgres:
condition: service_healthy
Expand Down
2 changes: 2 additions & 0 deletions src/LinkTracker.Scrapper/Configuration/ScrapperOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public sealed class ScrapperOptions

public string GitHubBaseUrl { get; init; } = "https://api.github.com/";
public string StackOverflowBaseUrl { get; init; } = "https://api.stackexchange.com/2.3/";

public string? GitHubToken { get; init; }
}
9 changes: 9 additions & 0 deletions src/LinkTracker.Scrapper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using LinkTracker.Scrapper.Services.Notifications;
using LinkTracker.Scrapper.Services.Updates;
using Microsoft.EntityFrameworkCore;
using System.Net.Http.Headers;
using Npgsql;
using Quartz;

Expand Down Expand Up @@ -51,6 +52,14 @@
{
client.BaseAddress = new Uri(scrapperOptions.GitHubBaseUrl);
client.DefaultRequestHeaders.UserAgent.ParseAdd("LinkTrackerBot/1.0");
client.DefaultRequestHeaders.Accept.ParseAdd("application/vnd.github+json");
client.DefaultRequestHeaders.Add("X-GitHub-Api-Version", "2022-11-28");

if (!string.IsNullOrWhiteSpace(scrapperOptions.GitHubToken))
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", scrapperOptions.GitHubToken);
}
});

builder.Services.AddHttpClient<StackOverflowClient>(client =>
Expand Down
4 changes: 2 additions & 2 deletions src/LinkTracker.Scrapper/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"RunMigrations": true
},
"Scrapper": {
"CheckIntervalSeconds": 30,
"CheckIntervalSeconds": 300,
"BatchSize": 100,
"Parallelism": 4,
"Parallelism": 2,
"GitHubBaseUrl": "https://api.github.com/",
"StackOverflowBaseUrl": "https://api.stackexchange.com/2.3/"
},
Expand Down
Loading