generated from didinele/typescript-docker-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
261 additions
and
1,947 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Selectable } from 'kysely'; | ||
import type { Experiment, ExperimentOverride } from '../db.js'; | ||
|
||
export type ExperimentWithOverrides = Selectable<Experiment> & { overrides: Selectable<ExperimentOverride>[] }; | ||
|
||
/** | ||
* Abstraction over all database interactions (things like Redis included) | ||
*/ | ||
export abstract class IDataManager { | ||
public abstract getExperiments(): Promise<ExperimentWithOverrides[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Kysely } from 'kysely'; | ||
import { jsonArrayFrom } from 'kysely/helpers/postgres'; | ||
import type { DB } from '../db.js'; | ||
import { IDataManager, type ExperimentWithOverrides } from './IDataManager.js'; | ||
|
||
/** | ||
* Our current databse implementation, using kysely with types generated by prisma-kysely | ||
*/ | ||
export class KyselyDataManager extends IDataManager { | ||
readonly #database: Kysely<DB>; | ||
|
||
// Note that we avoid using an actual dependency. This is because we don't really want to expose database | ||
// into our container. An implementation over IDataHandler should always be used. | ||
public constructor(database: Kysely<DB>) { | ||
super(); | ||
|
||
this.#database = database; | ||
} | ||
|
||
public override async getExperiments(): Promise<ExperimentWithOverrides[]> { | ||
return this.#database | ||
.selectFrom('Experiment') | ||
.selectAll() | ||
.select((query) => [ | ||
jsonArrayFrom( | ||
query | ||
.selectFrom('ExperimentOverride') | ||
.selectAll('ExperimentOverride') | ||
.whereRef('Experiment.name', '=', 'ExperimentOverride.experimentName'), | ||
).as('overrides'), | ||
]) | ||
.execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# binary-encoding | ||
|
||
Custom encoding we use for storing cache. | ||
Custom encoding we use for storing Discord data cache. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.