Plots2: 按“人数”排序时,在主题卡上的帖子数之前删除“-”

创建于 2020-05-28  ·  25评论  ·  资料来源: publiclab/plots2

请描述问题

当点击“人数”排序选项时,主题卡上的帖子数之前似乎有一个小小的“-”,使其看起来像是帖子数为负数。 看截图:

Screen Shot 2020-05-20 at 10 36 42 AM (1)

你期望看到什么你没有看到?

我希望看到正整数。

请告诉我们在哪里看

https://publiclab.org/tags?sort=followers&order=asc

你的 PublicLab.org 用户名是什么?

这可以帮助我们诊断问题:

丽兹

最有用的评论

@ebarry我认为这实际上是一个更严重的问题:sweat_smile:我在这里做了更改https://github.com/publiclab/plots2/pull/7609但我一定把它搞砸了并计算了错误的计数想:失望:在@jywarren 中循环抱歉可能需要一些帮助来解决这个问题:sweat_smile:

所有25条评论

有没有人手头有代码链接可以在这里添加? 提前致谢!

@ebarry我认为这实际上是一个更严重的问题:sweat_smile:我在这里做了更改https://github.com/publiclab/plots2/pull/7609但我一定把它搞砸了并计算了错误的计数想:失望:在@jywarren 中循环抱歉可能需要一些帮助来解决这个问题:sweat_smile:

@Tlazypanda我们可以看看其他使用Tag.counter类型代码的地方,并尝试切换到那个地方吗?

https://github.com/publiclab/plots2/pull/7609/files#diff -8fe92870a7f027a46eed82a51c5c16bcR118

但是,计数相差很小。 我想知道这是否是一些东西被垃圾邮件发送然后影响数学的问题?

例如,查看这些计数之间的差异:

image

image

我们可以查找 236 计数的计算位置并切换到那个位置,也许?

所以使用控制器生成的实例变量:

https://github.com/publiclab/plots2/blob/c056cb0b97ebc6b34184ec3dfa9a83e1096395f9/app/views/tag/show.html.erb#L58

我相信这是计算的地方:

https://github.com/publiclab/plots2/blob/c056cb0b97ebc6b34184ec3dfa9a83e1096395f9/app/controllers/tag_controller.rb#L551 -L560

@jywarren ,我可以在 tag/:id 中看到,即 tag 的显示页面是我们只在那边和主题卡中显示研究笔记,我们试图显示研究笔记+问题。
所以,我认为我们需要做的是我们需要以与在tag#show中所做的相同的方式获取笔记,并且为了在主题卡底部显示计数,我们只需要使用这个数学表达式:
带有标记名的笔记数 - 主题卡中显示的笔记数

我们需要以与在 tag#show 中所做的相同的方式获取笔记

你好,刚刚好! 在此处注意“单一事实来源”的概念: https :

我相信我们应该在这里使用相同的计算: https :

@urvashigupta7 非常感谢您的参与! 您是否有兴趣进行这些更改?

我还认为在https://github.com/publiclab/plots2/pull/7476/ 中,我们没有过滤掉垃圾邮件。 所以在这些行上,我们应该添加.where(status: 1)

https://github.com/publiclab/plots2/blob/c056cb0b97ebc6b34184ec3dfa9a83e1096395f9/app/controllers/tag_controller.rb#L551 -L560

该代码也取决于此,它不会过滤垃圾邮件:

https://github.com/publiclab/plots2/blob/f4dfdcbae4dfa60b0ec357081ee1fae6f2089436/app/models/node.rb#L609 -L618

同样,此代码还需要使用相同的过滤器过滤垃圾邮件:

https://github.com/publiclab/plots2/blob/f4dfdcbae4dfa60b0ec357081ee1fae6f2089436/app/models/tag.rb#L118 -L124

唔。 看起来我们正在从@total_posts计算中过滤垃圾邮件,因为它运行 /after/ 这些行:

https://github.com/publiclab/plots2/blob/c056cb0b97ebc6b34184ec3dfa9a83e1096395f9/app/controllers/tag_controller.rb#L204 -L218

但是, Tag.counterNode.for_tagname_and_type都不是过滤器。 也许这就是违规行为?

我想这里的计数仍然不对。 例如, https://stable.publiclab.org/tags现在列出了balloon-mapping 692 个帖子,但这里是该标签的统计数据(稳定版):

image

我认为我们需要依赖于这个修复: https :

然后我们可以再次检查。 重新打开片刻......手指🤞

https://github.com/publiclab/plots2/pull/8245现在完成了! 并且有单元测试,太好了。 好的,现在这可能有效......

好的,它说573 posts » -- 嗯

研究笔记 469
问题 37
维基页面 77
人数 346

我的意思是,笔记加上维基 = 546 ......? 加上问题是583?

现在,在稳定版上测试tests标签,我怀疑可能有一些缓存正在进行。 将该标签添加到新笔记https://stable.publiclab.org/notes/aidanswope/05-21-2019/angel-s-point-balloon-map-updated并没有导致笔记标签从7 到 8,虽然tag.counttag.run_count的结果一样返回 8

https://stable.publiclab.org/tag/tests

YESSSSS 缓存了 5 分钟: https :

好的,所以跟踪选项卡计数:

https://github.com/publiclab/plots2/blob/e97eff7464a544a97f4b38f169f76250600b3148/app/models/node.rb#L621 -L630

Node.where(status: 1, type: 'note').includes(:revision, :tag).references(:term_data, :node_revisions).where('term_data.name = ? OR term_data.parent = ?', 'balloon-mapping', 'balloon-mapping').where.not(nid: qids).count => 470

与主题卡数对比:

NodeTag.joins(:node).where(tid: 10).where('node.status = 1 AND node.type = "note"').where.not(nid: qids).count => 467

😭

这三个是区别: [6129, 7236, 7414] --

[#,

,

]

很奇怪! 有两个原因:3 个笔记与 10 个缺失的笔记不同(以为我们还没有看过问题),并且,这三个似乎很正常,除了一个是在 2013 年 2 月,2 个是在 2013 年 5 月:

(更新:有关重复的标记名,请参见下文)

也很有趣:

Node.where(status: 1, type: 'note').includes(:revision, :tag).references(:term_data, :node_revisions).where('term_data.name = ? OR term_data.parent = ?', 'balloon-mapping', 'balloon-mapping').where(nid: qids).count => 29

这同意:

NodeTag.joins(:node).where(tid: 10).where('node.status = 1 AND node.type = "note"').where(nid: qids).count

与选项卡上显示的 37 相比,计算公式为:

https://github.com/publiclab/plots2/blob/e97eff7464a544a97f4b38f169f76250600b3148/app/models/node.rb#L640 -L646

啊哈! 最后一部分显示标记question:balloon-mapping帖子包括在该计数中,即使它们没有基本的balloon-mapping标签!!!

以下 8 个帖子似乎有question:balloon-mapping但没有balloon-mapping

[13556, 15762, 16426, 18994, 20694, 11301, 12251, 19625]

好的,这样我们就可以在 2 个节点内。 现在让我们手动比较:

irb(main):040:0> NodeTag.joins(:node).where(tid: 10).where('node.status = 1 AND node.type = "note"').count
=> 496
irb(main):041:0> Node.where(status: 1, type: 'note').includes(:tag).references(:term_data).where('term_data.name = ?', 'balloon-mapping').count
=> 499
irb(main):022:0> Node.where(status: 1, type: 'note').includes(:revision, :tag).references(:term_data, :node_revisions).where('term_data.name = ? OR term_data.parent = ?', 'balloon-mapping', 'balloon-mapping').collect(&:nid)
=> [146, 253, 254, 268, 403, 511, 724, 732, 743, 913, 1482, 1489, 1620, 1626, 1627, 1632, 1715, 1849, 1968, 1994, 2126, 2138, 2144, 2476, 2589, 2930, 3115, 3325, 4649, 4952, 5038, 5220, 5250, 5978, 6934, 7050, 7189, 7294, 7314, 7491, 7577, 7593, 7995, 8189, 8907, 8913, 8914, 8950, 9019, 9032, 9042, 9086, 9417, 9434, 9742, 9888, 9977, 10541, 11019, 11100, 11223, 11574, 11582, 11827, 12201, 12240, 12491, 12619, 12708, 13095, 13424, 13945, 14022, 14095, 14183, 14185, 14219, 14515, 14572, 14587, 14597, 14600, 14611, 14620, 14813, 14907, 14909, 14983, 15545, 15568, 16591, 16653, 16746, 16877, 18316, 19153, 19272, 19462, 19558, 19578, 19620, 19762, 20331, 23549, 24101, 24102, 1795, 6635, 347, 369, 439, 444, 792, 861, 1665, 1668, 1962, 2135, 2143, 2152, 2245, 2277, 2783, 2784, 3563, 3635, 3670, 4482, 4516, 4755, 4760, 4923, 4925, 6059, 7641, 10181, 10489, 11101, 11724, 13243, 13880, 13948, 17322, 64, 166, 202, 344, 1666, 1816, 1818, 1819, 2919, 3354, 3736, 3821, 4087, 8020, 8947, 9301, 11199, 11260, 11261, 11755, 12161, 1544, 1739, 1742, 1892, 2006, 5494, 9353, 10705, 828, 1515, 1786, 1877, 1926, 1949, 2121, 2625, 2666, 2677, 2846, 2892, 2961, 4092, 4907, 5394, 5415, 5664, 7132, 7367, 7368, 7717, 7964, 8400, 10243, 6175, 9507, 4636, 6293, 3014, 6624, 9806, 10289, 10554, 11278, 11391, 12104, 12622, 12894, 13143, 9935, 10036, 10196, 10450, 11283, 11719, 11769, 12237, 10246, 10605, 2462, 9497, 1889, 2131, 2443, 3026, 4127, 4252, 4673, 5538, 5893, 6608, 8034, 8902, 8959, 9644, 9707, 10045, 10162, 10335, 10336, 10337, 10373, 10540, 10570, 11107, 11110, 11112, 11124, 11143, 11175, 11298, 11336, 12053, 12203, 12590, 16984, 19515, 19580, 23822, 2163, 3634, 7620, 10166, 11056, 11319, 11589, 1541, 1652, 1676, 1677, 1746, 2154, 2237, 2275, 2311, 2623, 2785, 3454, 3652, 3822, 4014, 4691, 4720, 4950, 5161, 7785, 8866, 8926, 8928, 8937, 8958, 8986, 9759, 9915, 10101, 10230, 10244, 10302, 10311, 10374, 10523, 10602, 11021, 11078, 11103, 11253, 11726, 11988, 12686, 12752, 12757, 13400, 13845, 14116, 14660, 14713, 14756, 1716, 2660, 7191, 7192, 1743, 1636, 1900, 9317, 10651, 1741, 13904, 3096, 2352, 2824, 4091, 2715, 6080, 6082, 2732, 3801, 3908, 4545, 7121, 10284, 13791, 10631, 4921, 6751, 9429, 9743, 11577, 17331, 6073, 9858, 10711, 11118, 6525, 10267, 9034, 11252, 11268, 8033, 8868, 10159, 10214, 9027, 9785, 9033, 9076, 9299, 14501, 14508, 14562, 21733, 10282, 9909, 11178, 11738, 10024, 12667, 11262, 11343, 11978, 11983, 11992, 11826, 11061, 10227, 10428, 11077, 11131, 11137, 11280, 11281, 11518, 11551, 11807, 11812, 11947, 12039, 14158, 14729, 14943, 15641, 16273, 16349, 18560, 19269, 19286, 21547, 10343, 14852, 14901, 15352, 15387, 10612, 10638, 10986, 10994, 20181, 11002, 11127, 11128, 11183, 12166, 11342, 11494, 11955, 11673, 11707, 11711, 12190, 18839, 13802, 14595, 12227, 15912, 14007, 13093, 13096, 12981, 13102, 13160, 13194, 13196, 13227, 13242, 13267, 13278, 13281, 13298, 14168, 15161, 23143, 14058, 14766, 13748, 13839, 15603, 14241, 14179, 14239, 14246, 14240, 14255, 14488, 14487, 14245, 14785, 15160, 14703, 14995, 16571, 15172, 15179, 15424, 15713, 15732, 16141, 16284, 16334, 16382, 17387, 17498, 17499, 18498, 16960, 19689, 17815, 19394, 19464, 19650, 19955, 19476, 19477, 23203, 6129, 7236, 7414]

对比:


irb(main):024:0> NodeTag.joins(:node).where(tid: 10).where('node.status = 1 AND node.type = "note"').collect(&:nid)
=> [146, 253, 254, 268, 403, 511, 724, 732, 743, 913, 1482, 1489, 1620, 1626, 1627, 1632, 1715, 1849, 1968, 1994, 2126, 2138, 2144, 2476, 2589, 2930, 3115, 3325, 4649, 4952, 5038, 5220, 5250, 5978, 6934, 7050, 7189, 7294, 7314, 7491, 7577, 7593, 7995, 8189, 8907, 8913, 8914, 8950, 9019, 9032, 9042, 9086, 9417, 9434, 9742, 9888, 9977, 10541, 11019, 11100, 11223, 11574, 11582, 11827, 12201, 12240, 12491, 12619, 12708, 13095, 13424, 13945, 14022, 14095, 14183, 14185, 14219, 14515, 14572, 14587, 14597, 14600, 14611, 14620, 14813, 14907, 14909, 14983, 15545, 15568, 16591, 16653, 16746, 16877, 18316, 19153, 19272, 19462, 19558, 19578, 19620, 19762, 20331, 23549, 24101, 24102, 1795, 6635, 347, 369, 439, 444, 792, 861, 1665, 1668, 1962, 2135, 2143, 2152, 2245, 2277, 2783, 2784, 3563, 3635, 3670, 4482, 4516, 4755, 4760, 4923, 4925, 6059, 7641, 10181, 10489, 11101, 11724, 13243, 13880, 13948, 17322, 64, 166, 202, 344, 1666, 1816, 1818, 1819, 2919, 3354, 3736, 3821, 4087, 8020, 8947, 9301, 11199, 11260, 11261, 11755, 12161, 1544, 1739, 1742, 1892, 2006, 5494, 9353, 10705, 828, 1515, 1786, 1877, 1926, 1949, 2121, 2625, 2666, 2677, 2846, 2892, 2961, 4092, 4907, 5394, 5415, 5664, 7132, 7367, 7368, 7717, 7964, 8400, 10243, 6175, 9507, 4636, 6293, 3014, 6624, 9806, 10289, 10554, 11278, 11391, 12104, 12622, 12894, 13143, 9935, 10036, 10196, 10450, 11283, 11719, 11769, 12237, 10246, 10605, 2462, 9497, 1889, 2131, 2443, 3026, 4127, 4252, 4673, 5538, 5893, 6608, 8034, 8902, 8959, 9644, 9707, 10045, 10162, 10335, 10336, 10337, 10373, 10540, 10570, 11107, 11110, 11112, 11124, 11143, 11175, 11298, 11336, 12053, 12203, 12590, 16984, 19515, 19580, 23822, 2163, 3634, 7620, 10166, 11056, 11319, 11589, 1541, 1652, 1676, 1677, 1746, 2154, 2237, 2275, 2311, 2623, 2785, 3454, 3652, 3822, 4014, 4691, 4720, 4950, 5161, 7785, 8866, 8926, 8928, 8937, 8958, 8986, 9759, 9915, 10101, 10230, 10244, 10302, 10311, 10374, 10523, 10602, 11021, 11078, 11103, 11253, 11726, 11988, 12686, 12752, 12757, 13400, 13845, 14116, 14660, 14713, 14756, 1716, 2660, 7191, 7192, 1743, 1636, 1900, 9317, 10651, 1741, 13904, 3096, 2352, 2824, 4091, 2715, 6080, 6082, 2732, 3801, 3908, 4545, 7121, 10284, 13791, 10631, 4921, 6751, 9429, 9743, 11577, 17331, 6073, 9858, 10711, 11118, 6525, 10267, 9034, 11252, 11268, 8033, 8868, 10159, 10214, 9027, 9785, 9033, 9076, 9299, 14501, 14508, 14562, 21733, 10282, 9909, 11178, 11738, 10024, 12667, 11262, 11343, 11978, 11983, 11992, 11826, 11061, 10227, 10428, 11077, 11131, 11137, 11280, 11281, 11518, 11551, 11807, 11812, 11947, 12039, 14158, 14729, 14943, 15641, 16273, 16349, 18560, 19269, 19286, 21547, 10343, 14852, 14901, 15352, 15387, 10612, 10638, 10986, 10994, 20181, 11002, 11127, 11128, 11183, 12166, 11342, 11494, 11955, 11673, 11707, 11711, 12190, 18839, 13802, 14595, 12227, 15912, 14007, 13093, 13096, 12981, 13102, 13160, 13194, 13196, 13227, 13242, 13267, 13278, 13281, 13298, 14168, 15161, 23143, 14058, 14766, 13748, 13839, 15603, 14241, 14179, 14239, 14246, 14240, 14255, 14488, 14487, 14245, 14785, 15160, 14703, 14995, 16571, 15172, 15179, 15424, 15713, 15732, 16141, 16284, 16334, 16382, 17387, 17498, 17499, 18498, 16960, 19689, 17815, 19394, 19464, 19650, 19955, 19476, 19477, 23203]

