Convert ids to i64
The birthday paradox is a real problem with the size of our datasets. i64 is the largest numerical value we can use, and there's a 0.1% chance of collision with ~2,000,000 values, so I feel pretty comfortable with this
This commit is contained in:
parent
c8f2ef57c8
commit
162341fb5f
9 changed files with 21 additions and 27 deletions
|
|
@ -6,7 +6,7 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"songs",
|
"songs",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("name", .string, .{}),
|
t.column("name", .string, .{}),
|
||||||
t.column("length", .float, .{ .optional = true }),
|
t.column("length", .float, .{ .optional = true }),
|
||||||
t.column("hidden", .boolean, .{}),
|
t.column("hidden", .boolean, .{}),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"albums",
|
"albums",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("name", .string, .{}),
|
t.column("name", .string, .{}),
|
||||||
t.column("length", .float, .{ .optional = true }),
|
t.column("length", .float, .{ .optional = true }),
|
||||||
t.timestamps(.{}),
|
t.timestamps(.{}),
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"albumsongs",
|
"albumsongs",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("song_id", .integer, .{ .reference = .{ "songs", "id" } }),
|
t.column("song_id", .bigint, .{ .reference = .{ "songs", "id" } }),
|
||||||
t.column("album_id", .integer, .{ .reference = .{ "albums", "id" } }),
|
t.column("album_id", .bigint, .{ .reference = .{ "albums", "id" } }),
|
||||||
t.timestamps(.{}),
|
t.timestamps(.{}),
|
||||||
},
|
},
|
||||||
.{},
|
.{},
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"scrobbles",
|
"scrobbles",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("albumsong", .integer, .{ .reference = .{ "albumsongs", "id" } }),
|
t.column("albumsong", .bigint, .{ .reference = .{ "albumsongs", "id" } }),
|
||||||
t.column("datetime", .datetime, .{}),
|
t.column("datetime", .datetime, .{}),
|
||||||
t.timestamps(.{}),
|
t.timestamps(.{}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"artists",
|
"artists",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("name", .string, .{}),
|
t.column("name", .string, .{}),
|
||||||
t.column("disambiguation", .string, .{ .optional = true }),
|
t.column("disambiguation", .string, .{ .optional = true }),
|
||||||
t.timestamps(.{}),
|
t.timestamps(.{}),
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"albumsongsartists",
|
"albumsongsartists",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("albumsong_id", .integer, .{ .reference = .{ "albumsongs", "id" } }),
|
t.column("albumsong_id", .bigint, .{ .reference = .{ "albumsongs", "id" } }),
|
||||||
t.column("artist_id", .integer, .{ .reference = .{ "artists", "id" } }),
|
t.column("artist_id", .bigint, .{ .reference = .{ "artists", "id" } }),
|
||||||
t.timestamps(.{}),
|
t.timestamps(.{}),
|
||||||
},
|
},
|
||||||
.{},
|
.{},
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ pub fn up(repo: anytype) !void {
|
||||||
try repo.createTable(
|
try repo.createTable(
|
||||||
"artistalbums",
|
"artistalbums",
|
||||||
&.{
|
&.{
|
||||||
t.primaryKey("id", .{}),
|
t.primaryKey("id", .{ .type = .bigint }),
|
||||||
t.column("album_id", .integer, .{ .reference = .{ "albums", "id" } }),
|
t.column("album_id", .bigint, .{ .reference = .{ "albums", "id" } }),
|
||||||
t.column("artist_id", .integer, .{ .reference = .{ "artists", "id" } }),
|
t.column("artist_id", .bigint, .{ .reference = .{ "artists", "id" } }),
|
||||||
t.timestamps(.{}),
|
t.timestamps(.{}),
|
||||||
},
|
},
|
||||||
.{},
|
.{},
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,6 @@ pub fn entityQueryResult(request: *jetzig.Request, query: GeneratedQuery, args:
|
||||||
return out.get("entity_info").?;
|
return out.get("entity_info").?;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (query.query_type == .datestreak) {
|
|
||||||
// var out: *jetzig.Data.Value = try Data.object();
|
|
||||||
// const entity = try (try result.next()).?.to(struct { name: []const u8, id: i32, scrobbles: i64, rank: []const u8 }, .{ .dupe = true, .allocator = request.allocator });
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
var out: *jetzig.Data.Value = try Data.array();
|
var out: *jetzig.Data.Value = try Data.array();
|
||||||
var mapper = result.mapper(UnifiedResult, .{ .dupe = true, .allocator = request.allocator });
|
var mapper = result.mapper(UnifiedResult, .{ .dupe = true, .allocator = request.allocator });
|
||||||
|
|
||||||
|
|
@ -65,22 +59,22 @@ const GeneratedQuery = struct {
|
||||||
|
|
||||||
const UnifiedResult = struct {
|
const UnifiedResult = struct {
|
||||||
album_name: ?[]const u8 = null,
|
album_name: ?[]const u8 = null,
|
||||||
album_id: ?i32 = null,
|
album_id: ?i64 = null,
|
||||||
song_name: ?[]const u8 = null,
|
song_name: ?[]const u8 = null,
|
||||||
song_id: ?i32 = null,
|
song_id: ?i64 = null,
|
||||||
artist_name: ?[]const u8 = null,
|
artist_name: ?[]const u8 = null,
|
||||||
artist_id: ?i32 = null,
|
artist_id: ?i64 = null,
|
||||||
scrobbles: ?i64 = null,
|
scrobbles: ?i64 = null,
|
||||||
date: ?[]const u8 = null,
|
date: ?[]const u8 = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const EntityInfoResult = struct {
|
const EntityInfoResult = struct {
|
||||||
album_name: ?[]const u8 = null,
|
album_name: ?[]const u8 = null,
|
||||||
album_id: ?i32 = null,
|
album_id: ?i64 = null,
|
||||||
song_name: ?[]const u8 = null,
|
song_name: ?[]const u8 = null,
|
||||||
song_id: ?i32 = null,
|
song_id: ?i64 = null,
|
||||||
artist_name: ?[]const u8 = null,
|
artist_name: ?[]const u8 = null,
|
||||||
artist_id: ?i32 = null,
|
artist_id: ?i64 = null,
|
||||||
scrobbles: ?i64 = null,
|
scrobbles: ?i64 = null,
|
||||||
date: ?[]const u8 = null,
|
date: ?[]const u8 = null,
|
||||||
rank: []const u8,
|
rank: []const u8,
|
||||||
|
|
|
||||||
|
|
@ -133,5 +133,5 @@ pub const TableRow = struct {
|
||||||
|
|
||||||
pub const HyperlinkData = struct {
|
pub const HyperlinkData = struct {
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
id: i32,
|
id: i64,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue