-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
Currently in the QDB, we have ~1000 tags, ~900 quotes, and 2562 relations between quotes and tags.
When one goes to /api/v2/qdb/tags, the count says there are 2575 tags. With a perPage currently set to 15, that means there should theoretically be 172 pages of data, however, only 72 pages of data exist (because 15 * 72 = ~1000, which matches up with how many tags there are).
We call `findAndCountAll()` to get the count, and this is the SQL that Sequelize generates to get the count:
```sql
SELECT count(*) AS `count`
FROM `tags` AS `tags`
LEFT OUTER JOIN `quotes_tags` AS `quotes.quotes_tags`
ON `tags`.`name` = `quotes.quotes_tags`.`tagName`
LEFT OUTER JOIN `quotes` AS `quotes`
ON `quotes`.`id` = `quotes.quotes_tags`.`quoteId`;
```
We need to figure out what code we need to change in the Sequelize relations so that we ~~~see active tags but also~~~ have the correct count. Could be an issue in Sequelize, so don't discount looking at any related issues on their [repo](https://github.com/sequelize/sequelize).
See:
[Tag Model](https://github.com/rit-sse/node-api/blob/devlop/models/tag.js)
[Quote Model](https://github.com/rit-sse/node-api/blob/devlop/models/quote.js)
[Relations](https://github.com/rit-sse/node-api/blob/devlop/models/index.js)
[Endpoint](https://github.com/rit-sse/node-api/blob/devlop/routes/tags.js)
See Failing Test Cases [1](https://github.com/rit-sse/node-api/blob/16f47c4cd05fc501e9d230da8b8033d024c2d887/test/routes/tags.js#L14) and [2](https://github.com/rit-sse/node-api/blob/16f47c4cd05fc501e9d230da8b8033d024c2d887/test/routes/tags.js#L48)