Skip to content

Commit

Permalink
refactor: rename store methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Dec 4, 2023
1 parent 2d14c34 commit da5c840
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/measurement/route/get-measurement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const handle = async (ctx: ParameterizedContext<DefaultState, DefaultContext & R
return;
}

const result = await store.getMeasurement(id);
const result = await store.getMeasurementString(id);

if (!result) {
ctx.status = 404;
Expand Down
4 changes: 2 additions & 2 deletions src/measurement/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ const substractObjects = (obj1: Record<string, unknown>, obj2: Record<string, un
export class MeasurementStore {
constructor (private readonly redis: RedisClient) {}

async getMeasurement (id: string): Promise<string> {
async getMeasurementString (id: string): Promise<string> {
return this.redis.sendCommand([ 'JSON.GET', getMeasurementKey(id) ]);
}

async getMeasurementJson (id: string): Promise<MeasurementRecord> {
async getMeasurement (id: string): Promise<MeasurementRecord> {
return await this.redis.json.get(getMeasurementKey(id)) as MeasurementRecord;
}

Expand Down
2 changes: 1 addition & 1 deletion src/probe/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ProbeRouter {
allProbes.push(connectedProbe);
} else {
if (!prevMeasurement) {
prevMeasurement = await this.store.getMeasurementJson(measurementId);
prevMeasurement = await this.store.getMeasurement(measurementId);

if (!prevMeasurement) {
return emptyResult;
Expand Down
2 changes: 1 addition & 1 deletion test/tests/unit/probe/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('probe router', () => {
const getRegionMock = sinon.stub();
const store = {
getIpsByMeasurementId: sinon.stub(),
getMeasurementJson: sinon.stub(),
getMeasurement: sinon.stub(),
} as unknown as MeasurementStore;
const router = new ProbeRouter(fetchSocketsMock, store);
let buildProbe: (socket: RemoteProbeSocket) => Promise<Probe>;
Expand Down

0 comments on commit da5c840

Please sign in to comment.