mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
style(mail-ingest): wrap the repository lines the way prettier does
The new repositories and their tests held a few lines past the 120-column print width.
This commit is contained in:
@@ -151,7 +151,11 @@ export class MailIngestCandidatesRepository extends TrekRepository<MailIngestCan
|
||||
}
|
||||
|
||||
async findById(id: number): Promise<MailIngestCandidateRow | null> {
|
||||
const row = await this.db().selectFrom('mail_ingest_candidates').selectAll().where('id', '=', id).executeTakeFirst();
|
||||
const row = await this.db()
|
||||
.selectFrom('mail_ingest_candidates')
|
||||
.selectAll()
|
||||
.where('id', '=', id)
|
||||
.executeTakeFirst();
|
||||
return row ?? null;
|
||||
}
|
||||
|
||||
@@ -208,7 +212,7 @@ export class MailIngestCandidatesRepository extends TrekRepository<MailIngestCan
|
||||
return Number(row.n);
|
||||
}
|
||||
|
||||
/** Whether a booking of this content was added to the trip from a mail and undone: it is not added on its own again. */
|
||||
/** Whether a booking of this content went into the trip from a mail and was undone: never added again on its own. */
|
||||
async wasUndoneInTrip(tripId: number, contentHash: string): Promise<boolean> {
|
||||
const row = await this.db()
|
||||
.selectFrom('mail_ingest_candidates')
|
||||
@@ -328,7 +332,11 @@ export class MailIngestCandidatesRepository extends TrekRepository<MailIngestCan
|
||||
if (confirmation) either.push(eb('confirmation_number', '=', confirmation));
|
||||
if (startFrom && startTo) {
|
||||
either.push(
|
||||
eb.and([eb('type', '=', type), eb('reservation_time', '>=', startFrom), eb('reservation_time', '<=', startTo)]),
|
||||
eb.and([
|
||||
eb('type', '=', type),
|
||||
eb('reservation_time', '>=', startFrom),
|
||||
eb('reservation_time', '<=', startTo),
|
||||
]),
|
||||
);
|
||||
}
|
||||
// An empty list reads as false: a probe with neither names nothing.
|
||||
|
||||
@@ -30,7 +30,11 @@ export class MailIngestPrefsRepository extends TrekRepository<MailIngestPrefs> {
|
||||
}
|
||||
|
||||
async findForUser(userId: number): Promise<MailIngestPrefsRow | null> {
|
||||
const row = await this.db().selectFrom('mail_ingest_prefs').selectAll().where('user_id', '=', userId).executeTakeFirst();
|
||||
const row = await this.db()
|
||||
.selectFrom('mail_ingest_prefs')
|
||||
.selectAll()
|
||||
.where('user_id', '=', userId)
|
||||
.executeTakeFirst();
|
||||
return row ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,13 @@ describe('MailIngestAddressesRepository', () => {
|
||||
it('revokes the live address of one scope only, and still finds a revoked token', async () => {
|
||||
const { user } = await makeUser(t);
|
||||
const trip = await makeTrip(t, user.id);
|
||||
const own = await addresses.insertAddress({ userId: user.id, tripId: null, tokenHash: 'a', tokenEnc: 'x', createdAt: AT });
|
||||
const own = await addresses.insertAddress({
|
||||
userId: user.id,
|
||||
tripId: null,
|
||||
tokenHash: 'a',
|
||||
tokenEnc: 'x',
|
||||
createdAt: AT,
|
||||
});
|
||||
await addresses.insertAddress({ userId: user.id, tripId: trip.id, tokenHash: 'b', tokenEnc: 'y', createdAt: AT });
|
||||
|
||||
expect(await addresses.revokeLive(user.id, null, LATER)).toBe(1);
|
||||
@@ -77,7 +83,13 @@ describe('MailIngestAddressesRepository', () => {
|
||||
|
||||
it('notes when a mail came in', async () => {
|
||||
const { user } = await makeUser(t);
|
||||
const id = await addresses.insertAddress({ userId: user.id, tripId: null, tokenHash: 'c', tokenEnc: 'z', createdAt: AT });
|
||||
const id = await addresses.insertAddress({
|
||||
userId: user.id,
|
||||
tripId: null,
|
||||
tokenHash: 'c',
|
||||
tokenEnc: 'z',
|
||||
createdAt: AT,
|
||||
});
|
||||
await addresses.touchUsed(id, LATER);
|
||||
expect((await addresses.findById(id))?.last_used_at).toBe(LATER);
|
||||
});
|
||||
|
||||
@@ -203,7 +203,12 @@ describe('MailIngestCandidatesRepository: what it reads of the trips', () => {
|
||||
|
||||
it('reads the person a mail is for', async () => {
|
||||
const { user } = await makeUser(t, { username: 'mia', email: 'mia@example.com' });
|
||||
expect(await candidates.findPerson(user.id)).toEqual({ id: user.id, username: 'mia', email: 'mia@example.com', role: 'user' });
|
||||
expect(await candidates.findPerson(user.id)).toEqual({
|
||||
id: user.id,
|
||||
username: 'mia',
|
||||
email: 'mia@example.com',
|
||||
role: 'user',
|
||||
});
|
||||
expect(await candidates.findPerson(user.id + 100)).toBeNull();
|
||||
});
|
||||
|
||||
@@ -218,8 +223,9 @@ describe('MailIngestCandidatesRepository: what it reads of the trips', () => {
|
||||
external_id: 'ABC123|flight|2027-03-01|hnd-itm',
|
||||
});
|
||||
|
||||
expect(await candidates.tripHasExternal(trip.id, ['import', 'mail'], 'ABC123|flight|2027-03-01|hnd-itm')).toBe(true);
|
||||
expect(await candidates.tripHasExternal(trip.id, ['import'], 'ABC123|flight|2027-03-01|hnd-itm')).toBe(false);
|
||||
const key = 'ABC123|flight|2027-03-01|hnd-itm';
|
||||
expect(await candidates.tripHasExternal(trip.id, ['import', 'mail'], key)).toBe(true);
|
||||
expect(await candidates.tripHasExternal(trip.id, ['import'], key)).toBe(false);
|
||||
|
||||
const none = { type: 'flight', startFrom: null, startTo: null, confirmation: null };
|
||||
expect(await candidates.tripHasSimilar(trip.id, none)).toBe(false);
|
||||
|
||||
@@ -125,7 +125,12 @@ describe('MailIngestMessagesRepository', () => {
|
||||
expect(await messages.claimDue(at('2026-11-01T12:00:00Z'), lease, 3)).toEqual([id]);
|
||||
|
||||
await messages.finish(id!, DONE);
|
||||
expect(await messages.findById(id!)).toMatchObject({ status: 'processed', ai_used: 1, from_verified: 1, lease_until: null });
|
||||
expect(await messages.findById(id!)).toMatchObject({
|
||||
status: 'processed',
|
||||
ai_used: 1,
|
||||
from_verified: 1,
|
||||
lease_until: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('purges a mail once it is done and nothing waits on it, and always after the hard limit', async () => {
|
||||
|
||||
Reference in New Issue
Block a user