Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaderboard changes from demo #5

Merged
merged 37 commits into from
Mar 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6dc09a0
docker in root
bruno-garcia Mar 10, 2024
e51a4b7
in-memory db
bruno-garcia Mar 10, 2024
7f21230
in-memory db
bruno-garcia Mar 10, 2024
7db225f
dotnet build sln
bruno-garcia Mar 10, 2024
3e256a3
Update and rename dotnet-desktop.yml to dotnet-build.yml
bruno-garcia Mar 10, 2024
5c8d82d
publish blazor app
bruno-garcia Mar 10, 2024
e457f10
push pages
bruno-garcia Mar 10, 2024
758e7aa
use linux for deploy
bruno-garcia Mar 10, 2024
1fab3f1
push wwwroot
bruno-garcia Mar 10, 2024
42f57b4
live backend
bruno-garcia Mar 10, 2024
ea4e295
dsn api
bruno-garcia Mar 10, 2024
92ca63d
favicon sentry
bruno-garcia Mar 10, 2024
59b5c4f
fix icon type
bruno-garcia Mar 10, 2024
d8dc72f
add js sdk
bruno-garcia Mar 10, 2024
3c0b321
fix op name
bruno-garcia Mar 11, 2024
c826157
publish gha only on main
bruno-garcia Mar 11, 2024
f8601ac
jwt ftw
bitsandfoxes Mar 12, 2024
bb438a0
Merge branch 'main' into feat/authentication
bitsandfoxes Mar 12, 2024
dce32da
bump sentry sdk 4.2.1
bruno-garcia Mar 12, 2024
cbeb737
cleanup and put user in config file
bitsandfoxes Mar 12, 2024
c44c635
Merge pull request #1 from sentry-demos/feat/authentication
bitsandfoxes Mar 12, 2024
d184eb7
added delete
bitsandfoxes Mar 13, 2024
3fc611b
fix warning nullability
bruno-garcia Mar 14, 2024
c2e5d93
postgres
bruno-garcia Mar 14, 2024
6f867d5
move dev config to dev file
bruno-garcia Mar 14, 2024
203b2d9
use posgres in release builds
bruno-garcia Mar 17, 2024
37ca5d0
cloud build
bruno-garcia Mar 17, 2024
3546811
upload symbols
bruno-garcia Mar 17, 2024
b26a704
pass down auth token for symbol upload
bruno-garcia Mar 17, 2024
c2eb59a
throw endpoint
bruno-garcia Mar 17, 2024
069dcc4
don't insert mock data
bruno-garcia Mar 17, 2024
3fe1e78
remove in-memory db
bruno-garcia Mar 17, 2024
058d6b1
add sentry to anti-cheat
bruno-garcia Mar 17, 2024
c6206dd
show time in PST
bruno-garcia Mar 22, 2024
5d01eb7
use local timezone
bruno-garcia Mar 22, 2024
0a65ae8
lottery (#3)
bruno-garcia Mar 22, 2024
f177078
readme
bruno-garcia Mar 22, 2024
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
Prev Previous commit
Next Next commit
postgres
bruno-garcia committed Mar 14, 2024
commit c2e5d93f3f4cb6b5a88741a5437fe5eaffb5d659
28 changes: 24 additions & 4 deletions Sentaur.Leaderboard.Api/LeaderboardContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace Sentaur.Leaderboard.Api;

@@ -8,7 +9,7 @@ public class LeaderboardContext : DbContext

private string _dbPath;

public LeaderboardContext()
public LeaderboardContext(DbContextOptions<LeaderboardContext> options) : base(options)
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
@@ -19,11 +20,30 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.Entity<ScoreEntry>(
eb => eb.HasKey(nameof(ScoreEntry.Key)));
eb =>
{
eb.HasKey(nameof(ScoreEntry.Key));
// https://stackoverflow.com/questions/72147210/cant-cast-database-type-character-to-guid
// eb.Property(p => p.Key).HasColumnType("CHAR(36)");
});
base.OnModelCreating(modelBuilder);
}

protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseInMemoryDatabase("InMemoryDb");
// => options.UseSqlite($"Data Source={_dbPath}");
#if !DEBUG
=> options.UseInMemoryDatabase("Leaderboard");
#else
=> options.UseNpgsql();
#endif

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder
.Properties<DateTimeOffset>()
.HaveConversion<DateTimeOffsetConverter>();
}
}

public class DateTimeOffsetConverter()
: ValueConverter<DateTimeOffset, DateTimeOffset>(d => d.ToUniversalTime(),
d => d.ToUniversalTime());

This file was deleted.

39 changes: 0 additions & 39 deletions Sentaur.Leaderboard.Api/Migrations/20240301164227_NewKeyProp.cs

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
namespace Sentaur.Leaderboard.Api.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -15,14 +15,16 @@ protected override void Up(MigrationBuilder migrationBuilder)
name: "ScoreEntries",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: false),
Duration = table.Column<TimeSpan>(type: "TEXT", nullable: false),
Score = table.Column<int>(type: "INTEGER", nullable: false),
Timestamp = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
Key = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
Duration = table.Column<TimeSpan>(type: "interval", nullable: false),
Score = table.Column<int>(type: "integer", nullable: false),
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ScoreEntries", x => x.Key);
});
}

Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Sentaur.Leaderboard.Api;

#nullable disable
@@ -15,30 +16,34 @@ partial class LeaderboardContextModelSnapshot : ModelSnapshot
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);

NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

modelBuilder.Entity("Sentaur.Leaderboard.ScoreEntry", b =>
{
b.Property<Guid>("Key")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
.HasColumnType("uuid");

b.Property<TimeSpan>("Duration")
.HasColumnType("TEXT");
.HasColumnType("interval");

b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
.HasColumnType("text");

b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
.HasColumnType("text");

b.Property<int>("Score")
.HasColumnType("INTEGER");
.HasColumnType("integer");

b.Property<DateTimeOffset>("Timestamp")
.HasColumnType("TEXT");
.HasColumnType("timestamp with time zone");

b.HasKey("Key");

15 changes: 10 additions & 5 deletions Sentaur.Leaderboard.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -56,11 +56,16 @@
});
});

builder.Services.AddDbContextFactory<LeaderboardContext>(
builder.Services.AddDbContext<LeaderboardContext>(
options =>
options.UseInMemoryDatabase("InMemoryDb")
// options.UseSqlite()
);
{
#if !DEBUG
options.UseInMemoryDatabase("Leaderboard");
#else
options.UseNpgsql(builder.Configuration.GetConnectionString("Leaderboard"));
#endif

});

builder.Services.AddAuthentication(o =>
{
@@ -127,7 +132,7 @@

app.MapPost("/token", [AllowAnonymous](User user) =>
{
if (user.Username.Equals(builder.Configuration["User:Username"]) && user.Password.Equals(builder.Configuration["User:Password"]))
if (user.Username?.Equals(builder.Configuration["User:Username"]) is true && user.Password?.Equals(builder.Configuration["User:Password"]) is true)
{
return Results.Ok(tokenHolder.Token);
}
6 changes: 5 additions & 1 deletion Sentaur.Leaderboard.Api/Sentaur.Leaderboard.Api.csproj
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
<!-- <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />-->
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="Sentry.AspNetCore" Version="4.2.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
@@ -30,4 +30,8 @@
</Content>
</ItemGroup>

<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions Sentaur.Leaderboard.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -4,5 +4,12 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"User": {
"Username": "test",
"Password": "password"
},
"ConnectionStrings": {
"Leaderboard": "Host=localhost;Database=leaderboard;Username=postgres;Password=leaderboard;Include Error Detail=true;"
}
}