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

Dev/version control resource -> codecov #470

Merged
merged 197 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
cfaae4f
Created empty version_control resource
jakeweatherhead Sep 11, 2023
6df880a
Updated file with boilerplate code
jakeweatherhead Sep 12, 2023
8d9ee9e
Deleted module file for version_control service
jakeweatherhead Sep 12, 2023
afab349
Added snapshot array creation
jakeweatherhead Sep 12, 2023
e0c7c21
Added calls to delete all diffs and snapshots
jakeweatherhead Sep 12, 2023
1b3917e
Laid out plan for getters and setters
jakeweatherhead Sep 12, 2023
772d3ed
Updated error message
jakeweatherhead Sep 12, 2023
df79785
Added calls to delete all diffs and snapshots
jakeweatherhead Sep 12, 2023
fdd0b14
Removed debugging statements
jakeweatherhead Sep 12, 2023
3a4e2b3
Added functions for finding logical order of circular array
jakeweatherhead Sep 15, 2023
b1b9f32
Updated function name to be more descriptive
jakeweatherhead Sep 15, 2023
8e6d366
Updated function calls to match new s3service names
jakeweatherhead Sep 15, 2023
a71e61a
Separated one function into two
jakeweatherhead Sep 15, 2023
924451a
Added conceptual skeletion of what controller will offer
jakeweatherhead Sep 15, 2023
9411ed2
Added docs for getAllSnapshots
jakeweatherhead Sep 15, 2023
ad84e19
Diff and Snapshot array getters
dylankapnias-uni Sep 16, 2023
d459414
Diff and Snapshot array setters
dylankapnias-uni Sep 16, 2023
2e39213
Push to Diff and Snapshot arrays
dylankapnias-uni Sep 16, 2023
6be1492
MockData for testing created
dylankapnias-uni Sep 16, 2023
3e50340
Hijacked login button for testing
dylankapnias-uni Sep 16, 2023
11f199c
Initialising of MockData
dylankapnias-uni Sep 16, 2023
81d6f6c
mini refactor to use setter
dylankapnias-uni Sep 16, 2023
fe45386
Building version from snapshot
dylankapnias-uni Sep 16, 2023
d7f8082
Building of diff version and context
dylankapnias-uni Sep 16, 2023
2288601
Visualise complete?
dylankapnias-uni Sep 16, 2023
fc40ddc
Removed old functionality
dylankapnias-uni Sep 16, 2023
58e40b9
Modularised getting of a readable patch
dylankapnias-uni Sep 16, 2023
3c4be2f
Modularised sorting
dylankapnias-uni Sep 16, 2023
68de4fb
Theoretical restore functionality
dylankapnias-uni Sep 16, 2023
5200cf6
Merge pull request #465 from COS301-SE-2023/codecov
jakeweatherhead Sep 16, 2023
f6c84ab
Created new diff dto
jakeweatherhead Sep 16, 2023
f929a0e
Updated names to new s3service naming scheme
jakeweatherhead Sep 16, 2023
84c6d2b
Imported new diff dto
jakeweatherhead Sep 16, 2023
eb75bcc
Imported new diff dto
jakeweatherhead Sep 16, 2023
c2aae46
Un-hijacked the login button
dylankapnias-uni Sep 16, 2023
ac68259
Merge pull request #466 from COS301-SE-2023/dev/version_service
jakeweatherhead Sep 16, 2023
5521d36
Added functions for logical to s3 array conversion
jakeweatherhead Sep 16, 2023
febabc0
Updated data type of UserID to number
jakeweatherhead Sep 16, 2023
fa0869d
Updated UserID data type to number
jakeweatherhead Sep 16, 2023
b734bf8
Updated names of function calls
jakeweatherhead Sep 16, 2023
9eb669b
Updated the names of function calls
jakeweatherhead Sep 16, 2023
add3ab1
Changed UserID data type to number
jakeweatherhead Sep 16, 2023
fbc2029
Changed UserID data type to number
jakeweatherhead Sep 16, 2023
a89e525
Added functions to get head diff/snapshot in array
jakeweatherhead Sep 16, 2023
3cced63
Increased timeout for jest tests
jakeweatherhead Sep 17, 2023
441f765
Added function: updateDiff to update diff metadata
jakeweatherhead Sep 17, 2023
d897bec
Removed redundant column from diff entity
jakeweatherhead Sep 17, 2023
e71642f
Added function to increment head of circular array
jakeweatherhead Sep 17, 2023
44dd81c
Added function: getAllDiffsForSnapshot
jakeweatherhead Sep 17, 2023
0e367ed
Created dto for single snapshot
jakeweatherhead Sep 17, 2023
e366dd4
Updated parameters of various functions
jakeweatherhead Sep 17, 2023
df54ba7
Fixed repository dependency issues
jakeweatherhead Sep 17, 2023
591c28d
Added logic to saveDiff/Snapshot functions
jakeweatherhead Sep 17, 2023
a48964f
Solved dependency issues
jakeweatherhead Sep 18, 2023
0902137
Added function: createDiffs in database
jakeweatherhead Sep 18, 2023
9bb2093
Basic test for saving diffs
JulianPienaar Sep 18, 2023
bc0eff3
Solved dependency issues
jakeweatherhead Sep 18, 2023
1895212
Merge branch 'dev/version_control_resource' of https://github.com/COS…
JulianPienaar Sep 18, 2023
8c6e529
Added calls to versioning functions
jakeweatherhead Sep 18, 2023
c83eee7
Merge branch 'dev/version_control_resource' of https://github.com/COS…
jakeweatherhead Sep 18, 2023
23bca55
Added calls to versioning functions
jakeweatherhead Sep 18, 2023
9c4c7c9
Removed functions from createFile function
jakeweatherhead Sep 18, 2023
a4a6408
Added function createSnapshots to create refs in db
jakeweatherhead Sep 18, 2023
48501eb
Removed redundant DisplayID field
jakeweatherhead Sep 18, 2023
9190d9a
Fixes to saving diff
JulianPienaar Sep 18, 2023
a6bbcbd
Created module file for VersionControl
jakeweatherhead Sep 18, 2023
600e626
Merge branch 'dev/version_control_resource' of https://github.com/COS…
jakeweatherhead Sep 18, 2023
7e660d7
Linked VersionControl endpoints
jakeweatherhead Sep 18, 2023
0677f4d
Added debugging statements
jakeweatherhead Sep 18, 2023
9dae74e
Removed stale comment
jakeweatherhead Sep 18, 2023
ec2b374
Retrieve all snapshots
JulianPienaar Sep 18, 2023
81a0493
Fixed snapshot dto
JulianPienaar Sep 18, 2023
871a5c6
FileID refactored to markdownID
JulianPienaar Sep 18, 2023
445c3e1
Updated nomenclature
jakeweatherhead Sep 18, 2023
a04062b
Logging response from retrieve all snapshots
JulianPienaar Sep 18, 2023
95d9c1f
Created version_history dto
jakeweatherhead Sep 18, 2023
c3c5d9a
Refactored obj naming
JulianPienaar Sep 18, 2023
aa48b65
Added retrieve all history endpoint
JulianPienaar Sep 18, 2023
4dcc3b9
Calling retrieve all history
JulianPienaar Sep 18, 2023
f0687d2
Added userid field to retrieve all history
JulianPienaar Sep 18, 2023
52233dd
Changed parameter for updateDiff
jakeweatherhead Sep 18, 2023
417ef52
Added function: retrieveAllSnapshots
jakeweatherhead Sep 18, 2023
516d8c8
Implemented load_history endpoint
jakeweatherhead Sep 18, 2023
de6a8a4
Added function: getAllSnapshots
jakeweatherhead Sep 18, 2023
b3e8062
Added function: getAllSnapshots
jakeweatherhead Sep 18, 2023
5939bd9
Outputting all history in one array
JulianPienaar Sep 18, 2023
bc50ed1
Added HasBeenUsed attribute
jakeweatherhead Sep 19, 2023
4edd447
Retrieve only initialised diffs
jakeweatherhead Sep 19, 2023
74e2f4c
Retrieve only initialised snapshots
jakeweatherhead Sep 19, 2023
ca84fd7
Fixed .env reference to MAX_SNAPSHOTS
jakeweatherhead Sep 19, 2023
30c0db2
Provided default value for new attribute: HasBeenUsed
jakeweatherhead Sep 19, 2023
6ea9675
On first update, set HasBeenUsed to true
jakeweatherhead Sep 19, 2023
ff1968b
Added support for new attribute HasBeenUsed
jakeweatherhead Sep 19, 2023
44dc482
Now using last modified field
JulianPienaar Sep 19, 2023
e5e160c
Testing data sent on save_diff
JulianPienaar Sep 19, 2023
e6eeae5
Reformatted the way in which history gets stored
JulianPienaar Sep 19, 2023
dc71036
Update to dto
JulianPienaar Sep 19, 2023
8d45e00
Now sending snapshotpayload on save diff
JulianPienaar Sep 19, 2023
2283f8c
Added SnapshotID field in dto
jakeweatherhead Sep 19, 2023
3d8db8f
Added logic for returning snapshots to the frontend
jakeweatherhead Sep 19, 2023
77c349a
Added functionality to match diffs to snapshots
jakeweatherhead Sep 19, 2023
95bb3cb
Handling of initial diffs
JulianPienaar Sep 19, 2023
c868382
Changing to deep copy of response
JulianPienaar Sep 19, 2023
e383279
Added dropdown arrow
JulianPienaar Sep 19, 2023
e4e249f
Dropdown of snapshots to diffs now works
JulianPienaar Sep 19, 2023
c9f3074
Better representation of snapshot
JulianPienaar Sep 19, 2023
56c3700
Save confirmation
JulianPienaar Sep 19, 2023
2cc0a9f
Implemented Contrast adjustment
JulianPienaar Sep 19, 2023
4909413
Fix to contrast adjustment
JulianPienaar Sep 19, 2023
fa7003e
Photo editing is complete
JulianPienaar Sep 19, 2023
4814133
numbering starts from 1 now
JulianPienaar Sep 19, 2023
9e4e1a2
Fixed snapshot creation issue
jakeweatherhead Sep 19, 2023
e65fc4e
Commented out deprecated function
jakeweatherhead Sep 19, 2023
8441971
Await asynchronous call to update markdown file
jakeweatherhead Sep 19, 2023
dd3bd9d
Added function: getDiff
jakeweatherhead Sep 19, 2023
7778bbe
Simplified logic using De Morgan's equivalent
jakeweatherhead Sep 20, 2023
fa3e08e
Added DTO for version content transfer
JulianPienaar Sep 20, 2023
c7b7f95
Created backend version_set dto
jakeweatherhead Sep 20, 2023
1022e7b
Corrected name of dto
jakeweatherhead Sep 20, 2023
22c90c1
Created function to retrieve history content set
JulianPienaar Sep 20, 2023
d8dcc59
Merge branch 'dev/version_control_resource' of https://github.com/COS…
JulianPienaar Sep 20, 2023
8117aab
Renamed function for consistency
JulianPienaar Sep 20, 2023
ffea860
Added shift mouse wheel to zoom
JulianPienaar Sep 20, 2023
2310b29
Can now save with ctrl s
JulianPienaar Sep 20, 2023
0d12f5b
Removed console logs
JulianPienaar Sep 20, 2023
c78b108
Fixed conflicts?
dylankapnias-uni Sep 20, 2023
e980abf
Merge branch 'dev/version_control_resource' of https://github.com/COS…
dylankapnias-uni Sep 20, 2023
e64859d
Now we don't send the snapshot twice on save
JulianPienaar Sep 20, 2023
707e794
Removed space
dylankapnias-uni Sep 20, 2023
e2d9636
uncommented some logic
dylankapnias-uni Sep 20, 2023
4698c6a
Added functions for ordering circular array logically
jakeweatherhead Sep 20, 2023
c2b7817
Added various functions for retrieving diffs and snapshots
jakeweatherhead Sep 20, 2023
10d9c4d
variable name refactor
dylankapnias-uni Sep 20, 2023
67eda7a
Added creation of addtional base snapshot
jakeweatherhead Sep 20, 2023
cf92264
Merge branch 'dev/version_control_resource' of https://github.com/COS…
dylankapnias-uni Sep 20, 2023
cf65ff5
Added OldestSnapshot boolean
jakeweatherhead Sep 20, 2023
7144608
Added various versioning functions
jakeweatherhead Sep 20, 2023
6747dd8
Added boolean logic changes
jakeweatherhead Sep 20, 2023
3ae0d8b
Added an OldestSnapshot field
jakeweatherhead Sep 20, 2023
ce20703
Merge branch 'dev/version_control_resource' of https://github.com/COS…
dylankapnias-uni Sep 20, 2023
2c9e86d
Created service to handle http requests to backend
JulianPienaar Sep 20, 2023
a3a3155
Moved over functionality to versioning-api service
JulianPienaar Sep 20, 2023
9a494ea
Refactored previousVersion
dylankapnias-uni Sep 20, 2023
5ad6df0
Merge branch 'dev/version_control_resource' of https://github.com/COS…
dylankapnias-uni Sep 20, 2023
3e00667
linter fixes
dylankapnias-uni Sep 20, 2023
48c602f
linter fixes
dylankapnias-uni Sep 20, 2023
8d3c487
Removed special case
jakeweatherhead Sep 20, 2023
929f911
More linter fixes
dylankapnias-uni Sep 20, 2023
e1e6eb8
Added support for safeLock
dylankapnias-uni Sep 20, 2023
620c010
Variable mismatch
dylankapnias-uni Sep 20, 2023
8dc1ef8
Added prev content
dylankapnias-uni Sep 20, 2023
96c6bab
Added await
jakeweatherhead Sep 20, 2023
029a1e0
Ran formatter
jakeweatherhead Sep 20, 2023
f7c6c52
Removed erroneous incrementation of nextDiffID
jakeweatherhead Sep 20, 2023
b45cc40
Removed old s3 call
jakeweatherhead Sep 20, 2023
a4b57ab
Removed creation of extra snapshot
jakeweatherhead Sep 20, 2023
ceb15e5
Refactor to DTO
dylankapnias-uni Sep 20, 2023
b316b7b
Deleted insertion of extra snapshot
jakeweatherhead Sep 20, 2023
6e5e9e6
Removed debugging statements
jakeweatherhead Sep 20, 2023
d535b97
Date format fixes
dylankapnias-uni Sep 20, 2023
11cdf1f
Sort direction change
dylankapnias-uni Sep 20, 2023
6b423bd
Order update
dylankapnias-uni Sep 20, 2023
c123df9
BUG FIX: Saving empty local storage
dylankapnias-uni Sep 20, 2023
729c9ca
Removed console log
dylankapnias-uni Sep 20, 2023
06fa156
Final order change
dylankapnias-uni Sep 20, 2023
8b91563
refactor for to map
dylankapnias-uni Sep 20, 2023
52dfeaa
Hopefully
dylankapnias-uni Sep 20, 2023
90da1ea
Hopefully fixed
dylankapnias-uni Sep 20, 2023
50a81be
BUG FIX: no longer logically sorting snapshots and diffs
jakeweatherhead Sep 20, 2023
00f2364
UI Change xD
dylankapnias-uni Sep 20, 2023
03b66ec
spacing changes
JulianPienaar Sep 20, 2023
1d13a3f
Reworked sorting
dylankapnias-uni Sep 20, 2023
f3e2bcd
Fixed spacing of diff object
JulianPienaar Sep 20, 2023
bf636ba
Removed repeated datetime
jakeweatherhead Sep 20, 2023
192d9b2
Updating version numbers
dylankapnias-uni Sep 20, 2023
8c5048a
Merge branch 'dev/version_control_resource' of https://github.com/COS…
dylankapnias-uni Sep 20, 2023
54847dc
Co-authored-by: Dylan Shane Kapnias <dylankapnias-uni@users.noreply.g…
jakeweatherhead Sep 20, 2023
2f56a1f
Added functions for versioning
jakeweatherhead Sep 20, 2023
03ba82b
Various updates
jakeweatherhead Sep 20, 2023
0876417
Bug fix
jakeweatherhead Sep 20, 2023
c0afa21
Added debugging statements
jakeweatherhead Sep 20, 2023
7cea7f3
Removed debugging statements
jakeweatherhead Sep 21, 2023
aad5b98
General maintenance
jakeweatherhead Sep 21, 2023
07e0054
Fixed timeout issues
jakeweatherhead Sep 21, 2023
b7eeda6
Fixed timeout issues
jakeweatherhead Sep 21, 2023
07a97ab
Fixed last failing unit test file
jakeweatherhead Sep 21, 2023
6a72da5
Minor reformatting
jakeweatherhead Sep 21, 2023
c0277a6
Added metadata reference for snapshots
jakeweatherhead Sep 21, 2023
38aa2fb
Patched failing integration test
jakeweatherhead Sep 21, 2023
854c675
WHen last asset gets deleted the spinner doesn't spin forever
JulianPienaar Sep 21, 2023
b0aa2ca
Added spinner on actions in home page
JulianPienaar Sep 21, 2023
5a87d33
Updated local storage on save
JulianPienaar Sep 21, 2023
c299e5d
Fixed some sonar issues
JulianPienaar Sep 21, 2023
46f6b00
More sonar fixes
JulianPienaar Sep 21, 2023
d6dd95b
New icons for diff and snapshots
JulianPienaar Sep 21, 2023
b68d280
Date and icon reformat
JulianPienaar Sep 21, 2023
0185d84
Implemented functionality to test versioning
JulianPienaar Sep 21, 2023
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 backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"testEnvironment": "node",
"testTimeout": 30000
}
}
14 changes: 14 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ import { TextractService } from './textract/textract.service';
import { ResetPasswordModule } from './reset_password/reset_password.module';
import { ResetPasswordRequest } from './reset_password/entities/reset_password_request.entity';
import { MailService } from './mail/mail.service';
import { DiffsService } from './diffs/diffs.service';
import { SnapshotService } from './snapshots/snapshots.service';
import { Diff } from './diffs/entities/diffs.entity';
import { Snapshot } from './snapshots/entities/snapshots.entity';
import { VersionControlModule } from './version_control/version_control.module';
import { VersionControlService } from './version_control/version_control.service';
import { VersionControlController } from './version_control/version_control.controller';

