Skip to content

Commit

Permalink
Merge pull request #45 from Enigmatis/upgrade-typeorm
Browse files Browse the repository at this point in the history
Upgrade typeorm
  • Loading branch information
chenshoo authored Apr 21, 2020
2 parents 0e64197 + bcfd6de commit ecf682e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
39 changes: 19 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"@enigmatis/polaris-logs": "^2.8.2",
"@enigmatis/polaris-middlewares": "^1.3.5",
"@enigmatis/polaris-schema": "^1.1.0",
"@enigmatis/polaris-typeorm": "^2.3.1",
"apollo-server-express": "^2.11.0",
"@enigmatis/polaris-typeorm": "^2.3.4",
"apollo-server-express": "2.11.0",
"apollo-server-plugin-base": "^0.6.10",
"express": "^4.17.1",
"graphql": "^14.6.0",
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/snapshot/snapshot-listener.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { PolarisGraphQLContext, RealitiesHolder } from '@enigmatis/polaris-common';
import { PolarisGraphQLLogger } from '@enigmatis/polaris-graphql-logger';
import { getConnectionForReality, SnapshotPage } from '@enigmatis/polaris-typeorm';
import {
getConnectionForReality,
getPolarisConnectionManager,
SnapshotPage,
} from '@enigmatis/polaris-typeorm';
import { runHttpQuery } from 'apollo-server-core';
import { GraphQLOptions } from 'apollo-server-express';
import {
Expand Down Expand Up @@ -60,6 +64,7 @@ export class SnapshotListener implements GraphQLRequestListener<PolarisGraphQLCo
const snapshotRepository = getConnectionForReality(
requestHeaders.realityId!,
this.realitiesHolder,
getPolarisConnectionManager() as any,
).getRepository(SnapshotPage);
const pagesIds: string[] = [];

Expand Down
7 changes: 6 additions & 1 deletion src/server/polaris-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { PolarisGraphQLLogger } from '@enigmatis/polaris-graphql-logger';
import { AbstractPolarisLogger, LoggerConfiguration } from '@enigmatis/polaris-logs';
import { PolarisLoggerPlugin } from '@enigmatis/polaris-middlewares';
import { makeExecutablePolarisSchema } from '@enigmatis/polaris-schema';
import { getConnectionForReality, SnapshotPage } from '@enigmatis/polaris-typeorm';
import {
getConnectionForReality,
getPolarisConnectionManager,
SnapshotPage,
} from '@enigmatis/polaris-typeorm';
import { ApolloServer, ApolloServerExpressConfig, PlaygroundConfig } from 'apollo-server-express';
import { ApolloServerPlugin } from 'apollo-server-plugin-base';
import * as express from 'express';
Expand Down Expand Up @@ -77,6 +81,7 @@ export class PolarisServer {
const snapshotRepository = getConnectionForReality(
realityId,
this.getSupportedRealities(),
getPolarisConnectionManager() as any,
).getRepository(SnapshotPage);
const result = await snapshotRepository.findOne({} as any, id);
res.send(result?.getData());
Expand Down
7 changes: 6 additions & 1 deletion src/snapshot/snapshot-cleaner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { RealitiesHolder, Reality } from '@enigmatis/polaris-common';
import { AbstractPolarisLogger } from '@enigmatis/polaris-logs';
import { getConnectionForReality, SnapshotPage } from '@enigmatis/polaris-typeorm';
import {
getConnectionForReality,
getPolarisConnectionManager,
SnapshotPage,
} from '@enigmatis/polaris-typeorm';

let snapshotCleanerInterval: NodeJS.Timeout;

Expand Down Expand Up @@ -31,6 +35,7 @@ const deleteOutdatedSnapshotPages = (
const snapshotRepository = getConnectionForReality(
reality.id,
realitiesHolder,
getPolarisConnectionManager() as any,
).getRepository(SnapshotPage);
await snapshotRepository.query(`DELETE FROM ${snapshotRepository.metadata.tablePath}
WHERE EXTRACT(EPOCH FROM (NOW() - "creationTime")) > ${secondsToBeOutdated};`);
Expand Down

0 comments on commit ecf682e

Please sign in to comment.