GithubHelp home page GithubHelp logo

imadarchid / ucits-ma Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 1.32 MB

๐Ÿ“ˆ A better way to look at Moroccan UCITS.

Home Page: https://ucits.imadarchid.com

TypeScript 12.61% JavaScript 0.27% CSS 0.08% Dockerfile 0.15% PLpgSQL 4.54% Python 82.28% Shell 0.06%
finance morocco ucits

ucits-ma's People

Contributors

imadarchid avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ucits-ma's Issues

The current state of the search bar is not functioning optimally.

The search bar appears to be functioning incorrectly. After careful consideration, I believe that a potential solution could be implemented in one of two ways:

  • Implementing regular expression to check if the user's input matches the format "MA*******", and routing the user to the path "/MA*******" if it does. Alternatively, we could implement a full-text search in the TRPC route of the name, which would require a mutation and result in a list of possible outcomes for the user to choose from.
  • Introducing separate search bars for both the name and ID.
  • Additionally, the issue with "Random" not generating truly random results should also be addressed.

I plan to draft a solution and submit a merge request as soon as possible.

Overall, I find this project to be truly impressive.

PerformanceChart: is there a better solution than converting Decimal to Float in Prisma types?

Context

We're implementing a chart component called PerformanceChart in Resultbox.tsx.

<div id="cardContent" className="px-4 py-2">
<PerformanceChart dataset={fund.data?.performances} />
</div>

The dataset prop has an interface PerformanceChartProps[] as follows:

interface PerformanceType {
vl_value: number
an_value: number
date: string
}
interface PerformanceChartProps {
dataset?: PerformanceType[]
}

Data is mapped from the database through Prisma, with the Prisma schema as follows for performances:

model performances {
performance_id Int @id @default(autoincrement())
isin_code String @db.VarChar
date DateTime @db.Date
an_value Decimal @db.Decimal
vl_value Decimal @db.Decimal
funds funds @relation(fields: [isin_code], references: [isin_code], onDelete: NoAction, onUpdate: NoAction, map: "ISIN constraint")
}

โš ๏ธ Problem

tsc complains that the dataset prop cannot accept number values for string types for vl_value and an_value.

types of property 'vl_value' are incompatible.
        Type 'number' is not assignable to type 'string'.

The issue comes from the fact that Prisma relies on Decimal.js for the Decimal type, which for some reason ends up converting values into strings instead of numbers.

Proposed solutions

  1. Use the Prisma.Decimal class as a type for values vl_value and an_value in PerformanceType
    Does not work, and throws the same error as before.

  2. Use inferRouterOutput to infer types from findByIsin
    The whole output types are inferred. Can I access a nested object's performances types only? (Sorry my TS skills are.. well improving?)

  3. Convert Decimal data types for vl_value and an_value in Prisma to Float
    We maintain consistency and errors are not thrown both from the prop side and the Chart.js side (which requires the type number for the chart values).

Current fix
I opted for option 3, but I think it's a little messy. Is this the right path? TBD (I can't stay stuck on this issue any longer...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.