Revision 096a7c3b
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/versions/2a309a9a3438_fix_statistics_negat.py | ||
---|---|---|
1 |
"""fix statistics negative population |
|
2 |
|
|
3 |
Revision ID: 2a309a9a3438 |
|
4 |
Revises: 165ba3fbfe53 |
|
5 |
Create Date: 2013-01-02 09:12:30.222261 |
|
6 |
|
|
7 |
""" |
|
8 |
|
|
9 |
# revision identifiers, used by Alembic. |
|
10 |
revision = '2a309a9a3438' |
|
11 |
down_revision = '165ba3fbfe53' |
|
12 |
|
|
13 |
from alembic import op |
|
14 |
import sqlalchemy as sa |
|
15 |
|
|
16 |
|
|
17 |
def upgrade(): |
|
18 |
st = sa.sql.table( |
|
19 |
'statistics', |
|
20 |
sa.sql.column('node', sa.Integer), |
|
21 |
sa.sql.column('population', sa.Integer) |
|
22 |
) |
|
23 |
|
|
24 |
u = st.update().where(st.c.population < 0).values({'population': 0}) |
|
25 |
op.execute(u) |
|
26 |
|
|
27 |
def downgrade(): |
|
28 |
pass |
b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py | ||
---|---|---|
492 | 492 |
else: |
493 | 493 |
prepopulation, presize = r |
494 | 494 |
population += prepopulation |
495 |
population = max(population, 0) |
|
495 | 496 |
size += presize |
496 | 497 |
|
497 | 498 |
#insert or replace |
b/snf-pithos-backend/pithos/backends/lib/sqlite/node.py | ||
---|---|---|
412 | 412 |
else: |
413 | 413 |
prepopulation, presize = r |
414 | 414 |
population += prepopulation |
415 |
population = max(population, 0) |
|
415 | 416 |
size += presize |
416 | 417 |
self.execute(qu, (node, population, size, mtime, cluster)) |
417 | 418 |
|
Also available in: Unified diff