-
Notifications
You must be signed in to change notification settings - Fork 6
Database summary statistics export #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
import {PickAttributesToCsvTransform} from "@/routes/applications/data-export/pick-attributes-to-csv-transform"; | ||
import {UserInfo} from "@/database"; | ||
import { AgeAugment } from "./user-age-augmenting-transform"; | ||
import {KeycloakAugments} from "@/lib/keycloak-augmenting-transform"; | ||
import {ConsentAugments} from "./consent-augmenting-transform"; | ||
import {AttendanceAugments} from "./attendance-augmenting-transform"; | ||
import {UserCvAugment} from "@/routes/applications/data-export/user-cv-augmenting-transform"; | ||
import {FlagAugments} from "@/routes/applications/data-export/user-flag-json-augmentor"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to merge the tailwind-v4
branch so we can run the formatter on this, imports are all over the place
import {UserCvAugment} from "@/routes/applications/data-export/user-cv-augmenting-transform"; | ||
import {FlagAugments} from "@/routes/applications/data-export/user-flag-json-augmentor"; | ||
|
||
export class AnonymousCsvTransform extends PickAttributesToCsvTransform<UserInfo & AgeAugment & AttendanceAugments & ConsentAugments<"media" | "dsuPrivacy"> & UserCvAugment & FlagAugments<"discipline-of-study" | "dietary-requirement">> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend extracting the type argument here into a type Foo = ...
declaration above
import {type ChildProcess, exec, type ExecException} from "node:child_process" | ||
import {createWriteStream} from "node:fs" | ||
import {mkdir, rm} from "node:fs/promises" | ||
import {join as pathJoin} from "node:path" | ||
import {Readable} from "node:stream" | ||
import {pipeline} from "node:stream/promises" | ||
import {ServerError} from "@otterhttp/errors" | ||
|
||
import {origin} from "@/config" | ||
import type {UserInfo} from "@/database" | ||
import {Group, onlyGroups} from "@/decorators/authorise" | ||
import {KeycloakAugmentingTransform} from "@/lib/keycloak-augmenting-transform" | ||
import {getTempDir} from "@/lib/temp-dir" | ||
import type {Middleware} from "@/types" | ||
|
||
import {hasCode} from "@/lib/type-guards" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your editor has messed with whitespace here - again, formatter would fix it
import {AttendanceAugmentingTransform, type AttendanceAugments} from "./attendance-augmenting-transform" | ||
import {CvExportingWritable} from "./cv-exporting-writable" | ||
import {FilteringTransform} from "./filtering-transform" | ||
import {HukCsvTransform} from "./huk-csv-transform" | ||
import {MlhCsvTransform} from "./mlh-csv-transform" | ||
import {generateUserCv} from "./user-cv-async-generator" | ||
import {generateUserInfo} from "./user-info-async-generator" | ||
import {UserAgeAugmentingTransform} from "@/routes/applications/data-export/user-age-augmenting-transform"; | ||
import {UserFlagAugmentor} from "@/routes/applications/data-export/user-flag-json-augmentor"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
return async (request, response) => { | ||
const tempDir = await getTempDir(); | ||
try { | ||
const fileName: string = "anonymous-data-export.csv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to annotate this variable's type, since we are assigning it to a string literal - the string
type will be inferred
ageGroupAugment = {ageGroup: "60+"}; | ||
} | ||
|
||
return {...userInfo, ...ageGroupAugment} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return {...userInfo, ...ageGroupAugment} | |
return {...userInfo, ageGroup} |
{name:"dietary-requirement", label: "dietary_requirements"}, | ||
{name:"discipline-of-study", label: "discipline_of_study"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{name:"dietary-requirement", label: "dietary_requirements"}, | |
{name:"discipline-of-study", label: "discipline_of_study"}, | |
{name: "dietary-requirement", label: "dietary_requirements"}, | |
{name: "discipline-of-study", label: "discipline_of_study"}, |
{name: "ageGroup", label: "age_group"}, | ||
{name: "dsuPrivacy", label: "dsu_privacy"}, | ||
{name: "media", label: "photo_media_consent"}, | ||
{name: "is_cv_uploaded", label: "has_uploaded_cv"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{name: "is_cv_uploaded", label: "has_uploaded_cv"}, | |
{name: "is_cv_uploaded", label: "did_upload_cv"}, |
{name: "dsuPrivacy", label: "dsu_privacy"}, | ||
{name: "media", label: "photo_media_consent"}, | ||
{name: "is_cv_uploaded", label: "has_uploaded_cv"}, | ||
{name: "cv_update_time", label: "cv_update_time"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{name: "cv_update_time", label: "cv_update_time"}, | |
{name: "cv_update_time", label: "cv_last_updated_at"}, |
{name: "media", label: "photo_media_consent"}, | ||
{name: "is_cv_uploaded", label: "has_uploaded_cv"}, | ||
{name: "cv_update_time", label: "cv_update_time"}, | ||
{name: "isCheckedIn", label: "has_attended"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{name: "isCheckedIn", label: "has_attended"} | |
{name: "isCheckedIn", label: "attendance"} |
… csv-transformer itself
…strings that can be exported into a CSV
…ew more data points to CSV transform
…nsform to the route handler
a14a88a
to
08213c3
Compare
rebased with main branch, ran formatter on each commit |
I have written most of the code which still needs testing. I'm not sure how to configure the handler for the route, and will need help from @Lordfirespeed.
The code also needs to be tested a lot more, and I'm not sure how to set up tests.
Once finished should hopefully close #207