add "underlyings" materialized view
This commit is contained in:
+2
-2
@@ -10,14 +10,14 @@ import fastify from 'fastify'
|
||||
import cors from '@fastify/cors'
|
||||
|
||||
const server = fastify()
|
||||
await server.register(cors, {});
|
||||
await server.register(cors, {origin:true});
|
||||
|
||||
server.get('/ping', async (request, reply) => {
|
||||
return 'pong\n'
|
||||
})
|
||||
|
||||
server.get('/option_quotes/underlyings', async (request, reply) => {
|
||||
const underlyings = (await sql`SELECT DISTINCT "underlying" FROM "option_quote";`).map(x=>x.underlying);
|
||||
const underlyings = (await sql`SELECT * FROM "underlyings";`).map(x=>x.underlying);
|
||||
reply.status(200).send(underlyings);
|
||||
})
|
||||
server.get<{
|
||||
|
||||
@@ -161,4 +161,5 @@ export async function ingestOptions(sourceDataDir:string):Promise<void>{
|
||||
};
|
||||
console.log("creating index");
|
||||
await sql`CREATE INDEX ON "option_quote" USING btree ("underlying","expiration","type","strike","quote_date");`;
|
||||
await sql`CREATE MATERIALIZED VIEW "underlyings" AS SELECT DISTINCT "underlying" FROM "option_quote";`;
|
||||
}
|
||||
Reference in New Issue
Block a user