From c0113bbabc46f20a4110a7173ae0bcf79e088bf2 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 13 May 2014 11:59:14 +0000 Subject: Sumplify functionality, no Context.solves No huge need in sorting Contexts by popularity when there is rating. --- diff --git a/doc/objects.dia b/doc/objects.dia index 1d97f00..d9af4b3 100644 --- a/doc/objects.dia +++ b/doc/objects.dia @@ -2,10 +2,10 @@ - + - + @@ -37,9 +37,6 @@ - - - @@ -56,7 +53,7 @@ - + @@ -64,51 +61,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## @@ -145,20 +100,34 @@ - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + - + @@ -170,16 +139,16 @@ - + - + - + #Context# @@ -220,20 +189,17 @@ - - - - + - + - + @@ -527,29 +493,6 @@ - #downloads# - - - #int [R S]# - - - ## - - - #Number of Release downloads# - - - - - - - - - - - - - #rating# @@ -583,13 +526,13 @@ - + - + @@ -633,20 +576,17 @@ - - - - + - + - + @@ -839,20 +779,17 @@ - - - - + - + - + @@ -1060,29 +997,6 @@ - - - - - - - - - - - - - - - - - - - - - - - ## @@ -1119,20 +1033,34 @@ - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + - + @@ -1144,16 +1072,16 @@ - + - + - + #Post# @@ -1194,20 +1122,17 @@ - - - - + - + - + @@ -1478,29 +1403,6 @@ - #downloads# - - - #int [R S]# - - - ## - - - #Number of attachemtns downloads# - - - - - - - - - - - - - #rating# @@ -1584,20 +1486,17 @@ - - - - + - + - + @@ -1805,7 +1704,6 @@ - @@ -1826,7 +1724,7 @@ - + @@ -1840,7 +1738,7 @@ - + @@ -1857,7 +1755,7 @@ - + @@ -1873,7 +1771,7 @@ - + @@ -1890,7 +1788,7 @@ - + @@ -1906,7 +1804,7 @@ - + @@ -1923,7 +1821,7 @@ - + @@ -1939,7 +1837,7 @@ - + @@ -1956,7 +1854,7 @@ - + @@ -1972,7 +1870,7 @@ - + @@ -1989,7 +1887,7 @@ - + @@ -2005,7 +1903,7 @@ - + @@ -2022,7 +1920,7 @@ - + @@ -2038,7 +1936,7 @@ - + @@ -2055,7 +1953,7 @@ - + @@ -2071,7 +1969,7 @@ - + @@ -2088,7 +1986,7 @@ - + @@ -2104,7 +2002,7 @@ - + @@ -2121,7 +2019,7 @@ - + @@ -2137,7 +2035,7 @@ - + @@ -2154,7 +2052,7 @@ - + @@ -2170,7 +2068,7 @@ - + @@ -2187,7 +2085,7 @@ - + diff --git a/sugar_network/model/context.py b/sugar_network/model/context.py index 89a0c08..45b20c2 100644 --- a/sugar_network/model/context.py +++ b/sugar_network/model/context.py @@ -82,11 +82,6 @@ class Context(db.Resource): def releases(self, value): return value - @db.indexed_property(db.Numeric, slot=2, default=0, - acl=ACL.READ | ACL.LOCAL) - def solves(self, value): - return value - @db.indexed_property(model.Rating, slot=3, acl=ACL.READ | ACL.LOCAL) def rating(self, value): return value diff --git a/sugar_network/node/stats.py b/sugar_network/node/stats.py index d5941eb..6a92deb 100644 --- a/sugar_network/node/stats.py +++ b/sugar_network/node/stats.py @@ -106,7 +106,6 @@ class StatRoutes(object): _rrd = None _stats = None - _solves = None _stated = False def stats_init(self, path, step, rras): @@ -114,7 +113,6 @@ class StatRoutes(object): self._rrd = Rrd(path, 'stats', _DS, step, rras) self._stats = self._rrd.values() - self._solves = {} if not self._stats: for field, traits in _DS.items(): @@ -140,9 +138,6 @@ class StatRoutes(object): stat = stat() self._stats[stat] += shift - if stat == 'solved': - self._solves[r.guid] = self._solves.get(r.guid, 0) + 1 - return result @route('GET', cmd='stats', arguments={ @@ -189,11 +184,6 @@ class StatRoutes(object): if traits['type'] == 'ABSOLUTE': self._stats[field] = 0 - context = this.volume['context'] - for guid, solves in self._solves.items(): - context.update(guid, {'solves': context[guid]['solves'] + solves}) - self._solves.clear() - def stats_regen(self, path, step, rras): for i in Rrd(path, 'stats', _DS, step, rras).files: os.unlink(i) diff --git a/tests/units/node/stats.py b/tests/units/node/stats.py index e7e2f3f..91b4dee 100755 --- a/tests/units/node/stats.py +++ b/tests/units/node/stats.py @@ -371,36 +371,6 @@ class StatsTest(tests.Test): ], this.call(method='GET', cmd='stats', limit=10)) - def test_StatSolvedPerObject(self): - ts = int(time.time()) - volume = self.start_master(auth=RootAuth()) - self.node_routes.stats_init('.', 1, ['RRA:AVERAGE:0.5:1:10']) - - self.override(time, 'time', lambda: ts) - guid = this.call(method='POST', path=['context'], content={'title': '', 'summary': '', 'description': '', 'type': 'activity'}) - this.call(method='POST', path=['context', guid, 'releases'], content=StringIO( - self.zips(('topdir/activity/activity.info', '\n'.join([ - '[Activity]', - 'name = Activity', - 'bundle_id = %s' % guid, - 'exec = true', - 'icon = icon', - 'activity_version = 1', - 'license = Public Domain', - ]))))) - this.call(method='GET', path=['context', guid], cmd='solve') - self.node_routes.stats_commit() - self.assertEqual(1, volume['context'][guid]['solves']) - - this.call(method='GET', path=['context', guid], cmd='solve') - this.call(method='GET', path=['context', guid], cmd='solve') - self.node_routes.stats_commit() - self.assertEqual(3, volume['context'][guid]['solves']) - - this.call(method='GET', path=['context', guid], cmd='solve') - self.node_routes.stats_commit() - self.assertEqual(4, volume['context'][guid]['solves']) - if __name__ == '__main__': tests.main() -- cgit v0.9.1