Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup api to check if a LF classic project exists #687

Closed
Tracked by #797 ...
hahn-kev opened this issue Apr 2, 2024 · 5 comments · Fixed by #798
Closed
Tracked by #797 ...

setup api to check if a LF classic project exists #687

hahn-kev opened this issue Apr 2, 2024 · 5 comments · Fixed by #798
Assignees
Labels
ASP.NET owner: Kevin High Priority K8S or Docker owner: Robin, Kevin
Milestone

Comments

@hahn-kev
Copy link
Collaborator

hahn-kev commented Apr 2, 2024

we want a way to determine if a project exists in LF classic. I'd like this to be very performant so we could potentially display it in a list of projects. It may be good enough to just mount the workspace volume and if the folder exists for the project in question.

options:

  1. mount the lfmerge volume (sendreceive-data) not a good idea because volume is RWO
  2. query the mongodb for the project, suggest using a batch data loader in gql
  3. send a request to the php api

option 2 would probably be pretty easy, but I'm worried about the performance, I don't really like the idea of making a query to mongodb for each project but that might end up being the best solution.

@hahn-kev hahn-kev added ASP.NET owner: Kevin K8S or Docker owner: Robin, Kevin labels Apr 2, 2024
@rmunn
Copy link
Contributor

rmunn commented Apr 3, 2024

We could query MongoDB once or twice per day for a list of projectCodes, turn that list into a HashSet, and do an O(1) lookup on the HashSet to determine if a project exists. It would possibly fail for projects that were just created minutes ago in LF, but that might not be a big deal. (And there could be ways around that, such as having any hg clone operation for projects not in the HashSet trigger a Mongo API query to see if that clone was coming from Language Forge. Would have a few false positives, but not many).

@megahirt
Copy link
Contributor

megahirt commented Apr 3, 2024

Does the LexBox C# code already have a standard way to query the LF MongoDB? I forget. If it does, then I could help with the query. I would suggest a single query that returns a full list of all project codes hooked up to S/R. This should be performant and then we don't need to mount the LF S/R volume and create an unnecessary dependency.

If you'd prefer I could probably create a LF API endpoint that provides this but then we have the issue of authentication which isn't built into the LF. API.

@myieye myieye added this to the LFNext poc milestone Apr 3, 2024
@hahn-kev hahn-kev mentioned this issue Apr 8, 2024
3 tasks
@hahn-kev
Copy link
Collaborator Author

hahn-kev commented Apr 8, 2024

In the lf-next branch I've implemented a way to query LF Mongo. And after thinking about it a bit I think that's probably going to be the best way to move forward.

The way we can implement using the graphql loader is something like this on the project class

public Task<bool> GetIsLanguageForgeProject(IsLanguageForgeProjectDataLoader loader) {
    return loader.LoadAsync(Code);
}

note: should probably be conditional based on if it's a FLEx project or not, we know that One story editor projects are not in LF for example.

what gql will do behind the scenes is aggregate all those calls to load, and inside the loader (which is what needs to be implemented) LoadBatchAsync will be called with all the project codes this gql query is trying to resolve. Then we can execute a single mongo query to determine if all those projects exist or not.

@rmunn
Copy link
Contributor

rmunn commented Apr 25, 2024

Yes, I agree that querying LF Mongo is going to be the way to go about this. We'll need to make sure we set up LF staging and production servers to allow connections to the Mongo pod from LexBox as well as from LF. (And if we have it wide-open to anything in the cluster, well, we should perhaps restrict that).

@hahn-kev
Copy link
Collaborator Author

you're right it is wide open, there's an issue for it already sillsdev/web-languageforge#1787

@myieye myieye self-assigned this May 13, 2024
@myieye myieye mentioned this issue May 13, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASP.NET owner: Kevin High Priority K8S or Docker owner: Robin, Kevin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants