allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] allura git commit: [#8081] safeguards/performance tweaks for running on a large database
Date Fri, 26 Oct 2018 18:48:44 GMT
Repository: allura
Updated Branches:
  refs/heads/master 19e03b88b -> 7e127c759


[#8081] safeguards/performance tweaks for running on a large database


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/7e127c75
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/7e127c75
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/7e127c75

Branch: refs/heads/master
Commit: 7e127c75914944db888d79cb5ea7cc269569579d
Parents: 137e47e
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Oct 26 14:47:03 2018 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Oct 26 14:47:14 2018 -0400

----------------------------------------------------------------------
 scripts/migrations/034-update_and_mr_titles.py  | 60 ------------------
 ...update_subscriptions_ticket_and_mr_titles.py | 67 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7e127c75/scripts/migrations/034-update_and_mr_titles.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/034-update_and_mr_titles.py b/scripts/migrations/034-update_and_mr_titles.py
deleted file mode 100644
index 8d4854c..0000000
--- a/scripts/migrations/034-update_and_mr_titles.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-import logging
-import re
-import sys
-from pylons import tmpl_context as c
-from bson import ObjectId
-from ming.orm import ThreadLocalORMSession
-
-from allura import model as M
-from forgetracker import model as TM
-
-log = logging.getLogger(__name__)
-
-
-def main():
-    task = sys.argv[-1]
-    c.project = None
-
-    # Fix ticket artifcat titles
-    title = re.compile('(Ticket [0-9]+.*)')
-    subs_tickets = M.Mailbox.query.find(dict(artifact_title=title)).all()
-    print 'Found total %d old artifact titles (tickets).' % len(subs_tickets)
-    for sub in subs_tickets:
-        ticket = TM.Ticket.query.get(_id = ObjectId(sub.artifact_index_id.split('#')[1]))
-        new_title = 'Ticket #%d: %s' % (ticket.ticket_num, ticket.summary)
-        print '"%s" --> "%s"' % (sub.artifact_title , new_title)
-        if(task != 'diff'):
-            sub.artifact_title = new_title
-
-    # Fix merge request artifact titles
-    title = re.compile('(Merge request: .*)')
-    subs_mrs = M.Mailbox.query.find(dict(artifact_title=title)).all()
-    print 'Found total %d old artifact titles (merge_requests).' % len(subs_tickets)
-    for sub in subs_mrs:
-        merge_request = M.MergeRequest.query.get(_id = ObjectId(sub.artifact_index_id.split('#')[1]))
-        new_title = 'Merge Request #%d: %s' % (merge_request.request_number, merge_request.summary)
-        print '"%s" --> "%s"' % (sub.artifact_title , new_title)
-        if(task != 'diff'):
-            sub.artifact_title = new_title
-
-    ThreadLocalORMSession.flush_all()
-
-if __name__ == '__main__':
-    main()

http://git-wip-us.apache.org/repos/asf/allura/blob/7e127c75/scripts/migrations/034-update_subscriptions_ticket_and_mr_titles.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/034-update_subscriptions_ticket_and_mr_titles.py b/scripts/migrations/034-update_subscriptions_ticket_and_mr_titles.py
new file mode 100644
index 0000000..ff13e8b
--- /dev/null
+++ b/scripts/migrations/034-update_subscriptions_ticket_and_mr_titles.py
@@ -0,0 +1,67 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import logging
+import re
+import sys
+from pylons import tmpl_context as c
+from bson import ObjectId
+
+from ming.odm import session
+from ming.orm import ThreadLocalORMSession
+
+from allura import model as M
+from forgetracker import model as TM
+
+log = logging.getLogger(__name__)
+
+
+def main():
+    task = sys.argv[-1]
+    c.project = None
+
+    # Fix ticket artifcat titles
+    title = re.compile('^Ticket [0-9]')
+    subs_tickets = M.Mailbox.query.find(dict(artifact_title=title)).all()
+    print 'Found total %d old artifact titles (tickets).' % len(subs_tickets)
+    for sub in subs_tickets:
+        ticket = TM.Ticket.query.get(_id = ObjectId(sub.artifact_index_id.split('#')[1]))
+        if not ticket:
+            print 'Could not find ticket for %s' % sub
+        new_title = 'Ticket #%d: %s' % (ticket.ticket_num, ticket.summary)
+        print '"%s" --> "%s"' % (sub.artifact_title , new_title)
+        if(task != 'diff'):
+            sub.artifact_title = new_title
+        session(sub).flush(sub)
+
+    # Fix merge request artifact titles
+    title = re.compile('^Merge request: ')
+    subs_mrs = M.Mailbox.query.find(dict(artifact_title=title)).all()
+    print 'Found total %d old artifact titles (merge_requests).' % len(subs_tickets)
+    for sub in subs_mrs:
+        merge_request = M.MergeRequest.query.get(_id = ObjectId(sub.artifact_index_id.split('#')[1]))
+        if not merge_request:
+            print 'Could not find merge request for %s' % sub
+        new_title = 'Merge Request #%d: %s' % (merge_request.request_number, merge_request.summary)
+        print '"%s" --> "%s"' % (sub.artifact_title , new_title)
+        if(task != 'diff'):
+            sub.artifact_title = new_title
+        session(sub).flush(sub)
+
+
+if __name__ == '__main__':
+    main()


Mime
View raw message