question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tech-radar support for CSV data source

See original GitHub issue

Now there is a simple way how to feed data from tech-radar plugin via “getData” attribute. We did implement our own feeder that loads data from CSV. However when we tried to put the url in the configuration we hit the wall many times as there is no easy way, how to achieve this “out” of the component.

I have prepared an enhancemen that fullfills our needs of loading tech-radar data from CSV. I would like to contribute to the comunity and want to gather feedback to this feature.

Feature Suggestion

New attribute useCsvLoader in the TechRadarPage component:

<TechRadarPage ... useCsvLoader />

New configuration:

techradar:
  csvEntriesUrl: https://location-of-csv-source/xxx.csv
  quadrants:
    - id: lngfwk
      name: Languages & Frameworks
    - id: tools
      name: Tools
   ...
  rings:
    - id: adopt
      name: Adopt
      color: '#009688'
    - id: trial
      name: Trial
      color: '#6acbef'
   ...

Possible Implementation

plugins/tech-radar/src/components/RadarComponent.tsx

...
import { TechRadarCsvDataLoader } from './csv-support/TechRadarCsvDataLoader';
...
const useTechRadarLoader = (props: TechRadarComponentProps) => {
  ...
  const configApi = useApi(configApiRef);
  const csvEntriesUrl = configApi.getOptionalString('techradar.csvEntriesUrl') ?? 'https://unknown-url-please-configure';
  ...
  const state = useAsync(async () => {
    if (useCsvLoader) {
      const response: TechRadarLoaderResponse = await TechRadarCsvDataLoader(csvEntriesUrl);
      return response;
    }
    if (getData) {
      ...
    }
    return undefined;
  }, [getData, errorApi]);
  ...
};

plugins/tech-radar/src/components/csv-support/TechRadarCsvDataLoader.ts

export { TechRadarCsvDataLoader };

import { GetRadarEntries } from "./GetRadarEntries";
import { TechRadarLoaderResponse } from "../../api";

const TechRadarCsvDataLoader = async (csvEntriesUrl: string) : Promise<TechRadarLoaderResponse> => {
    const entries = await GetRadarEntries(csvEntriesUrl);
    return Promise.resolve({
        quadrants: //TBD: load from config or get from parameter,
        rings: //TBD
        entries: entries,
    });
}

plugins/tech-radar/src/components/csv-support/GetRadarEntries.ts

import { RadarEntry } from "../../api";
import { GetCsvEntries } from "./GetCsvEntries";

export async function GetRadarEntries(
    csvEntriesUrl: string
): Promise<RadarEntry[]> {
    const entries: RadarEntry[] = [];
    const csvRecords = await GetCsvEntries(csvEntriesUrl);
    var i = 0;
    csvRecords.forEach((row: { name: string; ring: string; quadrant: string; movedState?: number; description: string; url?: string;}) => {
        i++;

        entries.push({
            url: row.url ?? '#',
            key: 'key_' + i,
            id: 'id_' + i,
            title: row.name,
            quadrant: row.quadrant,
            description: row.description,
            timeline: [
                {
                    //TBD: only one row used?
                    moved: row.movedState,
                    ringId: row.ring,
                    date: new Date('2020-01-01'), //TODO
                    description: row.description,
                }
            ]
        })
    });
    return Promise.resolve(entries);
}

plugins/tech-radar/src/components/csv-support/GetCsvEntries.ts

import parse from 'csv-parse/lib/sync';

export async function GetCsvEntries(
    csvEntriesUrl: string,
): Promise<any> {
    console.log("Fetching csv from %s", csvEntriesUrl);
    const response = await fetchUrl(csvEntriesUrl);
    const records = parse(response, {
        columns: true,
        skip_empty_lines: true,
        delimiter: ",",
    })
    return Promise.resolve(records);
}

const fetchUrl = async (
    url: string,
): Promise<string> => {
    const response = await fetch(url);
    if (response.status === 200)
        return await response.text() as string;
    throw new Error("Response not 200");
};

sample data (plugins/tech-radar/sample-data.csv):

name,ring,quadrant,movedState,description,area,url
Backstage,adopt,platforms,0,"An open platform for building developer portals: Powered by a centralized service catalog, Backstage restores order to your infrastructure and enables your product teams to ship high-quality code quickly — without compromising autonomy.",development,https://backstage.io/

Context

We want to load data for tech-radar from csv.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
benjdlambertcommented, Jun 2, 2021

Hey 👋 So i’ve been hacking a little on making the TechRadar a little more flexible on how you load data.

It’s not yet finished as I need to write some documentation, but in theory you can create your own class which implements TechRadarApi with a load method that should return the correct JSON object, and how you build that JSON object is entirely up to you. So you can read a CSV URL from config if you want and parse that CSV file and create the required JSON object.

#5891

1reaction
Fox32commented, May 28, 2021

Actually that shouldn’t have a performance impact. With API I mean an interface in the frontend that an adopter can replace with an own implementation. See the example for the explore plugin linked above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tech-Radar/radar.csv at main · red-gate/Tech-Radar - GitHub
name ring quadrant isNew C# adopt Languages and Frameworks true TypeScript adopt Languages and Frameworks true Go trial Languages and Frameworks true
Read more >
Pull data from CSV for Tech Radar - Stack Overflow
I am trying to create my own Tech Radar based on Zalando Tech Radar and getting it to Pull data from a CSV....
Read more >
Configuring Tech Radar - Roadie.io
Roadie currently supports fetching tech radar data directly from GitHub and Bitbucket. Both CSV and JSON data files are supported, ...
Read more >
Sync your contacts, calendar and email: Page 2 | TechRadar
Launch and go to File | Subscribe to Remote Calendar. Choose 'On the Network' when prompted, then check the CalDAV radio button on...
Read more >
Build your Own Radar | Thoughtworks
Our Build Your Own Radar visualization tool will help you map out a ... a Google Sheet, or a hosted .csv file that's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found