Coder Social home page Coder Social logo

Comments (3)

SohamRatnaparkhi avatar SohamRatnaparkhi commented on August 15, 2024 1

Thanks @SohamRatnaparkhi, I have assigned you.

As stated in the issue, the endpoint is GET /tasks. The controller name for that you can find in the OpenAPI specification. I am not looking it up for you, so that you will have a chance to explore how OpenAPI specs are structured ;-)

Note that there are two general approaches you could follow here:

1. **Only fetch tasks matching the prefix from the database.** Here you would need to find out how you can define and pass such a filter when doing a database call. Such a solution is preferred as it will be much more performant, especially when we will have thousands of tasks. However, I am not 100% sure it's possible with MongoDB, but https://www.mongodb.com/docs/manual/reference/operator/query/regex/ looks promising.

2. **Filter matching tasks _after_ the database call.** This is the general approach you describe. If you do not get anywhere with approach (1), make sure that you don't just use a plain `for` loop. Instead make use of `map()` or use a list comprehension. In fact, you should probably try both and see which approach is more performant. If you can think of any other solutions, include them in your benchmark.

Yep. This works as well!
I will try to come up with a solution soon and will draft a PR.

from protes.

SohamRatnaparkhi avatar SohamRatnaparkhi commented on August 15, 2024

Hi @uniqueg ,
I would love to solve this issue.
One possible brute force approach to solving it would involve iterating through all the tasks and appending any tasks that begin with a specified string, such as 'foo,' to a list, which would then be returned.

I have reviewed the code base, but I was unable to locate the controller for this request. Based on my analysis, the controller may be in either server.py or task_runs.py. If I am mistaken, please direct me to the correct controller. Otherwise, I am prepared to create a new function to address the issue.

Thank you!

from protes.

uniqueg avatar uniqueg commented on August 15, 2024

Thanks @SohamRatnaparkhi, I have assigned you.

As stated in the issue, the endpoint is GET /tasks. The controller name for that you can find in the OpenAPI specification. I am not looking it up for you, so that you will have a chance to explore how OpenAPI specs are structured ;-)

Note that there are two general approaches you could follow here:

  1. Only fetch tasks matching the prefix from the database. Here you would need to find out how you can define and pass such a filter when doing a database call. Such a solution is preferred as it will be much more performant, especially when we will have thousands of tasks. However, I am not 100% sure it's possible with MongoDB, but https://www.mongodb.com/docs/manual/reference/operator/query/regex/ looks promising.
  2. Filter matching tasks after the database call. This is the general approach you describe. If you do not get anywhere with approach (1), make sure that you don't just use a plain for loop. Instead make use of map() or use a list comprehension. In fact, you should probably try both and see which approach is more performant. If you can think of any other solutions, include them in your benchmark.

from protes.

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.