@Module({
imports: [
Expand All @@ -41,17 +48,21 @@ import { MailService } from './mail/mail.service';
TypeOrmModule.forFeature([
ResetPasswordRequest,
]),
TypeOrmModule.forFeature([Diff]),
TypeOrmModule.forFeature([Snapshot]),
MarkdownFilesModule,
FoldersModule,
S3Module,
FileManagerModule,
AssetManagerModule,
VersionControlModule,
ResetPasswordModule,
],
controllers: [
AuthController,
S3Controller,
FileManagerController,
VersionControlController
],
providers: [
FileManagerService,
Expand All @@ -62,6 +73,9 @@ import { MailService } from './mail/mail.service';
ConversionService,
TextractService,
MailService,
DiffsService,
SnapshotService,
VersionControlService,
],
})
export class AppModule {}
168 changes: 164 additions & 4 deletions backend/src/diffs/diffs.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,172 @@
import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { Diff } from "./entities/diffs.entity";
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Diff } from './entities/diffs.entity';
import 'dotenv/config';
import * as CryptoJS from 'crypto-js';
import { MarkdownFileDTO } from '../markdown_files/dto/markdown_file.dto';
import { DiffDTO } from './dto/diffs.dto';

@Injectable()
export class DiffsService {
constructor(
@InjectRepository(Diff)
private diffRepository: Repository<Diff>,
) {}

///===-----------------------------------------------------

async getDiff(
diffDTO: DiffDTO,
nextDiffID: number,
) {
const diff =
await this.diffRepository.findOne({
where: {
MarkdownID: diffDTO.MarkdownID,
S3DiffID: nextDiffID,
},
});

return diff;
}

///===-----------------------------------------------------

async updateDiff(
diffDTO: DiffDTO,
nextDiffID: number,
) {
// const diff =
// await this.diffRepository.findOne({
// where: {
// MarkdownID: diffDTO.MarkdownID,
// S3DiffID: nextDiffID,
// },
// });

const diff = await this.getDiff(
diffDTO,
nextDiffID,
);

diff.LastModified = new Date();
diff.HasBeenUsed = true;
await this.diffRepository.save(diff);
}

///===-----------------------------------------------------

async createDiffs(
markdownFileDTO: MarkdownFileDTO,
snapshotIDs: string[],
) {
const diffRecords = [];
let snapshotIndex = 0;
for (
let i = 0;
i < parseInt(process.env.MAX_DIFFS);
i++
) {
const diffID = CryptoJS.SHA256(
markdownFileDTO.UserID.toString() +
new Date().getTime().toString() +
i.toString(),
).toString();

if (
i %
parseInt(
process.env.DIFFS_PER_SNAPSHOT,
) ===
0 &&
i !== 0
) {
snapshotIndex++;
}

diffRecords.push({
DiffID: diffID,
MarkdownID: markdownFileDTO.MarkdownID,
UserID: markdownFileDTO.UserID,
S3DiffID: i,
HasBeenUsed: false,
SnapshotID: snapshotIDs[snapshotIndex],
});
}
await this.diffRepository.insert(diffRecords);
}

///===-----------------------------------------------------

async deleteDiffs(
markdownFileDTO: MarkdownFileDTO,
) {
await this.diffRepository.delete({
MarkdownID: markdownFileDTO.MarkdownID,
});
}

///===-----------------------------------------------------

async resetDiffs(
markdownID: string,
snapshotID: string,
) {
await this.diffRepository.update(
{
MarkdownID: markdownID,
SnapshotID: snapshotID,
},
{
HasBeenUsed: false,
},
);
}

///===-----------------------------------------------------

async getAllDiffs(markdownID: string) {
return await this.diffRepository.find({
where: {
MarkdownID: markdownID,
HasBeenUsed: true,
},
});
}

///===-----------------------------------------------------

getLogicalIndex(
s3Index: number,
nextDiffID: number,
arr_len: number,
): number {
return (
(s3Index - nextDiffID + arr_len) % arr_len
);
}

///===-----------------------------------------------------

async getLogicalDiffOrder(
diffDTOs: DiffDTO[],
nextDiffID: number,
) {
const arrLength = parseInt(
process.env.MAX_DIFFS,
);
const logicalOrder: DiffDTO[] = new Array(
arrLength,
).fill(0);
for (let idx = 0; idx < arrLength; idx++) {
const logicalIndex = this.getLogicalIndex(
diffDTOs[idx].S3DiffID,
nextDiffID,
arrLength,
);
logicalOrder[logicalIndex] = diffDTOs[idx];
}
return logicalOrder;
}
}
23 changes: 23 additions & 0 deletions backend/src/diffs/dto/diffs.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class DiffDTO {
DiffID: string;
MarkdownID: string;
UserID: number;
DisplayID: number;
S3DiffID: number;
LastModified: Date;
Content: string;
SnapshotPayload: string;
SnapshotID: string;

constructor() {
this.DiffID = undefined;
this.MarkdownID = undefined;
this.UserID = undefined;
this.DisplayID = undefined;
this.S3DiffID = undefined;
this.LastModified = undefined;
this.Content = undefined;
this.SnapshotPayload = undefined;
this.SnapshotID = undefined;
}
}
11 changes: 7 additions & 4 deletions backend/src/diffs/entities/diffs.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export class Diff {
MarkdownID: string;

@Column()
UserID: string;

@Column()
DisplayID: string;
UserID: number;

@Column()
S3DiffID: number;
Expand All @@ -27,4 +24,10 @@ export class Diff {
onUpdate: 'CURRENT_TIMESTAMP(3)',
})
LastModified: Date;

