mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-24 17:44:21 +03:00
Fix name conflict in Waspleau (#830)
Co-authored-by: shayneczyzewski <shayne.czyzewski@gmail.com>
This commit is contained in:
parent
24fb75ffd0
commit
adc1e1a84b
@ -1,6 +1,6 @@
|
||||
app waspleau {
|
||||
wasp: {
|
||||
version: "^0.6.0"
|
||||
version: "^0.7.0"
|
||||
},
|
||||
|
||||
title: "Waspleau",
|
||||
@ -24,7 +24,7 @@ job github {
|
||||
schedule: {
|
||||
cron: "*/10 * * * *"
|
||||
},
|
||||
entities: [Metric]
|
||||
entities: [Datum]
|
||||
}
|
||||
|
||||
job loadTime {
|
||||
@ -39,10 +39,10 @@ job loadTime {
|
||||
"name": "wasp-lang.dev Load Time"
|
||||
} json=}
|
||||
},
|
||||
entities: [Metric]
|
||||
entities: [Datum]
|
||||
}
|
||||
|
||||
entity Metric {=psl
|
||||
entity Datum {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
value String
|
||||
@ -56,5 +56,5 @@ page MainPage {
|
||||
|
||||
query dashboard {
|
||||
fn: import { refreshDashboardData } from "@server/dashboard.js",
|
||||
entities: [Metric]
|
||||
entities: [Datum]
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `Metric` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropTable
|
||||
DROP TABLE "Metric";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Datum" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"value" TEXT NOT NULL,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Datum_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Datum_name_key" ON "Datum"("name");
|
@ -1,5 +1,5 @@
|
||||
export const refreshDashboardData = async (_args, context) => {
|
||||
return context.entities.Metric.findMany({
|
||||
return context.entities.Datum.findMany({
|
||||
orderBy: [
|
||||
{
|
||||
name: 'asc',
|
||||
|
@ -1,19 +1,19 @@
|
||||
import axios from 'axios'
|
||||
import { upsertMetric } from './utils.js'
|
||||
import { upsertData } from './utils.js'
|
||||
|
||||
export async function workerFunction(args, context) {
|
||||
console.log('github.js workerFunction', args, context)
|
||||
|
||||
const response = await axios.get('https://api.github.com/repos/wasp-lang/wasp')
|
||||
|
||||
const metrics = [
|
||||
const data = [
|
||||
{ name: 'Wasp GitHub Stars', value: response.data.stargazers_count },
|
||||
{ name: 'Wasp GitHub Language', value: response.data.language },
|
||||
{ name: 'Wasp GitHub Forks', value: response.data.forks },
|
||||
{ name: 'Wasp GitHub Open Issues', value: response.data.open_issues },
|
||||
]
|
||||
|
||||
await Promise.all(metrics.map(upsertMetric(context)))
|
||||
await Promise.all(data.map(upsertData(context)))
|
||||
|
||||
return metrics
|
||||
return data
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import { upsertMetric } from './utils.js'
|
||||
import { upsertData } from './utils.js'
|
||||
|
||||
export async function workerFunction(args, context) {
|
||||
console.log('loadTime.js workerFunction', args, context)
|
||||
@ -8,9 +8,9 @@ export async function workerFunction(args, context) {
|
||||
await axios.get(args.url)
|
||||
const end = Date.now()
|
||||
|
||||
const metrics = [{ name: args.name, value: `${end - start}ms` }]
|
||||
const data = [{ name: args.name, value: `${end - start}ms` }]
|
||||
|
||||
await Promise.all(metrics.map(upsertMetric(context)))
|
||||
await Promise.all(data.map(upsertData(context)))
|
||||
|
||||
return metrics
|
||||
return data
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
export function upsertMetric(context) {
|
||||
export function upsertData(context) {
|
||||
return ({ name, value } = {}) => {
|
||||
return context.entities.Metric.upsert({
|
||||
return context.entities.Datum.upsert({
|
||||
where: { name },
|
||||
update: { name, value: String(value) },
|
||||
create: { name, value: String(value) }
|
||||
|
Loading…
Reference in New Issue
Block a user