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

collapse pco sub-orgs' briefingt/qpnotes records under pco #1342

Merged
merged 19 commits into from
Feb 6, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fb81854
collapse pco sub-orgs' briefingt/qpnotes records under pco
RabiaSajjad Dec 19, 2022
26db8da
update pco-sub org name change to pkcc-pcprc
RabiaSajjad Dec 20, 2022
3601fae
minor improvement to pco sub-orgs migration script
RabiaSajjad Dec 20, 2022
e2f5719
add pco sub-orgs migration scripts for travelq and hospitalityq
RabiaSajjad Dec 20, 2022
8205820
migration script to collapse pco sub-orgs for travelq-nil
RabiaSajjad Dec 23, 2022
da9f980
migration script to collapse pco sub-orgs for hospitalityq-nil
RabiaSajjad Dec 23, 2022
eebf379
add more organizations to migration scripts for pco
RabiaSajjad Mar 1, 2023
a7cb68a
add migration scripts for contracts, travela for pco merge
RabiaSajjad Mar 1, 2023
ead9e21
add migration script for contracts-nil for pco-merge
RabiaSajjad Mar 1, 2023
21c9e90
Merge branch 'master' into merge-pco-sub-orgs
RabiaSajjad Jan 30, 2025
2063c98
update migration scripts for pco sub-orgs
RabiaSajjad Jan 30, 2025
8c53d3d
fix linting error
RabiaSajjad Jan 30, 2025
556d633
add changelog for PR# 1342
RabiaSajjad Jan 30, 2025
bc06c0d
improve migration scripts for python3
RabiaSajjad Jan 31, 2025
455ea51
remove linting error from pco migration scripts
RabiaSajjad Jan 31, 2025
f285bde
remove more linting error from pco migration scripts
RabiaSajjad Jan 31, 2025
cf5818b
Merge branch 'master' into merge-pco-sub-orgs
RabiaSajjad Feb 3, 2025
c090258
update migration scripts to only output PCO sub-orgs data
RabiaSajjad Feb 5, 2025
d45767d
update changelog for PR# 1342
RabiaSajjad Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add migration script for contracts-nil for pco-merge
RabiaSajjad committed Mar 1, 2023
commit ead9e2121ade8d6d5e4b70086e70ef27d7c7bcc8
57 changes: 57 additions & 0 deletions bin/migrate/migrate_contracts_nil_2022_12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# coding=utf-8

"""
migration script to copy all contracts-nil records
for PCO sub-organizations into PCO organization.
Duplicate records from sub-orgnizations for
reporting_period will be ignored
"""

import unicodecsv
import sys
import codecs


sub_orgs = [ 'ghl-lgc',
'iga-aig',
'mdi-mid',
'miga-maig',
'dpm-vpm',
'pkcc-pcprc',
'ql-lq',
'srp-rsp',
'nsira-ossnr',
'ocsec-bccst',
'snsicp-scpssnr',
'sirc-csars',
'jfpc-cfp',
]
PCO = { 'owner_org': 'pco-bcp',
'owner_org_title': 'Privy Council Office | Bureau du Conseil privé' }

assert sys.stdin.read(3) == codecs.BOM_UTF8

in_csv = unicodecsv.DictReader(sys.stdin, encoding='utf-8')
out_csv = unicodecsv.DictWriter(sys.stdout, fieldnames=in_csv.fieldnames, encoding='utf-8')
out_csv.writeheader()

data = []

def report_exists(reporting_period, owner_org):
for row in data:
if row['reporting_period'] == reporting_period and \
row['owner_org'] == owner_org:
return True
return False

for line in in_csv:
if line['owner_org'] in sub_orgs:
if not report_exists(line['reporting_period'], PCO['owner_org']):
line.update(PCO)
data.append(line)
else:
data.append(line)

for line in data:
out_csv.writerow(line)