Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F950156
20130403.conpherencecachemig.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
20130403.conpherencecachemig.php
View Options
<?php
echo
pht
(
"Migrating data from conpherence transactions to conpherence 'cache'...
\n
"
);
$table
=
new
ConpherenceThread
();
$table
->
openTransaction
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
$participant_table
=
new
ConpherenceParticipant
();
$conpherences
=
new
LiskMigrationIterator
(
$table
);
foreach
(
$conpherences
as
$conpherence
)
{
echo
pht
(
'Migrating conpherence #%d'
,
$conpherence
->
getID
()).
"
\n
"
;
$participants
=
id
(
new
ConpherenceParticipant
())
->
loadAllWhere
(
'conpherencePHID = %s'
,
$conpherence
->
getPHID
());
$transactions
=
id
(
new
ConpherenceTransaction
())
->
loadAllWhere
(
'objectPHID = %s'
,
$conpherence
->
getPHID
());
$participation_hash
=
mgroup
(
$participants
,
'getBehindTransactionPHID'
);
$message_count
=
0
;
$participants_to_cache
=
array
();
foreach
(
$transactions
as
$transaction
)
{
$participants_to_cache
[]
=
$transaction
->
getAuthorPHID
();
if
(
$transaction
->
getTransactionType
()
==
PhabricatorTransactions
::
TYPE_COMMENT
)
{
$message_count
++;
}
$participants_to_update
=
idx
(
$participation_hash
,
$transaction
->
getPHID
(),
array
());
if
(
$participants_to_update
)
{
queryfx
(
$conn_w
,
'UPDATE %T SET seenMessageCount = %d '
.
'WHERE conpherencePHID = %s AND participantPHID IN (%Ls)'
,
$participant_table
->
getTableName
(),
$message_count
,
$conpherence
->
getPHID
(),
mpull
(
$participants_to_update
,
'getParticipantPHID'
));
}
}
$participants_to_cache
=
array_slice
(
array_unique
(
array_reverse
(
$participants_to_cache
)),
0
,
10
);
queryfx
(
$conn_w
,
'UPDATE %T '
.
'SET recentParticipantPHIDs = %s, '
.
'messageCount = %d '
.
'WHERE phid = %s'
,
$table
->
getTableName
(),
json_encode
(
$participants_to_cache
),
$message_count
,
$conpherence
->
getPHID
());
}
$table
->
saveTransaction
();
echo
"
\n
"
.
pht
(
'Done.'
).
"
\n
"
;
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 17, 1:58 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
224094
Default Alt Text
20130403.conpherencecachemig.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment