Search doesn't return anything

Feature(s) impacted

Search in sub-collection, when trying to add an existing student to lead students.

Observed behavior

Search is continously loading when looking for an item, through button “Add existing …”.

image

If I look for a missing term, I’ve got the right info :

image

So, it seems it simply doesn’t return the results.

Failure Logs

No failure log.

Context

  • Project name: lereacteur-admin
  • Team name: Operations
  • Environment name: dev/prod
  • Agent (forest package) name & version: "forest-express-mongoose": "^8.7.9"
  • Database type: MongoDB

Hi @XavierColombel ,

  1. Did the search was working previously ? (if yes, what change did you make recently and when did it start to happen?)
  2. Is it working on other collections?
  3. Do you still have records before searching ?

Best regards,

Shohan

Did the search was working previously ? (if yes, what change did you make recently and when did it start to happen?)
Yes and I’ve recently moved to from version 7 to 8.
Is it working on other collections?
Yes but not with students sub-collection.
Do you still have records before searching ?
Yes

Hi @XavierColombel,

We have some breaking changes from V7 to V8, could you check with this documentation if your setup is up-to-date please ?
Could you please send me how did you declare your sub-collection?

Best regards,

Shohan

My setup is up-to-dating, following the documentation. Everything is working but this.

My subcollection students is declared like this in the lead model :

students: [{ type: Mongoose.Schema.Types.ObjectId, ref: "Students" }],

I’ve to tell I have other subcollections, declared the same way and it’s working fine.

The main problem is it’s loading permanently, when I look for a student… And I’ve no error log. Can yo please investigate by your side please and give me errors you might have? It’s a big problem for us and we pay Forest.

Thanks.

Hi @XavierColombel,

  1. In your search, when it continuously loading, what does the network returns ?
  2. The display field of your Students collection is a Smart Field called “Nom complet”. Could I have the definition of this field ?
  3. In the search query, is the “Nom complet” is in the payload of the response ?

Best regards,

Shohan

1. In your search, when it continuously loading, what does the network returns ?
When I type something it returns an error from ember, I guess :
image

2. The display field of your Students collection is a Smart Field called “Nom complet”. Could I have the definition of this field ?
It’s the concatenation of first name, last name and email, like this : John DOE (johndoe@email.com) for instance.

3. In the search query, is the “Nom complet” is in the payload of the response ?
Nom complet is the reference field and the payload, yes.

image

Hello @XavierColombel

We are still trying to identify and reproduce your issue.

Can you please share with us the http response you receive from your agent when searching for a student to add ?

Nicolas

If I search “valerie”, I’ve got this :

{
    "meta": {
        "decorators": {
            "0": {
                "id": "xxxxxx",
                "search": [
                    "firstname",
                    "Nom complet"
                ]
            }
        }
    },
    "data": [
        {
            "type": "Students",
            "id": "xxxxxx",
            "attributes": {
                "Nom complet": "Valerie XXXX XXX (xxxxx@yahoo.fr)",
                "email": "xxxxx@yahoo.fr",
                "telephone": "+xxxxxxxx",
                "firstname": "Valerie",
                "lastname": "XXXX XXX",
                "birthDate": "1987-06-05T00:00:00.000Z",
                "zipCode": "xxxxx",
                "slackId": "XXXXXX",
                "slackAvatar": "https://avatars.slack-edge.com/xxx_1024.jpg",
                "mailinglist": true,
                "relationships": {
                    "githubMember": {
                        "data": [
                            {
                                "type": "GithubMembers",
                                "id": "xxxxx"
                            }
                        ],
                        "links": {
                            "related": {
                                "href": "/forest/Students/xxxxx/relationships/githubMember"
                            }
                        }
                    },
                    "sessions": {
                        "links": {
                            "related": {
                                "href": "/forest/Students/xxxxx/relationships/sessions"
                            }
                        }
                    },
                    "leads": {
                        "links": {
                            "related": {
                                "href": "/forest/Students/xxxxx/relationships/leads"
                            }
                        }
                    },
                    "commentsArr": {
                        "links": {
                            "related": {
                                "href": "/forest/Students/xxxxx/relationships/commentsArr"
                            }
                        }
                    },
                    "documents": {
                        "links": {
                            "related": {
                                "href": "/forest/Students/xxxxx/relationships/documents"
                            }
                        }
                    },
                    "exams": {
                        "links": {
                            "related": {
                                "href": "/forest/Students/xxxxx/relationships/exams"
                            }
                        }
                    }
                }
            }
        ],
        "included": [
            {
                "type": "GithubMembers",
                "id": "xxxxx",
                "attributes": {
                    "_id": "xxxxx"
                }
            }
        ]
    }

So, for me it’s a good response, but nothing appears and the loader is still turning.

PS : I’ve cleaned the json.

Thank you for your response.

Can you please try to update the smart field name so it does not contain spaces ?

fields: [{
    field: 'NomComplet",
    ...

You can update the display name of the field in the Students collection settings to match “Nom complet”.

Yes, same problem, same loader turning indefinitely.

I found that with certain search I’ve no problem.

For instance, looking for foui, I’ve got this response (and it’s working) :

{
  "meta": {
    "decorators": {
      "0": {
        "id": "5e99fa2ec9aaef788cc6c335",
        "search": ["email", "lastname", "Nom complet"]
      }
    }
  },
  "data": [
    {
      "type": "Students",
      "id": "5e99fa2ec9aaef788cc6c335",
      "attributes": {
        "Nom complet": "xxxxx Fouite (fouite.xxxxx@gmail.com)",
        "email": "fouite.xxxxx@gmail.com",
        "firstname": "xxxxx",
        "lastname": "Fouix",
        "birthDate": "1980-09-04T22:16:40.000Z",
        "country": "France",
        "slackAvatar": "https://avatars.slack-edge.com/xxxxx_1024.jpg",
        "isFlagged": false,
        "createdAt": "2020-04-17T18:48:23.314Z",
        "updatedAt": "2020-04-17T18:48:23.314Z",
        "_id": "5e99fa2ec9aaef788cc6c335"
      },
      "relationships": {
        "sessions": {
          "links": {
            "related": {
              "href": "/forest/Students/5e99fa2ec9aaef788cc6c335/relationships/sessions"
            }
          }
        },
        "leads": {
          "links": {
            "related": {
              "href": "/forest/Students/5e99fa2ec9aaef788cc6c335/relationships/leads"
            }
          }
        },
        "commentsArr": {
          "links": {
            "related": {
              "href": "/forest/Students/5e99fa2ec9aaef788cc6c335/relationships/commentsArr"
            }
          }
        },
        "documents": {
          "links": {
            "related": {
              "href": "/forest/Students/5e99fa2ec9aaef788cc6c335/relationships/documents"
            }
          }
        }
      }
    }
  ]
}

And if I look for valeri (it’s not working) :

{
  "meta": {
    "decorators": {
      "0": {
        "id": "641083c3f447ae00141a63ac",
        "search": ["firstname", "Nom complet"]
      }
    }
  },
  "data": [
    {
      "type": "Students",
      "id": "641083c3f447ae00141a63ac",
      "attributes": {
        "Nom complet": "Valerie XXXX XXX (xxxxxx@yahoo.fr)",
        "email": "xxxxxx@yahoo.fr",
        "telephone": "+xxxxxx",
        "firstname": "Valerie",
        "lastname": "XXXX XXX",
        "birthDate": "1987-06-05T00:00:00.000Z",
        "zipCode": "69570",
        "slackAvatar": "https://avatars.slack-edge.com/xxxxx_1024.jpg",
        "createdAt": "2023-03-14T14:25:07.187Z",
        "updatedAt": "2023-03-14T14:25:07.187Z",
        "_id": "641083c3f447ae00141a63ac"
      },
      "relationships": {
        "githubMember": {
          "data": [
            { "type": "GithubMembers", "id": "641effa7f79a140014a47a3b" }
          ],
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/githubMember"
            }
          }
        },
        "sessions": {
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/sessions"
            }
          }
        },
        "leads": {
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/leads"
            }
          }
        },
        "commentsArr": {
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/commentsArr"
            }
          }
        },
        "documents": {
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/documents"
            }
          }
        },
        "exams": {
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/exams"
            }
          }
        }
      }
    }
  ],
  "included": [
    {
      "type": "GithubMembers",
      "id": "641effa7f79a140014a47a3b",
      "attributes": { "_id": "641effa7f79a140014a47a3b" }
    }
  ]
}

Do you see any problem ?

There is something a bit weird is that you don’t have the same fields for both entities :thinking:. Did you customized the serializer of forestadmin ?
What could be the problem is your GithubMembers relationships, I will investigate a bit more :male_detective:

Okey I think it is the issue. Your GithubMember relationships is return as a HasMany but it’s actually a BelongsTo :thinking:

          "data": [
            { "type": "GithubMembers", "id": "641effa7f79a140014a47a3b" }
          ],
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/githubMember"
            }
          }
        },

It should be:

        "githubMember": {
          "data": { "type": "GithubMembers", "id": "641effa7f79a140014a47a3b" },
          "links": {
            "related": {
              "href": "/forest/Students/641083c3f447ae00141a63ac/relationships/githubMember"
            }
          }
        },

@vince here is my setup (and I didn’t change or customize anything) in student model :

Could you tell me how to solve this please ?

The issue is coming from your agent (your backend). Could your show me the declaration of your Student model ? And the data in database of your valeri student

@vince Actually, I didn’t update anything since more than a year, and it always worked.

Here is the model (simplified) :

module.exports = (mongoose, Mongoose) => {
  const schema = Mongoose.Schema(
    {
      email: String,
      telephone: String,
      firstname: String,
      lastname: String,
      githubMember: {
        type: Mongoose.Schema.Types.ObjectId,
        ref: "GithubMembers",
      },
      sessions: [
        { type: Mongoose.Schema.Types.ObjectId, ref: "SessionsApollo" },
      ],
      leads: [{ type: Mongoose.Schema.Types.ObjectId, ref: "Leads" }], // !!!!!!
      infos: String,
      commentsArr: [
        { type: Mongoose.Schema.Types.ObjectId, ref: "CommentsStudents" },
      ],
      mailinglist: Boolean,
      documents: [{ type: Mongoose.Schema.Types.ObjectId, ref: "Documents" }],
      status: {
        type: String,
        default: "prework",
      },
      isFlagged: {
        type: Boolean,
        default: false,
      },
      linkedIn: String,
      exams: [
        {
          type: Mongoose.Schema.Types.ObjectId,
          ref: "SessionsApollo",
        },
      ],
      createdAt: {
        type: Date,
        default: Date.now,
      },
      updatedAt: {
        type: Date,
        default: Date.now,
      },
    },
    {
      timestamps: false,
    }
  );
  return mongoose.model("Students", schema, "students");
};

And object for “valeri” :

{
  "_id": {
    "$oid": "641083c3f447ae00141a63ac"
  },
  "sessions": [
    {
      "$oid": "62b2f80705ed090018f35200"
    }
  ],
  "leads": [
    {
      "$oid": "63d79e7e1ab49c0016ec3418"
    },
    {
      "$oid": "64de2128c201380014f68360"
    }
  ],
  "commentsArr": [],
  "documents": [
    {
      "$oid": "641083ecf447ae00141a63b0"
    }
  ],
  "status": "training",
  "isFlagged": false,
  "exams": [],
  "email": "xxxxx@yahoo.fr",
  "telephone": "+33xxxxxxxxx",
  "firstname": "Valerie",
  "lastname": "XXXX",
  "mailinglist": true,
  "createdAt": {
    "$date": "2023-03-14T14:25:07.187Z"
  },
  "updatedAt": {
    "$date": "2023-03-14T14:25:07.187Z"
  },
  "__v": 0,
  "githubMember": [
    {
      "$oid": "641effa7f79a140014a47a3b"
    }
  ],
}

Your issue is on your data. Valeri is badly written, it should have

"githubMember":  {
  "$oid": "641effa7f79a140014a47a3b"
}

instead of

"githubMember": [
    {
      "$oid": "641effa7f79a140014a47a3b"
    }
  ]

@vince thank you very much for pointing out this hudge mistake by our side. But it’s still totally weird because it worked until theses days. Anyway, I’ve updated our model. :muscle::pray:

1 Like