Skip to content

Commit 7232097

Browse files
committed
chore: clean up repos
1 parent c3b1b2e commit 7232097

16 files changed

+294
-288
lines changed

Diff for: e2e/src/api/specs/map.e2e-spec.ts

+11-25
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,24 @@ describe('/map', () => {
2222
websocket = await utils.connectWebsocket(admin.accessToken);
2323

2424
asset = await utils.createAsset(admin.accessToken);
25+
26+
const files = ['formats/heic/IMG_2682.heic', 'metadata/gps-position/thompson-springs.jpg'];
27+
utils.resetEvents();
28+
const uploadFile = async (input: string) => {
29+
const filepath = join(testAssetDir, input);
30+
const { id } = await utils.createAsset(admin.accessToken, {
31+
assetData: { bytes: await readFile(filepath), filename: basename(filepath) },
32+
});
33+
await utils.waitForWebsocketEvent({ event: 'assetUpload', id });
34+
};
35+
await Promise.all(files.map((f) => uploadFile(f)));
2536
});
2637

2738
afterAll(() => {
2839
utils.disconnectWebsocket(websocket);
2940
});
3041

3142
describe('GET /map/markers', () => {
32-
beforeAll(async () => {
33-
const files = [
34-
'formats/avif/8bit-sRGB.avif',
35-
'formats/jpg/el_torcal_rocks.jpg',
36-
'formats/jxl/8bit-sRGB.jxl',
37-
'formats/heic/IMG_2682.heic',
38-
'formats/png/density_plot.png',
39-
'formats/raw/Nikon/D80/glarus.nef',
40-
'formats/raw/Nikon/D700/philadelphia.nef',
41-
'formats/raw/Panasonic/DMC-GH4/4_3.rw2',
42-
'formats/raw/Sony/ILCE-6300/12bit-compressed-(3_2).arw',
43-
'formats/raw/Sony/ILCE-7M2/14bit-uncompressed-(3_2).arw',
44-
];
45-
utils.resetEvents();
46-
const uploadFile = async (input: string) => {
47-
const filepath = join(testAssetDir, input);
48-
const { id } = await utils.createAsset(admin.accessToken, {
49-
assetData: { bytes: await readFile(filepath), filename: basename(filepath) },
50-
});
51-
await utils.waitForWebsocketEvent({ event: 'assetUpload', id });
52-
};
53-
const uploads = files.map((f) => uploadFile(f));
54-
await Promise.all(uploads);
55-
}, 30_000);
56-
5743
it('should require authentication', async () => {
5844
const { status, body } = await request(app).get('/map/markers');
5945
expect(status).toBe(401);

Diff for: mobile/lib/services/api.service.dart

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ApiService {
1919
late AssetApi assetApi;
2020
late SearchApi searchApi;
2121
late ServerInfoApi serverInfoApi;
22+
late MapApi mapApi;
2223
late PartnerApi partnerApi;
2324
late PersonApi personApi;
2425
late AuditApi auditApi;
@@ -50,6 +51,7 @@ class ApiService {
5051
assetApi = AssetApi(_apiClient);
5152
serverInfoApi = ServerInfoApi(_apiClient);
5253
searchApi = SearchApi(_apiClient);
54+
mapApi = MapApi(_apiClient);
5355
partnerApi = PartnerApi(_apiClient);
5456
personApi = PersonApi(_apiClient);
5557
auditApi = AuditApi(_apiClient);

Diff for: mobile/lib/services/map.service.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MapSerivce with ErrorLoggerMixin {
1919
}) async {
2020
return logError(
2121
() async {
22-
final markers = await _apiService.assetApi.getMapMarkers(
22+
final markers = await _apiService.mapApi.getMapMarkers(
2323
isFavorite: isFavorite,
2424
isArchived: withArchived,
2525
withPartners: withPartners,

Diff for: server/src/interfaces/asset.interface.ts

-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { AssetOrder } from 'src/entities/album.entity';
22
import { AssetJobStatusEntity } from 'src/entities/asset-job-status.entity';
33
import { AssetEntity, AssetType } from 'src/entities/asset.entity';
44
import { ExifEntity } from 'src/entities/exif.entity';
5-
import { ReverseGeocodeResult } from 'src/interfaces/metadata.interface';
65
import { AssetSearchOptions, SearchExploreItem } from 'src/interfaces/search.interface';
76
import { Paginated, PaginationOptions } from 'src/utils/pagination';
87
import { FindOptionsOrder, FindOptionsRelations, FindOptionsSelect } from 'typeorm';
@@ -22,19 +21,6 @@ export interface LivePhotoSearchOptions {
2221
type: AssetType;
2322
}
2423

25-
export interface MapMarkerSearchOptions {
26-
isArchived?: boolean;
27-
isFavorite?: boolean;
28-
fileCreatedBefore?: Date;
29-
fileCreatedAfter?: Date;
30-
}
31-
32-
export interface MapMarker extends ReverseGeocodeResult {
33-
id: string;
34-
lat: number;
35-
lon: number;
36-
}
37-
3824
export enum WithoutProperty {
3925
THUMBNAIL = 'thumbnail',
4026
ENCODED_VIDEO = 'encoded-video',
@@ -195,7 +181,6 @@ export interface IAssetRepository {
195181
softDeleteAll(ids: string[]): Promise<void>;
196182
restoreAll(ids: string[]): Promise<void>;
197183
findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null>;
198-
getMapMarkers(ownerIds: string[], albumIds: string[], options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
199184
getStatistics(ownerId: string, options: AssetStatsOptions): Promise<AssetStats>;
200185
getTimeBuckets(options: TimeBucketOptions): Promise<TimeBucketItem[]>;
201186
getTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]>;

Diff for: server/src/interfaces/map.interface.ts

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
export const IMapRepository = 'IMapRepository';
22

3+
export interface MapMarkerSearchOptions {
4+
isArchived?: boolean;
5+
isFavorite?: boolean;
6+
fileCreatedBefore?: Date;
7+
fileCreatedAfter?: Date;
8+
}
9+
10+
export interface GeoPoint {
11+
latitude: number;
12+
longitude: number;
13+
}
14+
15+
export interface ReverseGeocodeResult {
16+
country: string | null;
17+
state: string | null;
18+
city: string | null;
19+
}
20+
21+
export interface MapMarker extends ReverseGeocodeResult {
22+
id: string;
23+
lat: number;
24+
lon: number;
25+
}
26+
327
export interface IMapRepository {
28+
init(): Promise<void>;
29+
reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult | null>;
30+
getMapMarkers(ownerIds: string[], albumIds: string[], options?: MapMarkerSearchOptions): Promise<MapMarker[]>;
431
fetchStyle(url: string): Promise<any>;
532
}

Diff for: server/src/interfaces/metadata.interface.ts

-13
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ import { BinaryField, Tags } from 'exiftool-vendored';
22

33
export const IMetadataRepository = 'IMetadataRepository';
44

5-
export interface GeoPoint {
6-
latitude: number;
7-
longitude: number;
8-
}
9-
10-
export interface ReverseGeocodeResult {
11-
country: string | null;
12-
state: string | null;
13-
city: string | null;
14-
}
15-
165
export interface ExifDuration {
176
Value: number;
187
Scale?: number;
@@ -33,9 +22,7 @@ export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration'> {
3322
}
3423

3524
export interface IMetadataRepository {
36-
init(): Promise<void>;
3725
teardown(): Promise<void>;
38-
reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult | null>;
3926
readTags(path: string): Promise<ImmichTags | null>;
4027
writeTags(path: string, tags: Partial<Tags>): Promise<void>;
4128
extractBinaryTag(tagName: string, path: string): Promise<Buffer>;

Diff for: server/src/repositories/asset.repository.ts

+1-54
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import {
2121
AssetUpdateOptions,
2222
IAssetRepository,
2323
LivePhotoSearchOptions,
24-
MapMarker,
25-
MapMarkerSearchOptions,
2624
MonthDay,
2725
TimeBucketItem,
2826
TimeBucketOptions,
@@ -31,7 +29,7 @@ import {
3129
WithoutProperty,
3230
} from 'src/interfaces/asset.interface';
3331
import { AssetSearchOptions, SearchExploreItem } from 'src/interfaces/search.interface';
34-
import { OptionalBetween, searchAssetBuilder } from 'src/utils/database';
32+
import { searchAssetBuilder } from 'src/utils/database';
3533
import { Instrumentation } from 'src/utils/instrumentation';
3634
import { Paginated, PaginationMode, PaginationOptions, paginate, paginatedBuilder } from 'src/utils/pagination';
3735
import {
@@ -547,57 +545,6 @@ export class AssetRepository implements IAssetRepository {
547545
});
548546
}
549547

550-
async getMapMarkers(
551-
ownerIds: string[],
552-
albumIds: string[],
553-
options: MapMarkerSearchOptions = {},
554-
): Promise<MapMarker[]> {
555-
const { isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore } = options;
556-
557-
const where = {
558-
isVisible: true,
559-
isArchived,
560-
exifInfo: {
561-
latitude: Not(IsNull()),
562-
longitude: Not(IsNull()),
563-
},
564-
isFavorite,
565-
fileCreatedAt: OptionalBetween(fileCreatedAfter, fileCreatedBefore),
566-
};
567-
568-
const assets = await this.repository.find({
569-
select: {
570-
id: true,
571-
exifInfo: {
572-
city: true,
573-
state: true,
574-
country: true,
575-
latitude: true,
576-
longitude: true,
577-
},
578-
},
579-
where: [
580-
{ ...where, ownerId: In([...ownerIds]) },
581-
{ ...where, albums: { id: In([...albumIds]) } },
582-
],
583-
relations: {
584-
exifInfo: true,
585-
},
586-
order: {
587-
fileCreatedAt: 'DESC',
588-
},
589-
});
590-
591-
return assets.map((asset) => ({
592-
id: asset.id,
593-
lat: asset.exifInfo!.latitude!,
594-
lon: asset.exifInfo!.longitude!,
595-
city: asset.exifInfo!.city,
596-
state: asset.exifInfo!.state,
597-
country: asset.exifInfo!.country,
598-
}));
599-
}
600-
601548
async getStatistics(ownerId: string, options: AssetStatsOptions): Promise<AssetStats> {
602549
const builder = this.repository
603550
.createQueryBuilder('asset')

0 commit comments

Comments
 (0)