啊哈。 也许这个:

Tag.where(name: 'balloon-mapping').length => 4
Tag.where(name: 'balloon-mapping').collect(&:tid) => [10, 3205, 3591, 4032]

是的,这就是差异:

irb(main):045:0> NodeTag.joins(:node).where(tid: [10, 3205, 3591, 4032]).where('node.status = 1 AND node.type = "note"').count
=> 499
irb(main):046:0> Node.where(status: 1, type: 'note').includes(:tag).references(:term_data).where('term_data.name = ?', 'balloon-mapping').count
=> 499

irb(main):050:0> Tag.where(name: 'balloon-mapping').collect(&:count)
=> [574, 1, 1, 1]

但是,特别是对于 #7334 中的methodproject错误

irb(main):047:0> Tag.where(name: 'method').collect(&:tid)
=> [14474]
irb(main):048:0> Tag.where(name: 'project').collect(&:tid)
=> [14751]

好的,我修复了重复的标签:

irb(main):053:0> NodeTag.where(tid: [3205, 3591, 4032]).each do |nt|
irb(main):054:1* nt.tid = 10
irb(main):055:1> nt.save
irb(main):056:1> end

但是我敢打赌数据库中有更多。 我们可能想做一个更大的项目来整合这些。

更新:是的,还有 28 个其他实例:

irb(main):063:0> Tag.count
=> 18532
irb(main):065:0> Tag.all.collect(&:name).uniq.count
=> 18504


irb(main):069:0> (Tag.all - Tag.all.group(:name)).collect(&:name)
=> ["fold-up", "gulf-coast", "kite-mapping", "gulf-coast", "brooklyn", "new-york-city", "balloon-mapping", "spectrometer", "farmhack", "white-balance", "fresh-kills", "balloon-mapping", "balloon-mapping", "kite-mapping", "newsletter", "newsletter", "passenger-pigeon", "jamaica-bay", "mobile-spectrometer", "infragram-sandbox", "mailing-lists", "diy-kite", "water-sensing", "carbon-arc", "diy-kite", "diy-kite", "workplace", "emergencies"]

我现在的建议是:

我们已经缩小了很多范围,它有两个部分。

  1. “幽灵”标签 - 重复的标签名,所以基本上有些没有被计算在内(已解决,尽管其他一些标签存在约 15 个其他实例)
  2. question:_____格式标签,在/tag/____页面上的问题选项卡下计算,但如果它们没有自己的基本标签,则不计算在主题卡中。 示例:8 个帖子有question:balloon-mapping但没有balloon-mapping ,因此他们将我们的计数增加了 8。

我对 (2) 的看法是我们应该把它写下来并意识到它,但不要解决它(无论如何我想不出一个干净的解决方案)。

而且,即使在进行了所有挖掘之后,我仍然对balloon-mapping有 1 的差异。 但我认为我们是如此接近以至于我们基本上应该没问题,因为它是最大的标签之一,这个问题不太可能影响其他人。 也有兴趣听听其他人对此的看法!

此页面是否有帮助?
0 / 5 - 0 等级