Rename Authorship entity to Edit

As we now have a separate Author entity, which holds information
about an author (the color), the Authorship name became confusing.
Edit seems to be a better name, as the entity saves information
about a change in a note.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-05-31 21:46:41 +02:00
parent 5846ca75a9
commit b2d37abf6c
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
19 changed files with 67 additions and 73 deletions

View file

@ -198,8 +198,8 @@ export class NotesService {
return await this.userRepository
.createQueryBuilder('user')
.innerJoin('user.authors', 'author')
.innerJoin('author.authorships', 'authorship')
.innerJoin('authorship.revisions', 'revision')
.innerJoin('author.edits', 'edit')
.innerJoin('edit.revisions', 'revision')
.innerJoin('revision.note', 'note')
.where('note.id = :id', { id: note.id })
.getMany();
@ -322,14 +322,14 @@ export class NotesService {
*/
async calculateUpdateUser(note: Note): Promise<User | null> {
const lastRevision = await this.getLatestRevision(note);
if (lastRevision && lastRevision.authorships) {
// Sort the last Revisions Authorships by their updatedAt Date to get the latest one
// the user of that Authorship is the updateUser
return lastRevision.authorships.sort(
if (lastRevision && lastRevision.edits) {
// Sort the last Revisions Edits by their updatedAt Date to get the latest one
// the user of that Edit is the updateUser
return lastRevision.edits.sort(
(a, b) => b.updatedAt.getTime() - a.updatedAt.getTime(),
)[0].author.user;
}
// If there are no Authorships, the owner is the updateUser
// If there are no Edits, the owner is the updateUser
return note.owner;
}