Track and display build authors
All checks were successful
App Image CI / Build app image (pull_request) Successful in -1m26s
NPM Audit Check / Check NPM audit (pull_request) Successful in -2m14s

This commit is contained in:
2025-09-23 16:09:31 -05:00
parent 24d7b37583
commit b20bbf40fc
5 changed files with 41 additions and 24 deletions

View File

@@ -149,13 +149,24 @@ class DB {
}
});
this.build.belongsTo(this.user);
this.user.hasMany(this.build);
this.sync();
}
private async sync(): Promise<void> {
await this.user.sync();
await this.build.sync();
await this.logChunk.sync();
await this.user.sync();
if (!(await this.getUser('-1'))) {
await this.createUser({
id: '-1',
username: '???',
displayName: 'Anonymous User'
});
}
}
public async getUser(id: string): Promise<User> {
@@ -171,13 +182,14 @@ class DB {
return user.id;
}
public async createBuild(repo: string, commit: string, patch: string, distro: string, dependencies: string): Promise<number> {
public async createBuild(repo: string, commit: string, patch: string, distro: string, dependencies: string, author: string): Promise<number> {
const buildRec = await this.build.create({
repo,
commit: commit || null,
patch: patch || null,
distro,
dependencies
dependencies,
userId: author || '-1'
});
return buildRec.id;
}
@@ -224,14 +236,17 @@ class DB {
}
public async getBuild(id: number): Promise<Build> {
return await this.build.findByPk(id);
return await this.build.findByPk(id, {
include: this.user
});
}
public async getBuilds(): Promise<Build[]> {
return await this.build.findAll({
attributes: SELECT,
order: [['id', 'DESC']],
where: FRESH
where: FRESH,
include: this.user
});
}
@@ -242,7 +257,8 @@ class DB {
where: {
...FRESH,
status
}
},
include: this.user
});
}
@@ -253,7 +269,8 @@ class DB {
where: {
...FRESH,
distro
}
},
include: this.user
});
}
@@ -264,7 +281,8 @@ class DB {
where: {
...FRESH,
...filterable
}
},
include: this.user
});
}
@@ -287,7 +305,8 @@ class DB {
{ repo: { [Op.iLike]: `%${query}%` } }
]
},
limit: 100
limit: 100,
include: this.user
});
}