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

QDB: Tag Count Incorrect #68

Open
billdybas opened this issue Dec 31, 2017 · 0 comments
Open

QDB: Tag Count Incorrect #68

billdybas opened this issue Dec 31, 2017 · 0 comments

Comments

@billdybas
Copy link
Member

billdybas commented Dec 31, 2017

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant