Giter Site home page Giter Site logo

Sort objectives about backend HOT 11 CLOSED

cambiatus avatar cambiatus commented on June 3, 2024
Sort objectives

from backend.

Comments (11)

zacck-zz avatar zacck-zz commented on June 3, 2024 1

@namoscagnm hmmm, I think you are missing the forest for the trees on this one. What you need to do here is sort the objectives so that the objectives are arranged from the latest on to the earliest one. And in order to do this you would likely add a pattern match like this one

def query(Action, %{input: filters}) do

and in your pattern match you can run a query that sorts the objectives something like

def query(Objective, _params) do 
# do your query and sort here 
end 

Let us know if we can explain this further

from backend.

zacck-zz avatar zacck-zz commented on June 3, 2024 1

Hi @namoscagnm so I realized I might have explained this very curtly and perhaps this was not very helpful to show you what is happening.
So first off you need to understand we are using dataloader, you can read some of the docs here
https://github.com/absinthe-graphql/dataloader/blob/0451ee23d618a8e253262a5d7dd423d2e60e666a/lib/dataloader.ex#L8
and also check out this sample explainer project
absinthe-graphql/absinthe_tutorial#11

On testing

You can write a unit test such as where you do the following checks

  1. Insert objectives with random dates
  2. Use your resolver to fetch objectives in the test
  3. Ensure that the first objective in the list is the objective with the latest date ( this ensures that your sorting is working) like this assertion here
    assert %{"title" => ^f_title} = hd(community_sales)

Your code is correct, however I dont see why you need the filters parameter as it is not used, I could be wrong on this though

Let me know if I can explain this further, I could make time for a call to take you through specific tests too

from backend.

lucca65 avatar lucca65 commented on June 3, 2024

@zacck

from backend.

zacck-zz avatar zacck-zz commented on June 3, 2024

@GettyOrawo this is a super easy way of getting your hands dirty ...

from backend.

gustavonmartins avatar gustavonmartins commented on June 3, 2024

Hi, can you assign this to me?
Thank you!

from backend.

lucca65 avatar lucca65 commented on June 3, 2024

good luck @namoscagnm, this will mainly take you to understand and work with absinthe! be sure to check their documentation!

from backend.

gustavonmartins avatar gustavonmartins commented on June 3, 2024

Hi, I am new to graphql, but I managed to find the Objective class by querying:
{
__schema {
types {
name
}
}
}
and I get an "Objective type" inside the response.

I supposed that your problem arises when you query for a list of all responses?

I'm not sure its so, but I tried many commands, including:

After this, I tried to get a list of all objects by typing:

{
objective {
id
}
}

But this didnt work because of a missing input, so I will try out more stuff...

Is it generally possible to list all entries in graphql withtout specyfing any input?

Thanks

from backend.

lucca65 avatar lucca65 commented on June 3, 2024

+1 for @zacck comment

from backend.

gustavonmartins avatar gustavonmartins commented on June 3, 2024

@zacck

Hi, thanks for pointing on the code where the changes will start.

I tried the easiest possible solution given what you proposed, but honestly I would have never been able to navigate to the correct part of the code only from the description.

I have no way of testing if this works or not (it compiles at least), because I do not know how to test it. As I said before i tried it via the API, but it didnt work. Here is my code change:

master...namoscagnm:master

Even if the code is correct, could any of you (@lucca65, @zacck ) tell me how to test it, so I can be more independent next time?

Thank you!

from backend.

gustavonmartins avatar gustavonmartins commented on June 3, 2024

A call would be nice. How can we do it? Via WhatsApp?

Lucca has my Telegram. You can ask him my contact.

from backend.

zacck-zz avatar zacck-zz commented on June 3, 2024

@lucca65 please share the contact details ...

from backend.

Related Issues (20)

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.