@Column()
HasBeenUsed: boolean;

@Column()
SnapshotID: string;
}
20 changes: 20 additions & 0 deletions backend/src/file_manager/__mocks__/file_manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { ExportDTO } from '../dto/export.dto';
import * as CryptoJS from 'crypto-js';
import { ConversionService } from '../../conversion/conversion.service';
import { ImportDTO } from '../dto/import.dto';
import { DiffsService } from '../../diffs/diffs.service';
import { SnapshotService } from '../../snapshots/snapshots.service';

@Injectable()
export class FileManagerServiceMock {
Expand All @@ -26,6 +28,8 @@ export class FileManagerServiceMock {
private s3service: S3Service,
private conversionService: ConversionService,
private userService: UsersService,
private diffsService: DiffsService,
private snapshotService: SnapshotService,
) {}

// File operations: ###########################################################
Expand Down Expand Up @@ -233,6 +237,22 @@ export class FileManagerServiceMock {
markdownFileDTO,
);

await this.s3service.deleteDiffObjectsForFile(
markdownFileDTO,
);

await this.s3service.deleteSnapshotObjectsForFile(
markdownFileDTO,
);

await this.diffsService.deleteDiffs(
markdownFileDTO,
);

await this.snapshotService.deleteSnapshots(
markdownFileDTO,
);

return this.markdownFilesService.remove(
markdownFileDTO,
);
Expand Down
14 changes: 14 additions & 0 deletions backend/src/file_manager/file_manager.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import { JwtService } from '@nestjs/jwt';
import { ResetPasswordService } from '../reset_password/reset_password.service';
import { ResetPasswordRequest } from '../reset_password/entities/reset_password_request.entity';
import { MailService } from '../mail/mail.service';
import { DiffsService } from '../diffs/diffs.service';
import { SnapshotService } from '../snapshots/snapshots.service';
import { Diff } from '../diffs/entities/diffs.entity';
import { Snapshot } from '../snapshots/entities/snapshots.entity';

describe('FileManagerController', () => {
let controller: FileManagerController;
Expand All @@ -54,6 +58,8 @@ describe('FileManagerController', () => {
JwtService,
ResetPasswordService,
MailService,
DiffsService,
SnapshotService,
{
provide: 'FileManagerService',
useValue: {
Expand All @@ -74,6 +80,14 @@ describe('FileManagerController', () => {
provide: getRepositoryToken(User),
useClass: Repository,
},
{
provide: getRepositoryToken(Diff),
useClass: Repository,
},
{
provide: getRepositoryToken(Snapshot),
useClass: Repository,
},
{
provide: getRepositoryToken(
ResetPasswordRequest,
Expand Down
8 changes: 8 additions & 0 deletions backend/src/file_manager/file_manager.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { S3ServiceMock } from '../s3/__mocks__/s3.service';
import { ResetPasswordService } from '../reset_password/reset_password.service';
import { ResetPasswordRequest } from '../reset_password/entities/reset_password_request.entity';
import { MailService } from '../mail/mail.service';
import { DiffsService } from '../diffs/diffs.service';
import { SnapshotService } from '../snapshots/snapshots.service';
import { Diff } from '../diffs/entities/diffs.entity';
import { Snapshot } from '../snapshots/entities/snapshots.entity';

@Module({
imports: [
Expand All @@ -24,6 +28,8 @@ import { MailService } from '../mail/mail.service';
TypeOrmModule.forFeature([
ResetPasswordRequest,
]),
TypeOrmModule.forFeature([Diff]),
TypeOrmModule.forFeature([Snapshot]),
],
controllers: [FileManagerController],
providers: [
Expand All @@ -37,6 +43,8 @@ import { MailService } from '../mail/mail.service';
S3ServiceMock,
ResetPasswordService,
MailService,
DiffsService,
SnapshotService,
],
})
export class FileManagerModule {}
Loading
Loading