thegazelle-ad / gazelle-server-next

Gazelle Server Rewritten with Next.JS
https://thegazelle.org
MIT License
3 stars 0 forks source link

Batch Profile Update : Parse Teams #20

Open corbanvilla opened 1 year ago

corbanvilla commented 1 year ago

Description

Every semester we spend far too much time manually entering team names, uploading them to s3 and inserting bios. This will be a script automating that whole process.

Milestone 1 : Parse CSV into teams

Begin first by making sure you can read the CSV file correctly.

Use the csv-parser library found here. I’ve already installed it into the Github repo.

Here’s a quick example script I’ve written to ensure it will work:

const fs = require("fs");
const parse = require("csv-parser");

const parser = parse({ delimiter: "," });

parser.on("readable", function () {
  let record;
  while ((record = parser.read()) !== null) {
    console.log(record);
  }
});

fs.createReadStream("./sigs.csv").pipe(parser);

**Milestone Requirements**

Functions

function readCSV(csvFile: string): returns [{}]

Reads any CSV file at the given file path provided (csvFile). Returns the elements as a list of objects. Does not do any logic parsing for teams or team members.

function parseTeams(csvDump): returns [{}]

Reads a dump of CSV objects (from readCSV) and parses all objects into a nested object (See Example Parsed Object below).

function isTeamHeader(object): returns bool

Reads a team object and returns whether an object looks like a team header or not. See above explanation for identifying team headers.

****Example Parsed Object****

[
    {
        team: "management",
        members: [
            {
              DESK: 'Githmi Rabel',
              POSITION: 'Editor-in-Chief',
              'NYU EMAIL': '...',
              SIGNATURE: '*Githmi Rabel is Editor-in-Chief. Email her at feedback@thegazelle.org*',
              '': '',
              Slug: 'githmi-rabel'
            },
            ....
        ]
    },
    {
        team: "web",
        members: [
            {
              DESK: 'Githmi Rabel',
              POSITION: 'Editor-in-Chief',
              'NYU EMAIL': '...',
              SIGNATURE: '*Githmi Rabel is Editor-in-Chief. Email her at feedback@thegazelle.org*',
              '': '',
              Slug: 'githmi-rabel'
            },
            ....
        ]
    },
  ....
]
github-actions[bot] commented 1 year ago

Branch issue-20 created! Clone with: git fetch && git checkout --track origin/issue-20 Rebase develop branch changes with: git checkout issue-20 && git rebase develop