Compare commits
5 Commits
89558cdd1a
...
026d0cfd56
| Author | SHA1 | Date | |
|---|---|---|---|
| 026d0cfd56 | |||
| 1a14485c57 | |||
| 50730a2b09 | |||
| 9fc14cffd0 | |||
| e534506894 |
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@ -25,9 +25,35 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and Push Docker image -- finn-board
|
- name: Build and Push Docker image
|
||||||
uses: docker/build-push-action@675965c0e16f1a0f94ecafff969d8c966f92c17b
|
uses: docker/build-push-action@675965c0e16f1a0f94ecafff969d8c966f92c17b
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: git.joshuacoles.me/joshuacoles/revision-ui:latest
|
tags: git.joshuacoles.me/joshuacoles/revision-ui:latest
|
||||||
|
|
||||||
|
build-arm:
|
||||||
|
runs-on: macos-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to Docker
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: git.joshuacoles.me
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and Push Docker image
|
||||||
|
uses: docker/build-push-action@675965c0e16f1a0f94ecafff969d8c966f92c17b
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: git.joshuacoles.me/joshuacoles/revision-ui:arm
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -40,3 +40,6 @@ next-env.d.ts
|
|||||||
|
|
||||||
# Private env files
|
# Private env files
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
# Caddyfile for local development when testing weird deploys
|
||||||
|
/Caddyfile
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import {Tooltip} from 'react-tooltip';
|
|||||||
import {Data} from "@/data/fetchData";
|
import {Data} from "@/data/fetchData";
|
||||||
import HeatMap from "@/components/HeatMap";
|
import HeatMap from "@/components/HeatMap";
|
||||||
|
|
||||||
function useCalendarData(data: Data, initialDate: Date, endDate: Date) {
|
function useCalendarData(data: Data) {
|
||||||
const timeEntries = data.timeEntries;
|
const timeEntries = data.timeEntries;
|
||||||
|
|
||||||
// Group by day, sum up seconds
|
// Group by day, sum up seconds
|
||||||
@ -17,17 +17,6 @@ function useCalendarData(data: Data, initialDate: Date, endDate: Date) {
|
|||||||
return R.sum((entries ?? []).map((entry) => entry.duration))
|
return R.sum((entries ?? []).map((entry) => entry.duration))
|
||||||
}, grouped);
|
}, grouped);
|
||||||
|
|
||||||
// Fill in missing days, hacky
|
|
||||||
dFns.eachDayOfInterval({
|
|
||||||
start: initialDate,
|
|
||||||
end: endDate,
|
|
||||||
}).forEach((date) => {
|
|
||||||
const key = dFns.formatISO(date);
|
|
||||||
if (summed[key] == undefined) {
|
|
||||||
summed[key] = 0;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return Object.entries(summed)
|
return Object.entries(summed)
|
||||||
.map(([key, value]) => ({
|
.map(([key, value]) => ({
|
||||||
date: dFns.parseISO(key),
|
date: dFns.parseISO(key),
|
||||||
@ -50,7 +39,7 @@ export function CalendarOverviewCard({
|
|||||||
}) {
|
}) {
|
||||||
const initialDate = dFns.parseISO(startTime);
|
const initialDate = dFns.parseISO(startTime);
|
||||||
const endDate = dFns.parseISO(endTime);
|
const endDate = dFns.parseISO(endTime);
|
||||||
const calendarData = useCalendarData(data, initialDate, endDate);
|
const calendarData = useCalendarData(data);
|
||||||
|
|
||||||
return <Card className="col-span-1">
|
return <Card className="col-span-1">
|
||||||
<Tooltip id="calendar-tooltip"/>
|
<Tooltip id="calendar-tooltip"/>
|
||||||
|
|||||||
21
src/data/db.d.ts
vendored
21
src/data/db.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
import type {ColumnType, JSONColumnType} from "kysely";
|
import type {ColumnType} from "kysely";
|
||||||
|
|
||||||
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
|
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
|
||||||
? ColumnType<S, I | undefined, U>
|
? ColumnType<S, I | undefined, U>
|
||||||
@ -32,13 +32,13 @@ export interface Client {
|
|||||||
export interface Project {
|
export interface Project {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
client_id: number | null;
|
client_id: number | null;
|
||||||
|
color: string;
|
||||||
id: Generated<number>;
|
id: Generated<number>;
|
||||||
name: string;
|
name: string;
|
||||||
raw_json: JSONColumnType<{
|
raw_json: Json;
|
||||||
color: string;
|
server_created_at: Timestamp;
|
||||||
id: number;
|
server_deleted_at: Timestamp | null;
|
||||||
name: string;
|
server_updated_at: Timestamp;
|
||||||
}>;
|
|
||||||
toggl_id: Int8;
|
toggl_id: Int8;
|
||||||
workspace_id: Int8;
|
workspace_id: Int8;
|
||||||
}
|
}
|
||||||
@ -47,13 +47,12 @@ export interface TimeEntry {
|
|||||||
description: string;
|
description: string;
|
||||||
id: Generated<number>;
|
id: Generated<number>;
|
||||||
project_id: Int8 | null;
|
project_id: Int8 | null;
|
||||||
raw_json: JSONColumnType<{
|
raw_json: Json;
|
||||||
start: string;
|
server_deleted_at: Timestamp | null;
|
||||||
end: string;
|
server_updated_at: Timestamp;
|
||||||
seconds: number;
|
|
||||||
}>;
|
|
||||||
start: Timestamp;
|
start: Timestamp;
|
||||||
stop: Timestamp;
|
stop: Timestamp;
|
||||||
|
tags: Generated<Json>;
|
||||||
toggl_id: Int8;
|
toggl_id: Int8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,12 +52,12 @@ export async function getData(config: OverviewConfig): Promise<Data> {
|
|||||||
let projectIds = config.subjects.map((subject) => subject.projectId.toString());
|
let projectIds = config.subjects.map((subject) => subject.projectId.toString());
|
||||||
|
|
||||||
const projects = await db.selectFrom('project')
|
const projects = await db.selectFrom('project')
|
||||||
.select('raw_json')
|
.select(['toggl_id', 'name', 'color'])
|
||||||
.where('project.toggl_id', 'in', projectIds)
|
.where('toggl_id', 'in', projectIds)
|
||||||
.execute();
|
.execute()
|
||||||
|
|
||||||
const timeEntries = await db.selectFrom('time_entry')
|
const timeEntries = await db.selectFrom('time_entry')
|
||||||
.select(['project_id', 'raw_json'])
|
.select(['project_id', 'start', 'stop'])
|
||||||
.where('project_id', 'in', projectIds)
|
.where('project_id', 'in', projectIds)
|
||||||
.where('start', '>', dFns.parseISO(config.timePeriod.start))
|
.where('start', '>', dFns.parseISO(config.timePeriod.start))
|
||||||
.where('start', '<', dFns.parseISO(config.timePeriod.end))
|
.where('start', '<', dFns.parseISO(config.timePeriod.end))
|
||||||
@ -65,16 +65,16 @@ export async function getData(config: OverviewConfig): Promise<Data> {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
projects: projects.map((project) => ({
|
projects: projects.map((project) => ({
|
||||||
projectId: project.raw_json.id,
|
projectId: parseInt(project.toggl_id),
|
||||||
name: project.raw_json.name,
|
name: project.name,
|
||||||
color: project.raw_json.color,
|
color: project.color,
|
||||||
})),
|
})),
|
||||||
|
|
||||||
timeEntries: timeEntries.map((timeEntry) => ({
|
timeEntries: timeEntries.map((timeEntry) => ({
|
||||||
projectId: parseInt(timeEntry.project_id!),
|
projectId: parseInt(timeEntry.project_id!),
|
||||||
start: timeEntry.raw_json.start,
|
start: dFns.formatISO(timeEntry.start),
|
||||||
end: timeEntry.raw_json.end,
|
end: dFns.formatISO(timeEntry.stop),
|
||||||
duration: timeEntry.raw_json.seconds,
|
duration: dFns.differenceInSeconds(timeEntry.stop, timeEntry.start)
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user